square.rb 6.3.0.20200826 → 17.1.0.20220120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +86 -51
  4. data/lib/square/api/apple_pay_api.rb +12 -9
  5. data/lib/square/api/bank_accounts_api.rb +21 -24
  6. data/lib/square/api/base_api.rb +20 -9
  7. data/lib/square/api/bookings_api.rb +391 -0
  8. data/lib/square/api/cards_api.rb +170 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +195 -85
  11. data/lib/square/api/checkout_api.rb +7 -5
  12. data/lib/square/api/customer_groups_api.rb +34 -16
  13. data/lib/square/api/customer_segments_api.rb +21 -9
  14. data/lib/square/api/customers_api.rb +102 -55
  15. data/lib/square/api/devices_api.rb +20 -8
  16. data/lib/square/api/disputes_api.rb +156 -144
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/gift_card_activities_api.rb +133 -0
  19. data/lib/square/api/gift_cards_api.rb +297 -0
  20. data/lib/square/api/inventory_api.rb +290 -37
  21. data/lib/square/api/invoices_api.rb +61 -57
  22. data/lib/square/api/labor_api.rb +127 -93
  23. data/lib/square/api/locations_api.rb +36 -25
  24. data/lib/square/api/loyalty_api.rb +134 -87
  25. data/lib/square/api/merchants_api.rb +8 -4
  26. data/lib/square/api/mobile_authorization_api.rb +9 -7
  27. data/lib/square/api/o_auth_api.rb +41 -32
  28. data/lib/square/api/orders_api.rb +132 -54
  29. data/lib/square/api/payments_api.rb +133 -75
  30. data/lib/square/api/refunds_api.rb +51 -30
  31. data/lib/square/api/sites_api.rb +43 -0
  32. data/lib/square/api/snippets_api.rb +146 -0
  33. data/lib/square/api/subscriptions_api.rb +216 -26
  34. data/lib/square/api/team_api.rb +81 -65
  35. data/lib/square/api/terminal_api.rb +166 -16
  36. data/lib/square/api/transactions_api.rb +32 -194
  37. data/lib/square/api/v1_transactions_api.rb +53 -103
  38. data/lib/square/api_helper.rb +38 -43
  39. data/lib/square/client.rb +54 -24
  40. data/lib/square/configuration.rb +61 -21
  41. data/lib/square/http/api_response.rb +3 -1
  42. data/lib/square/http/faraday_client.rb +34 -5
  43. data/lib/square/utilities/date_time_helper.rb +151 -0
  44. data/lib/square/utilities/file_wrapper.rb +1 -2
  45. data/lib/square.rb +65 -61
  46. data/spec/user_journey_spec.rb +2 -5
  47. data/test/api/api_test_base.rb +1 -6
  48. data/test/api/test_catalog_api.rb +1 -4
  49. data/test/api/test_customers_api.rb +1 -4
  50. data/test/api/test_employees_api.rb +1 -4
  51. data/test/api/test_labor_api.rb +2 -6
  52. data/test/api/test_locations_api.rb +21 -35
  53. data/test/api/test_merchants_api.rb +1 -4
  54. data/test/api/test_payments_api.rb +3 -6
  55. data/test/api/test_refunds_api.rb +3 -6
  56. data/test/http_response_catcher.rb +0 -5
  57. data/test/test_helper.rb +1 -6
  58. metadata +40 -18
  59. data/lib/square/api/v1_employees_api.rb +0 -723
  60. data/lib/square/api/v1_items_api.rb +0 -1686
  61. data/lib/square/api/v1_locations_api.rb +0 -65
@@ -7,16 +7,16 @@ module Square
7
7
 
8
8
  # `RenewToken` is deprecated. For information about refreshing OAuth access
9
9
  # tokens, see
10
- # [Renew OAuth
11
- # Token](https://developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-
12
- # tokens).
10
+ # [Migrate from Renew to Refresh OAuth
11
+ # Tokens](https://developer.squareup.com/docs/oauth-api/migrate-to-refresh-t
12
+ # okens).
13
13
  # Renews an OAuth access token before it expires.
14
14
  # OAuth access tokens besides your application's personal access token
