square.rb 3.20190814.0 → 3.20190925.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/square.rb +53 -52
- data/lib/square/api/apple_pay_api.rb +55 -55
- data/lib/square/api/base_api.rb +48 -45
- data/lib/square/api/catalog_api.rb +461 -461
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -335
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -300
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +117 -45
- data/lib/square/api/merchants_api.rb +46 -0
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -168
- data/lib/square/api/orders_api.rb +271 -269
- data/lib/square/api/payments_api.rb +282 -282
- data/lib/square/api/refunds_api.rb +149 -149
- data/lib/square/api/reporting_api.rb +145 -143
- data/lib/square/api/transactions_api.rb +379 -379
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -281
- data/lib/square/client.rb +155 -139
- data/lib/square/configuration.rb +98 -88
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/test/api/test_labor_api.rb +74 -0
- metadata +4 -3
- data/lib/square/api/v1_locations_api.rbe +0 -67
@@ -1,269 +1,271 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# OrdersApi
|
8
|
-
class OrdersApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Creates a new [Order](#type-order) which can include information on
|
14
|
-
# products for
|
15
|
-
# purchase and settings to apply to the purchase.
|
16
|
-
# To pay for a created order, please refer to the [Pay for
|
17
|
-
# Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
|
18
|
-
# guide.
|
19
|
-
# You can modify open orders using the
|
20
|
-
# [UpdateOrder](#endpoint-orders-updateorder) endpoint.
|
21
|
-
# To learn more about the Orders API, see the
|
22
|
-
# [Orders API
|
23
|
-
# Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
|
24
|
-
# @param [String] location_id Required parameter: The ID of the business
|
25
|
-
# location to associate the order with.
|
26
|
-
# @param [CreateOrderRequest] body Required parameter: An object containing
|
27
|
-
# the fields to POST for the request. See the corresponding object
|
28
|
-
# definition for field details.
|
29
|
-
# @return [CreateOrderResponse Hash] response from the API call
|
30
|
-
def create_order(location_id:,
|
31
|
-
body:)
|
32
|
-
# Prepare query url.
|
33
|
-
_query_builder = config.get_base_uri
|
34
|
-
_query_builder << '/v2/locations/{location_id}/orders'
|
35
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
36
|
-
_query_builder,
|
37
|
-
'location_id' => location_id
|
38
|
-
)
|
39
|
-
_query_url = APIHelper.clean_url _query_builder
|
40
|
-
|
41
|
-
# Prepare headers.
|
42
|
-
_headers = {
|
43
|
-
'accept' => 'application/json',
|
44
|
-
'content-type' => 'application/json; charset=utf-8'
|
45
|
-
}
|
46
|
-
|
47
|
-
# Prepare and execute HttpRequest.
|
48
|
-
_request = config.http_client.post(
|
49
|
-
_query_url,
|
50
|
-
headers: _headers,
|
51
|
-
parameters: body.to_json
|
52
|
-
)
|
53
|
-
OAuth2.apply(config, _request)
|
54
|
-
_response = execute_request(_request)
|
55
|
-
|
56
|
-
# Return appropriate response type.
|
57
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
58
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
59
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Retrieves a set of [Order](#type-order)s by their IDs.
|
63
|
-
# If a given Order ID does not exist, the ID is ignored instead of
|
64
|
-
# generating an error.
|
65
|
-
# @param [String] location_id Required parameter: The ID of the orders'
|
66
|
-
# associated location.
|
67
|
-
# @param [BatchRetrieveOrdersRequest] body Required parameter: An object
|
68
|
-
# containing the fields to POST for the request. See the corresponding
|
69
|
-
# object definition for field details.
|
70
|
-
# @return [BatchRetrieveOrdersResponse Hash] response from the API call
|
71
|
-
def batch_retrieve_orders(location_id:,
|
72
|
-
body:)
|
73
|
-
# Prepare query url.
|
74
|
-
_query_builder = config.get_base_uri
|
75
|
-
_query_builder << '/v2/locations/{location_id}/orders/batch-retrieve'
|
76
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
77
|
-
_query_builder,
|
78
|
-
'location_id' => location_id
|
79
|
-
)
|
80
|
-
_query_url = APIHelper.clean_url _query_builder
|
81
|
-
|
82
|
-
# Prepare headers.
|
83
|
-
_headers = {
|
84
|
-
'accept' => 'application/json',
|
85
|
-
'content-type' => 'application/json; charset=utf-8'
|
86
|
-
}
|
87
|
-
|
88
|
-
# Prepare and execute HttpRequest.
|
89
|
-
_request = config.http_client.post(
|
90
|
-
_query_url,
|
91
|
-
headers: _headers,
|
92
|
-
parameters: body.to_json
|
93
|
-
)
|
94
|
-
OAuth2.apply(config, _request)
|
95
|
-
_response = execute_request(_request)
|
96
|
-
|
97
|
-
# Return appropriate response type.
|
98
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
99
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
100
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
101
|
-
end
|
102
|
-
|
103
|
-
# Updates an open [Order](#type-order) by adding, replacing, or deleting
|
104
|
-
# fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
|
105
|
-
# An UpdateOrder request requires the following:
|
106
|
-
# - The `order_id` in the endpoint path, identifying the order to update.
|
107
|
-
# - The latest `version` of the order to update.
|
108
|
-
# - The [sparse
|
109
|
-
# order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
|
110
|
-
# -order-objects)
|
111
|
-
# containing only the fields to update and the version the update is
|
112
|
-
# being applied to.
|
113
|
-
# - If deleting fields, the [dot notation
|
114
|
-
# paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
|
115
|
-
# -notation)
|
116
|
-
# identifying fields to clear.
|
117
|
-
# To pay for an order, please refer to the [Pay for
|
118
|
-
# Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
|
119
|
-
# guide.
|
120
|
-
# To learn more about the Orders API, see the
|
121
|
-
# [Orders API
|
122
|
-
# Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
|
123
|
-
# @param [
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
# @param [
|
128
|
-
#
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
_query_builder =
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
# the
|
181
|
-
#
|
182
|
-
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
#
|
213
|
-
#
|
214
|
-
# order
|
215
|
-
# total
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
# payment
|
221
|
-
#
|
222
|
-
#
|
223
|
-
# `
|
224
|
-
#
|
225
|
-
#
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
# @param [
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
_query_builder =
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# OrdersApi
|
8
|
+
class OrdersApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Creates a new [Order](#type-order) which can include information on
|
14
|
+
# products for
|
15
|
+
# purchase and settings to apply to the purchase.
|
16
|
+
# To pay for a created order, please refer to the [Pay for
|
17
|
+
# Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
|
18
|
+
# guide.
|
19
|
+
# You can modify open orders using the
|
20
|
+
# [UpdateOrder](#endpoint-orders-updateorder) endpoint.
|
21
|
+
# To learn more about the Orders API, see the
|
22
|
+
# [Orders API
|
23
|
+
# Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
|
24
|
+
# @param [String] location_id Required parameter: The ID of the business
|
25
|
+
# location to associate the order with.
|
26
|
+
# @param [CreateOrderRequest] body Required parameter: An object containing
|
27
|
+
# the fields to POST for the request. See the corresponding object
|
28
|
+
# definition for field details.
|
29
|
+
# @return [CreateOrderResponse Hash] response from the API call
|
30
|
+
def create_order(location_id:,
|
31
|
+
body:)
|
32
|
+
# Prepare query url.
|
33
|
+
_query_builder = config.get_base_uri
|
34
|
+
_query_builder << '/v2/locations/{location_id}/orders'
|
35
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
36
|
+
_query_builder,
|
37
|
+
'location_id' => location_id
|
38
|
+
)
|
39
|
+
_query_url = APIHelper.clean_url _query_builder
|
40
|
+
|
41
|
+
# Prepare headers.
|
42
|
+
_headers = {
|
43
|
+
'accept' => 'application/json',
|
44
|
+
'content-type' => 'application/json; charset=utf-8'
|
45
|
+
}
|
46
|
+
|
47
|
+
# Prepare and execute HttpRequest.
|
48
|
+
_request = config.http_client.post(
|
49
|
+
_query_url,
|
50
|
+
headers: _headers,
|
51
|
+
parameters: body.to_json
|
52
|
+
)
|
53
|
+
OAuth2.apply(config, _request)
|
54
|
+
_response = execute_request(_request)
|
55
|
+
|
56
|
+
# Return appropriate response type.
|
57
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
58
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
59
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Retrieves a set of [Order](#type-order)s by their IDs.
|
63
|
+
# If a given Order ID does not exist, the ID is ignored instead of
|
64
|
+
# generating an error.
|
65
|
+
# @param [String] location_id Required parameter: The ID of the orders'
|
66
|
+
# associated location.
|
67
|
+
# @param [BatchRetrieveOrdersRequest] body Required parameter: An object
|
68
|
+
# containing the fields to POST for the request. See the corresponding
|
69
|
+
# object definition for field details.
|
70
|
+
# @return [BatchRetrieveOrdersResponse Hash] response from the API call
|
71
|
+
def batch_retrieve_orders(location_id:,
|
72
|
+
body:)
|
73
|
+
# Prepare query url.
|
74
|
+
_query_builder = config.get_base_uri
|
75
|
+
_query_builder << '/v2/locations/{location_id}/orders/batch-retrieve'
|
76
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
77
|
+
_query_builder,
|
78
|
+
'location_id' => location_id
|
79
|
+
)
|
80
|
+
_query_url = APIHelper.clean_url _query_builder
|
81
|
+
|
82
|
+
# Prepare headers.
|
83
|
+
_headers = {
|
84
|
+
'accept' => 'application/json',
|
85
|
+
'content-type' => 'application/json; charset=utf-8'
|
86
|
+
}
|
87
|
+
|
88
|
+
# Prepare and execute HttpRequest.
|
89
|
+
_request = config.http_client.post(
|
90
|
+
_query_url,
|
91
|
+
headers: _headers,
|
92
|
+
parameters: body.to_json
|
93
|
+
)
|
94
|
+
OAuth2.apply(config, _request)
|
95
|
+
_response = execute_request(_request)
|
96
|
+
|
97
|
+
# Return appropriate response type.
|
98
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
99
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
100
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Updates an open [Order](#type-order) by adding, replacing, or deleting
|
104
|
+
# fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
|
105
|
+
# An UpdateOrder request requires the following:
|
106
|
+
# - The `order_id` in the endpoint path, identifying the order to update.
|
107
|
+
# - The latest `version` of the order to update.
|
108
|
+
# - The [sparse
|
109
|
+
# order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
|
110
|
+
# -order-objects)
|
111
|
+
# containing only the fields to update and the version the update is
|
112
|
+
# being applied to.
|
113
|
+
# - If deleting fields, the [dot notation
|
114
|
+
# paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
|
115
|
+
# -notation)
|
116
|
+
# identifying fields to clear.
|
117
|
+
# To pay for an order, please refer to the [Pay for
|
118
|
+
# Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
|
119
|
+
# guide.
|
120
|
+
# To learn more about the Orders API, see the
|
121
|
+
# [Orders API
|
122
|
+
# Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
|
123
|
+
# @param [String] location_id Required parameter: The ID of the order's
|
124
|
+
# associated location.
|
125
|
+
# @param [String] order_id Required parameter: The ID of the order to
|
126
|
+
# update.
|
127
|
+
# @param [UpdateOrderRequest] body Required parameter: An object containing
|
128
|
+
# the fields to POST for the request. See the corresponding object
|
129
|
+
# definition for field details.
|
130
|
+
# @return [UpdateOrderResponse Hash] response from the API call
|
131
|
+
def update_order(location_id:,
|
132
|
+
order_id:,
|
133
|
+
body:)
|
134
|
+
# Prepare query url.
|
135
|
+
_query_builder = config.get_base_uri
|
136
|
+
_query_builder << '/v2/locations/{location_id}/orders/{order_id}'
|
137
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
138
|
+
_query_builder,
|
139
|
+
'location_id' => location_id,
|
140
|
+
'order_id' => order_id
|
141
|
+
)
|
142
|
+
_query_url = APIHelper.clean_url _query_builder
|
143
|
+
|
144
|
+
# Prepare headers.
|
145
|
+
_headers = {
|
146
|
+
'accept' => 'application/json',
|
147
|
+
'content-type' => 'application/json; charset=utf-8'
|
148
|
+
}
|
149
|
+
|
150
|
+
# Prepare and execute HttpRequest.
|
151
|
+
_request = config.http_client.put(
|
152
|
+
_query_url,
|
153
|
+
headers: _headers,
|
154
|
+
parameters: body.to_json
|
155
|
+
)
|
156
|
+
OAuth2.apply(config, _request)
|
157
|
+
_response = execute_request(_request)
|
158
|
+
|
159
|
+
# Return appropriate response type.
|
160
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
161
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
162
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Search all orders for one or more locations. Orders include all sales,
|
166
|
+
# returns, and exchanges regardless of how or when they entered the Square
|
167
|
+
# Ecosystem (e.g. Point of Sale, Invoices, Connect APIs, etc).
|
168
|
+
# SearchOrders requests need to specify which locations to search and define
|
169
|
+
# a
|
170
|
+
# [`SearchOrdersQuery`](#type-searchordersquery) object which controls
|
171
|
+
# how to sort or filter the results. Your SearchOrdersQuery can:
|
172
|
+
# Set filter criteria.
|
173
|
+
# Set sort order.
|
174
|
+
# Determine whether to return results as complete Order objects, or as
|
175
|
+
# [OrderEntry](#type-orderentry) objects.
|
176
|
+
# Note that details for orders processed with Square Point of Sale while in
|
177
|
+
# offline mode may not be transmitted to Square for up to 72 hours. Offline
|
178
|
+
# orders have a `created_at` value that reflects the time the order was
|
179
|
+
# created,
|
180
|
+
# not the time it was subsequently transmitted to Square.
|
181
|
+
# @param [SearchOrdersRequest] body Required parameter: An object containing
|
182
|
+
# the fields to POST for the request. See the corresponding object
|
183
|
+
# definition for field details.
|
184
|
+
# @return [SearchOrdersResponse Hash] response from the API call
|
185
|
+
def search_orders(body:)
|
186
|
+
# Prepare query url.
|
187
|
+
_query_builder = config.get_base_uri
|
188
|
+
_query_builder << '/v2/orders/search'
|
189
|
+
_query_url = APIHelper.clean_url _query_builder
|
190
|
+
|
191
|
+
# Prepare headers.
|
192
|
+
_headers = {
|
193
|
+
'accept' => 'application/json',
|
194
|
+
'content-type' => 'application/json; charset=utf-8'
|
195
|
+
}
|
196
|
+
|
197
|
+
# Prepare and execute HttpRequest.
|
198
|
+
_request = config.http_client.post(
|
199
|
+
_query_url,
|
200
|
+
headers: _headers,
|
201
|
+
parameters: body.to_json
|
202
|
+
)
|
203
|
+
OAuth2.apply(config, _request)
|
204
|
+
_response = execute_request(_request)
|
205
|
+
|
206
|
+
# Return appropriate response type.
|
207
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
208
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
209
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Pay for an [order](#type-order) using one or more approved
|
213
|
+
# [payments](#type-payment),
|
214
|
+
# or settle an order with a total of `0`.
|
215
|
+
# The total of the `payment_ids` listed in the request must be equal to the
|
216
|
+
# order
|
217
|
+
# total. Orders with a total amount of `0` can be marked as paid by
|
218
|
+
# specifying an empty
|
219
|
+
# array of `payment_ids` in the request.
|
220
|
+
# To be used with PayOrder, a payment must:
|
221
|
+
# - Reference the order by specifying the `order_id` when [creating the
|
222
|
+
# payment](#endpoint-payments-createpayment).
|
223
|
+
# Any approved payments that reference the same `order_id` not specified in
|
224
|
+
# the
|
225
|
+
# `payment_ids` will be canceled.
|
226
|
+
# - Be approved with [delayed
|
227
|
+
# capture](https://developer.squareup.com/docs/payments-api/take-payments#de
|
228
|
+
# layed-capture).
|
229
|
+
# Using a delayed capture payment with PayOrder will complete the approved
|
230
|
+
# payment.
|
231
|
+
# Learn how to [pay for orders with a single payment using the Payments
|
232
|
+
# API](https://developer.squareup.com/docs/orders-api/pay-for-orders).
|
233
|
+
# @param [String] order_id Required parameter: The ID of the order being
|
234
|
+
# paid.
|
235
|
+
# @param [PayOrderRequest] body Required parameter: An object containing the
|
236
|
+
# fields to POST for the request. See the corresponding object definition
|
237
|
+
# for field details.
|
238
|
+
# @return [PayOrderResponse Hash] response from the API call
|
239
|
+
def pay_order(order_id:,
|
240
|
+
body:)
|
241
|
+
# Prepare query url.
|
242
|
+
_query_builder = config.get_base_uri
|
243
|
+
_query_builder << '/v2/orders/{order_id}/pay'
|
244
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
245
|
+
_query_builder,
|
246
|
+
'order_id' => order_id
|
247
|
+
)
|
248
|
+
_query_url = APIHelper.clean_url _query_builder
|
249
|
+
|
250
|
+
# Prepare headers.
|
251
|
+
_headers = {
|
252
|
+
'accept' => 'application/json',
|
253
|
+
'content-type' => 'application/json; charset=utf-8'
|
254
|
+
}
|
255
|
+
|
256
|
+
# Prepare and execute HttpRequest.
|
257
|
+
_request = config.http_client.post(
|
258
|
+
_query_url,
|
259
|
+
headers: _headers,
|
260
|
+
parameters: body.to_json
|
261
|
+
)
|
262
|
+
OAuth2.apply(config, _request)
|
263
|
+
_response = execute_request(_request)
|
264
|
+
|
265
|
+
# Return appropriate response type.
|
266
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
267
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
268
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|