Class: CheckoutApiClient
- Inherits:
-
BaseApiClient
- Object
- BaseApiClient
- CheckoutApiClient
- Defined in:
- lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb
Instance Method Summary collapse
- #create_checkout_request(merchant_id, commerce_case_id, payload) ⇒ Object
- #get_checkout_request(merchant_id, commerce_case_id, checkout_id) ⇒ Object
- #get_checkouts_request(merchant_id, query_params = nil) ⇒ Object
-
#initialize(config) ⇒ CheckoutApiClient
constructor
A new instance of CheckoutApiClient.
- #remove_checkout_request(merchant_id, commerce_case_id, checkout_id) ⇒ Object
- #update_checkout_request(merchant_id, commerce_case_id, checkout_id, payload) ⇒ Object
Constructor Details
#initialize(config) ⇒ CheckoutApiClient
Returns a new instance of CheckoutApiClient.
13 14 15 |
# File 'lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb', line 13 def initialize(config) super(config) end |
Instance Method Details
#create_checkout_request(merchant_id, commerce_case_id, payload) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb', line 17 def create_checkout_request(merchant_id, commerce_case_id, payload) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts") request_init = { method: 'POST', headers: { 'Content-Type' => 'application/json' }, body: JSON.generate(payload) } make_api_call(url.to_s, request_init) end |
#get_checkout_request(merchant_id, commerce_case_id, checkout_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb', line 32 def get_checkout_request(merchant_id, commerce_case_id, checkout_id) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? raise TypeError, CHECKOUT_ID_REQUIRED_ERROR if checkout_id.nil? || checkout_id.empty? url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}") request_init = { method: 'GET', headers: {} } make_api_call(url.to_s, request_init) end |
#get_checkouts_request(merchant_id, query_params = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb', line 47 def get_checkouts_request(merchant_id, query_params = nil) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? url = URI.join(get_config.host, "/v1/#{merchant_id}/checkouts") if query_params url.query = URI.encode_www_form(query_params.to_query_map) end request_init = { method: 'GET', headers: {} } make_api_call(url.to_s, request_init) end |
#remove_checkout_request(merchant_id, commerce_case_id, checkout_id) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb', line 80 def remove_checkout_request(merchant_id, commerce_case_id, checkout_id) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? raise TypeError, CHECKOUT_ID_REQUIRED_ERROR if checkout_id.nil? || checkout_id.empty? url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}") request_init = { method: 'DELETE', headers: {} } make_api_call(url.to_s, request_init) { nil } end |
#update_checkout_request(merchant_id, commerce_case_id, checkout_id, payload) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/PCP-server-Ruby-SDK/api/checkout_api_client.rb', line 64 def update_checkout_request(merchant_id, commerce_case_id, checkout_id, payload) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? raise TypeError, CHECKOUT_ID_REQUIRED_ERROR if checkout_id.nil? || checkout_id.empty? url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}") request_init = { method: 'PATCH', headers: { 'Content-Type' => 'application/json' }, body: JSON.generate(payload) } make_api_call(url.to_s, request_init) { nil } end |