class Bambora::Rest::WWWFormClient

The base class for making www form urlencoded requests.

Constants

CONTENT_TYPE

Public Instance Methods

post(path:, body:) click to toggle source

Make a POST Request.

@param path [String] Indicating request path. @param body [Hash] Data to be sent in the query parameters of the request.

@return [Hash] Indicating success or failure of the operation.

Calls superclass method Bambora::Rest::Client#post
# File lib/bambora/rest/www_form_client.rb, line 16
def post(path:, body:)
  # Both Faraday's and Excon's docs show that you can pass a hash into the +body+ and set the content type to
  # application/x-www-form-urlencoded and the +body+ will be transformed into query parameters, however, this
  # did not work in testing so I am manually transforming the hash into query parameters here.
  parse_response_body(
    super(
      path: path,
      body: Bambora::Builders::WWWFormParameters.new(body: body).to_s,
      headers: build_headers,
    ),
  )
end

Private Instance Methods

build_headers() click to toggle source
# File lib/bambora/rest/www_form_client.rb, line 31
def build_headers
  {
    'Content-Type' => CONTENT_TYPE,
  }
end