Class: PaymentInformationApiClient
- Inherits:
-
BaseApiClient
- Object
- BaseApiClient
- PaymentInformationApiClient
- Defined in:
- lib/PCP-server-Ruby-SDK/api/payment_information_api_client.rb
Constant Summary collapse
- PAYMENT_INFORMATION_ID_REQUIRED_ERROR =
'Payment Information ID is required'
Instance Method Summary collapse
- #create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) ⇒ Object
- #get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id) ⇒ Object
-
#initialize(config) ⇒ PaymentInformationApiClient
constructor
A new instance of PaymentInformationApiClient.
Constructor Details
#initialize(config) ⇒ PaymentInformationApiClient
Returns a new instance of PaymentInformationApiClient.
11 12 13 |
# File 'lib/PCP-server-Ruby-SDK/api/payment_information_api_client.rb', line 11 def initialize(config) super(config) end |
Instance Method Details
#create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/PCP-server-Ruby-SDK/api/payment_information_api_client.rb', line 15 def create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}/payment-informations") request_init = { method: 'POST', headers: { 'Content-Type' => 'application/json' }, body: JSON.generate(payload) } make_api_call(url.to_s, request_init) end |
#get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/PCP-server-Ruby-SDK/api/payment_information_api_client.rb', line 29 def get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id) validate_ids(merchant_id, commerce_case_id, checkout_id) raise TypeError, PAYMENT_INFORMATION_ID_REQUIRED_ERROR if payment_information_id.nil? || payment_information_id.empty? url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}/payment-informations/#{payment_information_id}") request_init = { method: 'GET', headers: {} } make_api_call(url.to_s, request_init) end |