15
- # expire after __30 days__.
16
- # You can also renew expired tokens within __15 days__ of their expiration.
15
+ # expire after 30 days.
16
+ # You can also renew expired tokens within 15 days of their expiration.
17
17
  # You cannot renew an access token that has been expired for more than 15
18
18
  # days.
19
- # Instead, the associated user must re-complete the OAuth flow from the
19
+ # Instead, the associated user must recomplete the OAuth flow from the
20
20
  # beginning.
21
21
  # __Important:__ The `Authorization` header for this endpoint must have the
22
22
  # following format:
@@ -25,10 +25,10 @@ module Square
25
25
  # ```
26
26
  # Replace `APPLICATION_SECRET` with the application secret on the
27
27
  # Credentials
28
- # page in the [application dashboard](https://connect.squareup.com/apps).
29
- # @param [String] client_id Required parameter: Your application ID,
30
- # available from the [application
31
- # dashboard](https://connect.squareup.com/apps).
28
+ # page in the [Developer Dashboard](https://developer.squareup.com/apps).
29
+ # @param [String] client_id Required parameter: Your application ID, which
30
+ # is available in the OAuth page in the [Developer
31
+ # Dashboard](https://developer.squareup.com/apps).
32
32
  # @param [RenewTokenRequest] body Required parameter: An object containing
33
33
  # the fields to POST for the request. See the corresponding object
34
34
  # definition for field details.
@@ -44,14 +44,14 @@ module Square
44
44
  _query_builder << '/oauth2/clients/{client_id}/access-token/renew'
45
45
  _query_builder = APIHelper.append_url_with_template_parameters(
46
46
  _query_builder,
47
- 'client_id' => client_id
47
+ 'client_id' => { 'value' => client_id, 'encode' => true }
48
48
  )
49
49
  _query_url = APIHelper.clean_url _query_builder
50
50
 
51
51
  # Prepare headers.
52
52
  _headers = {
53
53
  'accept' => 'application/json',
54
- 'content-type' => 'application/json; charset=utf-8',
54
+ 'Content-Type' => 'application/json',
55
55
  'Authorization' => authorization
56
56
  }
57
57
 
@@ -66,7 +66,9 @@ module Square
66
66
  # Return appropriate response type.
67
67
  decoded = APIHelper.json_deserialize(_response.raw_body)
68
68
  _errors = APIHelper.map_response(decoded, ['errors'])
69
- ApiResponse.new(_response, data: decoded, errors: _errors)
69
+ ApiResponse.new(
70
+ _response, data: decoded, errors: _errors
71
+ )
70
72
  end
71
73
 
72
74
  # Revokes an access token generated with the OAuth flow.
@@ -81,9 +83,8 @@ module Square
81
83
  # ```
82
84
  # Authorization: Client APPLICATION_SECRET
83
85
  # ```
84
- # Replace `APPLICATION_SECRET` with the application secret on the
85
- # Credentials
86
- # page in the [application dashboard](https://connect.squareup.com/apps).
86
+ # Replace `APPLICATION_SECRET` with the application secret on the OAuth
87
+ # page for your application on the Developer Dashboard.
87
88
  # @param [RevokeTokenRequest] body Required parameter: An object containing
88
89
  # the fields to POST for the request. See the corresponding object
89
90
  # definition for field details.
@@ -100,7 +101,7 @@ module Square
100
101
  # Prepare headers.
101
102
  _headers = {
102
103
  'accept' => 'application/json',
103
- 'content-type' => 'application/json; charset=utf-8',
104
+ 'Content-Type' => 'application/json',
104
105
  'Authorization' => authorization
105
106
  }
106
107
 
@@ -115,21 +116,27 @@ module Square
115
116
  # Return appropriate response type.
116
117
  decoded = APIHelper.json_deserialize(_response.raw_body)
117
118
  _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(_response, data: decoded, errors: _errors)
119
+ ApiResponse.new(
120
+ _response, data: decoded, errors: _errors
121
+ )
119
122
  end
120
123
 
