Class: PCPServerSDK::Endpoints::OrderManagementCheckoutActionsApiClient

Inherits:
BaseApiClient
  • Object
show all
Defined in:
lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ OrderManagementCheckoutActionsApiClient

Returns a new instance of OrderManagementCheckoutActionsApiClient.



13
14
15
# File 'lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb', line 13

def initialize(config)
  super(config)
end

Instance Method Details

#cancel_order(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::CancelResponse

Cancel an order

Parameters:

  • merchant_id (String)

    The merchant identifier

  • commerce_case_id (String)

    The commerce case identifier

  • checkout_id (String)

    The checkout identifier

  • payload (PCPServerSDK::Models::CancelRequest)

    The cancel request

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb', line 86

def cancel_order(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}/cancel")

  request_init = {
    method: 'POST',
    headers: { 'Content-Type' => 'application/json' },
    body: JSON.generate(payload)
  }

  response = make_api_call(url.to_s, request_init)
  deserialize_json(response, PCPServerSDK::Models::CancelResponse)
end

#create_order(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::OrderResponse

Create an order

Parameters:

  • merchant_id (String)

    The merchant identifier

  • commerce_case_id (String)

    The commerce case identifier

  • checkout_id (String)

    The checkout identifier

  • payload (PCPServerSDK::Models::OrderRequest)

    The order request

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb', line 23

def create_order(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}/order")

  request_init = {
    method: 'POST',
    headers: { 'Content-Type' => 'application/json' },
    body: JSON.generate(payload)
  }

  response = make_api_call(url.to_s, request_init)
  deserialize_json(response, PCPServerSDK::Models::OrderResponse)
end

#deliver_order(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::DeliverResponse

Deliver an order

Parameters:

  • merchant_id (String)

    The merchant identifier

  • commerce_case_id (String)

    The commerce case identifier

  • checkout_id (String)

    The checkout identifier

  • payload (PCPServerSDK::Models::DeliverRequest)

    The deliver request

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb', line 44

def deliver_order(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}/deliver")

  request_init = {
    method: 'POST',
    headers: { 'Content-Type' => 'application/json' },
    body: JSON.generate(payload)
  }

  response = make_api_call(url.to_s, request_init)
  deserialize_json(response, PCPServerSDK::Models::DeliverResponse)
end

#return_order(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::ReturnResponse

Return an order

Parameters:

  • merchant_id (String)

    The merchant identifier

  • commerce_case_id (String)

    The commerce case identifier

  • checkout_id (String)

    The checkout identifier

  • payload (PCPServerSDK::Models::ReturnRequest)

    The return request

Returns:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb', line 65

def return_order(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}/return")

  request_init = {
    method: 'POST',
    headers: { 'Content-Type' => 'application/json' },
    body: JSON.generate(payload)
  }

  response = make_api_call(url.to_s, request_init)
  deserialize_json(response, PCPServerSDK::Models::ReturnResponse)
end