Module: WolfCore::Integrations::OrdersApiOperations
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
-
#fetch_orders(wolf_token:, tenant:, query:, wolf_platform_url:) ⇒ Object
-
#fetch_orders!(wolf_token:, tenant:, query:, wolf_platform_url:, error_message:, error_data: nil) ⇒ Object
#async_http_get, #async_http_patch, #async_http_post, #async_http_put, #http_get, #http_patch, #http_post, #http_put, #parse_http_response, #parsed_http_get, #parsed_http_patch, #parsed_http_post, #parsed_http_put, #response_success?, #safe_http_get, #safe_http_patch, #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
55
56
57
58
59
60
61
62
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 55
def create_order(wolf_token:, order:, tenant:, wolf_platform_url:)
parsed_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
45
46
47
48
49
50
51
52
53
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 45
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
37
38
39
40
41
42
43
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 37
def fetch_order(wolf_token:, order_id:, tenant:, wolf_platform_url:)
parsed_http_get(
headers: { "Authorization" => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/orders/#{order_id}",
query: { tenant: tenant }
)
end
|
#fetch_order!(wolf_token:, order_id:, tenant:, wolf_platform_url:, error_message:) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 26
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
|
#fetch_orders(wolf_token:, tenant:, query:, wolf_platform_url:) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 16
def fetch_orders(wolf_token:, tenant:, query:, wolf_platform_url:)
query ||= {}
query = query.merge({ tenant: tenant })
parsed_http_get(
headers: { 'Authorization' => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/orders",
query: query,
)
end
|
#fetch_orders!(wolf_token:, tenant:, query:, wolf_platform_url:, error_message:, error_data: nil) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/wolf_core/application/integrations/orders_api_operations.rb', line 6
def fetch_orders!(wolf_token:, tenant:, query:, wolf_platform_url:, error_message:, error_data: nil)
response = fetch_orders(
wolf_token: wolf_token, tenant: tenant, query: query,
wolf_platform_url: wolf_platform_url,
)
validate_http_response(response: response, message: error_message, error_data: error_data)
response_body = response.body
response_body.dig("data", "table")
end
|