121
- # Returns an OAuth access token.
122
- # The endpoint supports distinct methods of obtaining OAuth access tokens.
123
- # Applications specify a method by adding the `grant_type` parameter
124
- # in the request and also provide relevant information.
125
- # For more information, see [OAuth access token
126
- # management](https://developer.squareup.com/docs/authz/oauth/how-it-works#o
127
- # auth-access-token-management).
128
- # __Note:__ Regardless of the method application specified,
129
- # the endpoint always returns two items; an OAuth access token and
130
- # a refresh token in the response.
131
- # __OAuth tokens should only live on secure servers. Application clients
132
- # should never interact directly with OAuth tokens__.
124
+ # Returns an OAuth access token and a refresh token unless the
125
+ # `short_lived` parameter is set to `true`, in which case the endpoint
126
+ # returns only an access token.
127
+ # The `grant_type` parameter specifies the type of OAuth request. If
128
+ # `grant_type` is `authorization_code`, you must include the authorization
129
+ # code you received when a seller granted you authorization. If `grant_type`
130
+ # is `refresh_token`, you must provide a valid refresh token. If you are
131
+ # using
132
+ # an old version of the Square APIs (prior to March 13, 2019), `grant_type`
133
+ # can be `migration_token` and you must provide a valid migration token.
134
+ # You can use the `scopes` parameter to limit the set of permissions granted
135
+ # to the access token and refresh token. You can use the `short_lived`
136
+ # parameter
137
+ # to create an access token that expires in 24 hours.
138
+ # __Note:__ OAuth tokens should be encrypted and stored on a secure server.
139
+ # Application clients should never interact directly with OAuth tokens.
133
140
  # @param [ObtainTokenRequest] body Required parameter: An object containing
134
141
  # the fields to POST for the request. See the corresponding object
135
142
  # definition for field details.
@@ -143,7 +150,7 @@ module Square
143
150
  # Prepare headers.
144
151
  _headers = {
145
152
  'accept' => 'application/json',
146
- 'content-type' => 'application/json; charset=utf-8'
153
+ 'Content-Type' => 'application/json'
147
154
  }
148
155
 
149
156
  # Prepare and execute HttpRequest.
@@ -157,7 +164,9 @@ module Square
157
164
  # Return appropriate response type.
158
165
  decoded = APIHelper.json_deserialize(_response.raw_body)
159
166
  _errors = APIHelper.map_response(decoded, ['errors'])
160
- ApiResponse.new(_response, data: decoded, errors: _errors)
167
+ ApiResponse.new(
168
+ _response, data: decoded, errors: _errors
169
+ )
161
170
  end
162
171
  end
163
172
  end
