Class: Bambora::Rest::WWWFormClient

Inherits:
Client
  • Object
show all
Defined in:
lib/bambora/rest/www_form_client.rb

Overview

The base class for making www form urlencoded requests.

Constant Summary collapse

CONTENT_TYPE =
'application/x-www-form-urlencoded'

Instance Attribute Summary

Attributes inherited from Client

#base_url, #merchant_id, #sub_merchant_id

Instance Method Summary collapse

Methods inherited from Client

#initialize

Constructor Details

This class inherits a constructor from Bambora::Rest::Client

Instance Method Details

#post(path:, body:) ⇒ Hash

Make a POST Request.

Parameters:

  • path (String)

    Indicating request path.

  • body (Hash)

    Data to be sent in the query parameters of the request.

Returns:

  • (Hash)

    Indicating success or failure of the operation.



16
17
18
19
20
21
22
23
24
25
26
27
# 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