Module: WolfCore::Integrations::OrdersApiOperations
- Includes:
- HttpOperations
- Defined in:
- lib/wolf_core/application/integrations/orders_api_operations.rb
Instance Method Summary
collapse
-
#create_order(wolf_token:, order:, tenant:, wolf_platform_url:) ⇒ Object
-
#create_order!(wolf_token:, order:, tenant:, wolf_platform_url:, error_message:) ⇒ Object
-
#fetch_order(wolf_token:, order_id:, tenant:, wolf_platform_url:) ⇒ Object
-
#fetch_order!(wolf_token:, order_id:, tenant:, wolf_platform_url:, error_message:) ⇒ Object
#async_http_get, #async_http_post, #async_http_put, #http_get, #http_post, #http_put, #parse_http_response, #parsed_http_get, #parsed_http_post, #parsed_http_put, #safe_http_get, #safe_http_post, #safe_http_put, #validate_http_response
#log_object
Methods included from AsyncUtils
#run_async
#raise_service_error
Instance Method Details
#create_order(wolf_token:, order:, tenant:, wolf_platform_url:) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 38
def create_order(wolf_token:, order:, tenant:, wolf_platform_url:)
http_post(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/orders",
query: { tenant: tenant },
body: order
)
end
|
#create_order!(wolf_token:, order:, tenant:, wolf_platform_url:, error_message:) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 28
def create_order!(wolf_token:, order:, tenant:, wolf_platform_url:, error_message:)
safe_http_post(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/orders",
query: { tenant: tenant },
body: order,
error_message: error_message,
)
end
|
#fetch_order(wolf_token:, order_id:, tenant:, wolf_platform_url:) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 17
def fetch_order(wolf_token:, order_id:, tenant:, wolf_platform_url:)
response = http_get(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/orders/#{order_id}",
query: { tenant: tenant },
)
response_body = response.body
return unless response_body.instance_of?(Hash)
response_body.dig('data', 'table', 'order')
end
|
#fetch_order!(wolf_token:, order_id:, tenant:, wolf_platform_url:, error_message:) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 6
def fetch_order!(wolf_token:, order_id:, tenant:, wolf_platform_url:, error_message:)
response = safe_http_get(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/orders/#{order_id}",
query: { tenant: tenant },
error_message: error_message,
)
response_body = response.body
response_body.dig('data', 'table', 'order')
end
|