@@ -5,17 +5,14 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a new [Order](#type-order) which can include information on
8
+ # Creates a new [order]($m/Order) that can include information about
9
9
  # products for
10
10
  # purchase and settings to apply to the purchase.
11
- # To pay for a created order, please refer to the [Pay for
12
- # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
13
- # guide.
14
- # You can modify open orders using the
15
- # [UpdateOrder](#endpoint-orders-updateorder) endpoint.
16
- # To learn more about the Orders API, see the
17
- # [Orders API
18
- # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
11
+ # To pay for a created order, see
12
+ # [Pay for
13
+ # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders).
14
+ # You can modify open orders using the [UpdateOrder]($e/Orders/UpdateOrder)
15
+ # endpoint.
19
16
  # @param [CreateOrderRequest] body Required parameter: An object containing
20
17
  # the fields to POST for the request. See the corresponding object
21
18
  # definition for field details.
@@ -29,7 +26,7 @@ module Square
29
26
  # Prepare headers.
30
27
  _headers = {
31
28
  'accept' => 'application/json',
32
- 'content-type' => 'application/json; charset=utf-8'
29
+ 'Content-Type' => 'application/json'
33
30
  }
34
31
 
35
32
  # Prepare and execute HttpRequest.
@@ -44,11 +41,13 @@ module Square
44
41
  # Return appropriate response type.
45
42
  decoded = APIHelper.json_deserialize(_response.raw_body)
46
43
  _errors = APIHelper.map_response(decoded, ['errors'])
47
- ApiResponse.new(_response, data: decoded, errors: _errors)
44
+ ApiResponse.new(
45
+ _response, data: decoded, errors: _errors
46
+ )
48
47
  end
49
48
 
50
- # Retrieves a set of [Order](#type-order)s by their IDs.
51
- # If a given Order ID does not exist, the ID is ignored instead of
49
+ # Retrieves a set of [orders]($m/Order) by their IDs.
50
+ # If a given order ID does not exist, the ID is ignored instead of
52
51
  # generating an error.
53
52
  # @param [BatchRetrieveOrdersRequest] body Required parameter: An object
54
53
  # containing the fields to POST for the request. See the corresponding
@@ -63,7 +62,7 @@ module Square
63
62
  # Prepare headers.
64
63
  _headers = {
65
64
  'accept' => 'application/json',
66
- 'content-type' => 'application/json; charset=utf-8'
65
+ 'Content-Type' => 'application/json'
67
66
  }
68
67
 
69
68
  # Prepare and execute HttpRequest.
@@ -78,10 +77,12 @@ module Square
78
77
  # Return appropriate response type.
79
78
  decoded = APIHelper.json_deserialize(_response.raw_body)
80
79
  _errors = APIHelper.map_response(decoded, ['errors'])
81
- ApiResponse.new(_response, data: decoded, errors: _errors)
80
+ ApiResponse.new(
81
+ _response, data: decoded, errors: _errors
82
+ )
82
83
  end
83
84
 
84
- # Calculates an [Order](#type-order).
85
+ # Enables applications to preview order pricing without creating an order.
85
86
  # @param [CalculateOrderRequest] body Required parameter: An object
86
87
  # containing the fields to POST for the request. See the corresponding
87
88
  # object definition for field details.
@@ -95,7 +96,7 @@ module Square
95
96
  # Prepare headers.
96
97
  _headers = {
97
98
  'accept' => 'application/json',
98
- 'content-type' => 'application/json; charset=utf-8'
99
+ 'Content-Type' => 'application/json'
99
100
  }
100
101
 
101
102
  # Prepare and execute HttpRequest.
@@ -110,22 +111,62 @@ module Square
110
111
  # Return appropriate response type.
111
112
  decoded = APIHelper.json_deserialize(_response.raw_body)
112
113
  _errors = APIHelper.map_response(decoded, ['errors'])
113
- ApiResponse.new(_response, data: decoded, errors: _errors)
114
+ ApiResponse.new(
115
+ _response, data: decoded, errors: _errors
116
+ )
117
+ end
118
+
119
+ # Creates a new order, in the `DRAFT` state, by duplicating an existing
120
+ # order. The newly created order has
121
+ # only the core fields (such as line items, taxes, and discounts) copied
122
+ # from the original order.
123
+ # @param [CloneOrderRequest] body Required parameter: An object containing
124
+ # the fields to POST for the request. See the corresponding object
125
+ # definition for field details.
126
+ # @return [CloneOrderResponse Hash] response from the API call
127
+ def clone_order(body:)
128
+ # Prepare query url.
129
+ _query_builder = config.get_base_uri
130
+ _query_builder << '/v2/orders/clone'
131
+ _query_url = APIHelper.clean_url _query_builder
132
+
133
+ # Prepare headers.
134
+ _headers = {
135
+ 'accept' => 'application/json',
136
+ 'Content-Type' => 'application/json'
137
+ }
138
+
139
+ # Prepare and execute HttpRequest.
140
+ _request = config.http_client.post(
141
+ _query_url,
142
+ headers: _headers,
143
+ parameters: body.to_json
144
+ )
145
+ OAuth2.apply(config, _request)
146
+ _response = execute_request(_request)
147
+
148
+ # Return appropriate response type.
149
+ decoded = APIHelper.json_deserialize(_response.raw_body)
150
+ _errors = APIHelper.map_response(decoded, ['errors'])
151
+ ApiResponse.new(
152
+ _response, data: decoded, errors: _errors
153
+ )
114
154
  end
115
155
 
116
156
  # Search all orders for one or more locations. Orders include all sales,
117
157
  # returns, and exchanges regardless of how or when they entered the Square
118
- # Ecosystem (e.g. Point of Sale, Invoices, Connect APIs, etc).
119
- # SearchOrders requests need to specify which locations to search and define
120
- # a
121
- # [`SearchOrdersQuery`](#type-searchordersquery) object which controls
122
- # how to sort or filter the results. Your SearchOrdersQuery can:
158
+ # ecosystem (such as Point of Sale, Invoices, and Connect APIs).
159
+ # `SearchOrders` requests need to specify which locations to search and
160
+ # define a
161
+ # [SearchOrdersQuery]($m/SearchOrdersQuery) object that controls
162
+ # how to sort or filter the results. Your `SearchOrdersQuery` can:
123
163
  # Set filter criteria.
124
- # Set sort order.
125
- # Determine whether to return results as complete Order objects, or as
126
- # [OrderEntry](#type-orderentry) objects.
164
+ # Set the sort order.
165
+ # Determine whether to return results as complete `Order` objects or as
166
+ # [OrderEntry]($m/OrderEntry) objects.
127
167
  # Note that details for orders processed with Square Point of Sale while in
128
- # offline mode may not be transmitted to Square for up to 72 hours. Offline
168
+ # offline mode might not be transmitted to Square for up to 72 hours.
169
+ # Offline
129
170
  # orders have a `created_at` value that reflects the time the order was
130
171
  # created,
131
172
  # not the time it was subsequently transmitted to Square.
@@ -142,7 +183,7 @@ module Square
142
183
  # Prepare headers.
143
184
  _headers = {
144
185
  'accept' => 'application/json',
145
- 'content-type' => 'application/json; charset=utf-8'
186
+ 'Content-Type' => 'application/json'
146
187
  }
147
188
 
148
189
  # Prepare and execute HttpRequest.
@@ -157,29 +198,64 @@ module Square
157
198
  # Return appropriate response type.
158
199
  decoded = APIHelper.json_deserialize(_response.raw_body)
159
200
  _errors = APIHelper.map_response(decoded, ['errors'])
160
- ApiResponse.new(_response, data: decoded, errors: _errors)
201
+ ApiResponse.new(
202
+ _response, data: decoded, errors: _errors
203
+ )
204
+ end
205
+
206
+ # Retrieves an [Order]($m/Order) by ID.
207
+ # @param [String] order_id Required parameter: The ID of the order to
208
+ # retrieve.
209
+ # @return [RetrieveOrderResponse Hash] response from the API call
210
+ def retrieve_order(order_id:)
211
+ # Prepare query url.
212
+ _query_builder = config.get_base_uri
213
+ _query_builder << '/v2/orders/{order_id}'
214
+ _query_builder = APIHelper.append_url_with_template_parameters(
215
+ _query_builder,
216
+ 'order_id' => { 'value' => order_id, 'encode' => true }
217
+ )
218
+ _query_url = APIHelper.clean_url _query_builder
219
+
220
+ # Prepare headers.
221
+ _headers = {
222
+ 'accept' => 'application/json'
223
+ }
224
+
225
+ # Prepare and execute HttpRequest.
226
+ _request = config.http_client.get(
227
+ _query_url,
228
+ headers: _headers
229
+ )
230
+ OAuth2.apply(config, _request)
231
+ _response = execute_request(_request)
232
+
233
+ # Return appropriate response type.
234
+ decoded = APIHelper.json_deserialize(_response.raw_body)
235
+ _errors = APIHelper.map_response(decoded, ['errors'])
236
+ ApiResponse.new(
237
+ _response, data: decoded, errors: _errors
238
+ )
161
239
  end
162
240
 
163
- # Updates an open [Order](#type-order) by adding, replacing, or deleting
241
+ # Updates an open [order]($m/Order) by adding, replacing, or deleting
164
242
  # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
165
- # An UpdateOrder request requires the following:
243
+ # An `UpdateOrder` request requires the following:
166
244
  # - The `order_id` in the endpoint path, identifying the order to update.
167
245
  # - The latest `version` of the order to update.
168
246
  # - The [sparse
169
247
  # order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
170
248
  # -order-objects)
171
- # containing only the fields to update and the version the update is
172
- # being applied to.
249
+ # containing only the fields to update and the version to which the update
250
+ # is
251
+ # being applied.
173
252
  # - If deleting fields, the [dot notation
174
253
  # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
175
254
  # -notation)
176
- # identifying fields to clear.
177
- # To pay for an order, please refer to the [Pay for
178
- # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
179
- # guide.
180
- # To learn more about the Orders API, see the
181
- # [Orders API
182
- # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
255
+ # identifying the fields to clear.
256
+ # To pay for an order, see
257
+ # [Pay for
258
+ # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders).
183
259
  # @param [String] order_id Required parameter: The ID of the order to
184
260
  # update.
185
261
  # @param [UpdateOrderRequest] body Required parameter: An object containing
@@ -193,14 +269,14 @@ module Square
193
269
  _query_builder << '/v2/orders/{order_id}'
194
270
  _query_builder = APIHelper.append_url_with_template_parameters(
195
271
  _query_builder,
196
- 'order_id' => order_id
272
+ 'order_id' => { 'value' => order_id, 'encode' => true }
197
273
  )
198
274
  _query_url = APIHelper.clean_url _query_builder
199
275
 
200
276
  # Prepare headers.
201
277
  _headers = {
202
278
  'accept' => 'application/json',
203
- 'content-type' => 'application/json; charset=utf-8'
279
+ 'Content-Type' => 'application/json'
204
280
  }
205
281
 
206
282
  # Prepare and execute HttpRequest.
@@ -215,30 +291,30 @@ module Square
215
291
  # Return appropriate response type.
216
292
  decoded = APIHelper.json_deserialize(_response.raw_body)
217
293
  _errors = APIHelper.map_response(decoded, ['errors'])
218
- ApiResponse.new(_response, data: decoded, errors: _errors)
294
+ ApiResponse.new(
295
+ _response, data: decoded, errors: _errors
296
+ )
219
297
  end
220
298
 
221
- # Pay for an [order](#type-order) using one or more approved
222
- # [payments](#type-payment),
299
+ # Pay for an [order]($m/Order) using one or more approved
300
+ # [payments]($m/Payment)
223
301
  # or settle an order with a total of `0`.
224
302
  # The total of the `payment_ids` listed in the request must be equal to the
225
303
  # order
226
304
  # total. Orders with a total amount of `0` can be marked as paid by
227
305
  # specifying an empty
228
306
  # array of `payment_ids` in the request.
229
- # To be used with PayOrder, a payment must:
307
+ # To be used with `PayOrder`, a payment must:
230
308
  # - Reference the order by specifying the `order_id` when [creating the
231
- # payment](#endpoint-payments-createpayment).
309
+ # payment]($e/Payments/CreatePayment).
232
310
  # Any approved payments that reference the same `order_id` not specified in
233
311
  # the
234
- # `payment_ids` will be canceled.
312
+ # `payment_ids` is canceled.
235
313
  # - Be approved with [delayed
236
314
  # capture](https://developer.squareup.com/docs/payments-api/take-payments#de
237
315
  # layed-capture).
238
- # Using a delayed capture payment with PayOrder will complete the approved
316
+ # Using a delayed capture payment with `PayOrder` completes the approved
239
317
  # payment.
240
- # Learn how to [pay for orders with a single payment using the Payments
241
- # API](https://developer.squareup.com/docs/orders-api/pay-for-orders).
242
318
  # @param [String] order_id Required parameter: The ID of the order being
243
319
  # paid.
244
320
  # @param [PayOrderRequest] body Required parameter: An object containing the
@@ -252,14 +328,14 @@ module Square
252
328
  _query_builder << '/v2/orders/{order_id}/pay'
253
329
  _query_builder = APIHelper.append_url_with_template_parameters(
254
330
  _query_builder,
255
- 'order_id' => order_id
331
+ 'order_id' => { 'value' => order_id, 'encode' => true }
256
332
  )
257
333
  _query_url = APIHelper.clean_url _query_builder
258
334
 
259
335
  # Prepare headers.
260
336
  _headers = {
261
337
  'accept' => 'application/json',
262
- 'content-type' => 'application/json; charset=utf-8'
338
+ 'Content-Type' => 'application/json'
263
339
  }
264
340
 
265
341
  # Prepare and execute HttpRequest.
@@ -274,7 +350,9 @@ module Square
274
350
  # Return appropriate response type.
275
351
  decoded = APIHelper.json_deserialize(_response.raw_body)
276
352
  _errors = APIHelper.map_response(decoded, ['errors'])
277
- ApiResponse.new(_response, data: decoded, errors: _errors)
353
+ ApiResponse.new(
354
+ _response, data: decoded, errors: _errors
355
+ )
278
356
  end
279
357
  end
280
358
  end