square.rb 6.0.0.20200625 → 6.5.0.20201028

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -30
  3. data/lib/square.rb +61 -60
  4. data/lib/square/api/apple_pay_api.rb +3 -1
  5. data/lib/square/api/bank_accounts_api.rb +12 -15
  6. data/lib/square/api/base_api.rb +2 -2
  7. data/lib/square/api/cash_drawers_api.rb +11 -5
  8. data/lib/square/api/catalog_api.rb +119 -49
  9. data/lib/square/api/checkout_api.rb +4 -2
  10. data/lib/square/api/customer_groups_api.rb +18 -8
  11. data/lib/square/api/customer_segments_api.rb +7 -3
  12. data/lib/square/api/customers_api.rb +47 -27
  13. data/lib/square/api/devices_api.rb +17 -6
  14. data/lib/square/api/disputes_api.rb +39 -34
  15. data/lib/square/api/employees_api.rb +10 -5
  16. data/lib/square/api/inventory_api.rb +30 -15
  17. data/lib/square/api/invoices_api.rb +359 -0
  18. data/lib/square/api/labor_api.rb +131 -22
  19. data/lib/square/api/locations_api.rb +20 -12
  20. data/lib/square/api/loyalty_api.rb +59 -65
  21. data/lib/square/api/merchants_api.rb +9 -4
  22. data/lib/square/api/mobile_authorization_api.rb +3 -1
  23. data/lib/square/api/o_auth_api.rb +10 -4
  24. data/lib/square/api/orders_api.rb +111 -90
  25. data/lib/square/api/payments_api.rb +75 -65
  26. data/lib/square/api/refunds_api.rb +21 -11
  27. data/lib/square/api/subscriptions_api.rb +263 -0
  28. data/lib/square/api/team_api.rb +32 -16
  29. data/lib/square/api/terminal_api.rb +156 -7
  30. data/lib/square/api/transactions_api.rb +32 -18
  31. data/lib/square/api/v1_employees_api.rb +59 -27
  32. data/lib/square/api/v1_items_api.rb +195 -115
  33. data/lib/square/api/v1_locations_api.rb +6 -2
  34. data/lib/square/api/v1_transactions_api.rb +49 -27
  35. data/lib/square/api_helper.rb +14 -9
  36. data/lib/square/client.rb +23 -16
  37. data/lib/square/configuration.rb +12 -4
  38. data/lib/square/http/api_response.rb +2 -0
  39. data/lib/square/http/faraday_client.rb +1 -0
  40. data/spec/user_journey_spec.rb +2 -5
  41. data/test/api/api_test_base.rb +1 -6
  42. data/test/api/test_catalog_api.rb +1 -4
  43. data/test/api/test_customers_api.rb +1 -4
  44. data/test/api/test_employees_api.rb +1 -4
  45. data/test/api/test_labor_api.rb +2 -6
  46. data/test/api/test_locations_api.rb +22 -33
  47. data/test/api/test_merchants_api.rb +1 -4
  48. data/test/api/test_payments_api.rb +3 -6
  49. data/test/api/test_refunds_api.rb +3 -6
  50. data/test/http_response_catcher.rb +0 -5
  51. data/test/test_helper.rb +0 -5
  52. metadata +33 -14
  53. data/lib/square/api/reporting_api.rb +0 -138
@@ -43,12 +43,15 @@ module Square
43
43
  # Return appropriate response type.
44
44
  decoded = APIHelper.json_deserialize(_response.raw_body)
45
45
  _errors = APIHelper.map_response(decoded, ['errors'])
46
- ApiResponse.new(_response, data: decoded, errors: _errors)
46
+ ApiResponse.new(
47
+ _response, data: decoded, errors: _errors
48
+ )
47
49
  end
48
50
 
49
51
  # Retrieve a `Merchant` object for the given `merchant_id`.
50
52
  # @param [String] merchant_id Required parameter: The ID of the merchant to
51
- # retrieve.
53
+ # retrieve. If the string "me" is supplied as the ID, then retrieve the
54
+ # merchant that is currently accessible to this call.
52
55
  # @return [RetrieveMerchantResponse Hash] response from the API call
53
56
  def retrieve_merchant(merchant_id:)
54
57
  # Prepare query url.
@@ -56,7 +59,7 @@ module Square
56
59
  _query_builder << '/v2/merchants/{merchant_id}'
57
60
  _query_builder = APIHelper.append_url_with_template_parameters(
58
61
  _query_builder,
59
- 'merchant_id' => merchant_id
62
+ 'merchant_id' => { 'value' => merchant_id, 'encode' => true }
60
63
  )
61
64
  _query_url = APIHelper.clean_url _query_builder
62
65
 
@@ -76,7 +79,9 @@ module Square
76
79
  # Return appropriate response type.
77
80
  decoded = APIHelper.json_deserialize(_response.raw_body)
78
81
  _errors = APIHelper.map_response(decoded, ['errors'])
79
- ApiResponse.new(_response, data: decoded, errors: _errors)
82
+ ApiResponse.new(
83
+ _response, data: decoded, errors: _errors
84
+ )
80
85
  end
81
86
  end
82
87
  end
@@ -46,7 +46,9 @@ module Square
46
46
  # Return appropriate response type.
47
47
  decoded = APIHelper.json_deserialize(_response.raw_body)
48
48
  _errors = APIHelper.map_response(decoded, ['errors'])
49
- ApiResponse.new(_response, data: decoded, errors: _errors)
49
+ ApiResponse.new(
50
+ _response, data: decoded, errors: _errors
51
+ )
50
52
  end
51
53
  end
52
54
  end
@@ -44,7 +44,7 @@ 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
 
@@ -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.
@@ -115,7 +117,9 @@ module Square
115
117
  # Return appropriate response type.
116
118
  decoded = APIHelper.json_deserialize(_response.raw_body)
117
119
  _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(_response, data: decoded, errors: _errors)
120
+ ApiResponse.new(
121
+ _response, data: decoded, errors: _errors
122
+ )
119
123
  end
120
124
 
121
125
  # Returns an OAuth access token.
@@ -157,7 +161,9 @@ module Square
157
161
  # Return appropriate response type.
158
162
  decoded = APIHelper.json_deserialize(_response.raw_body)
159
163
  _errors = APIHelper.map_response(decoded, ['errors'])
160
- ApiResponse.new(_response, data: decoded, errors: _errors)
164
+ ApiResponse.new(
165
+ _response, data: decoded, errors: _errors
166
+ )
161
167
  end
162
168
  end
163
169
  end
@@ -13,24 +13,14 @@ module Square
13
13
  # guide.
14
14
  # You can modify open orders using the
15
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).
19
- # @param [String] location_id Required parameter: The ID of the business
20
- # location to associate the order with.
21
16
  # @param [CreateOrderRequest] body Required parameter: An object containing
22
17
  # the fields to POST for the request. See the corresponding object
23
18
  # definition for field details.
24
19
  # @return [CreateOrderResponse Hash] response from the API call
25
- def create_order(location_id:,
26
- body:)
20
+ def create_order(body:)
27
21
  # Prepare query url.
28
22
  _query_builder = config.get_base_uri
29
- _query_builder << '/v2/locations/{location_id}/orders'
30
- _query_builder = APIHelper.append_url_with_template_parameters(
31
- _query_builder,
32
- 'location_id' => location_id
33
- )
23
+ _query_builder << '/v2/orders'
34
24
  _query_url = APIHelper.clean_url _query_builder
35
25
 
36
26
  # Prepare headers.
@@ -51,27 +41,22 @@ module Square
51
41
  # Return appropriate response type.
52
42
  decoded = APIHelper.json_deserialize(_response.raw_body)
53
43
  _errors = APIHelper.map_response(decoded, ['errors'])
54
- ApiResponse.new(_response, data: decoded, errors: _errors)
44
+ ApiResponse.new(
45
+ _response, data: decoded, errors: _errors
46
+ )
55
47
  end
56
48
 
57
49
  # Retrieves a set of [Order](#type-order)s by their IDs.
58
50
  # If a given Order ID does not exist, the ID is ignored instead of
59
51
  # generating an error.
60
- # @param [String] location_id Required parameter: The ID of the orders'
61
- # associated location.
62
52
  # @param [BatchRetrieveOrdersRequest] body Required parameter: An object
63
53
  # containing the fields to POST for the request. See the corresponding
64
54
  # object definition for field details.
65
55
  # @return [BatchRetrieveOrdersResponse Hash] response from the API call
66
- def batch_retrieve_orders(location_id:,
67
- body:)
56
+ def batch_retrieve_orders(body:)
68
57
  # Prepare query url.
69
58
  _query_builder = config.get_base_uri
70
- _query_builder << '/v2/locations/{location_id}/orders/batch-retrieve'
71
- _query_builder = APIHelper.append_url_with_template_parameters(
72
- _query_builder,
73
- 'location_id' => location_id
74
- )
59
+ _query_builder << '/v2/orders/batch-retrieve'
75
60
  _query_url = APIHelper.clean_url _query_builder
76
61
 
77
62
  # Prepare headers.
@@ -92,69 +77,9 @@ module Square
92
77
  # Return appropriate response type.
93
78
  decoded = APIHelper.json_deserialize(_response.raw_body)
94
79
  _errors = APIHelper.map_response(decoded, ['errors'])
95
- ApiResponse.new(_response, data: decoded, errors: _errors)
96
- end
97
-
98
- # Updates an open [Order](#type-order) by adding, replacing, or deleting
99
- # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
100
- # An UpdateOrder request requires the following:
101
- # - The `order_id` in the endpoint path, identifying the order to update.
102
- # - The latest `version` of the order to update.
103
- # - The [sparse
104
- # order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
105
- # -order-objects)
106
- # containing only the fields to update and the version the update is
107
- # being applied to.
108
- # - If deleting fields, the [dot notation
109
- # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
110
- # -notation)
111
- # identifying fields to clear.
112
- # To pay for an order, please refer to the [Pay for
113
- # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
114
- # guide.
115
- # To learn more about the Orders API, see the
116
- # [Orders API
117
- # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
118
- # @param [String] location_id Required parameter: The ID of the order's
119
- # associated location.
120
- # @param [String] order_id Required parameter: The ID of the order to
121
- # update.
122
- # @param [UpdateOrderRequest] body Required parameter: An object containing
123
- # the fields to POST for the request. See the corresponding object
124
- # definition for field details.
125
- # @return [UpdateOrderResponse Hash] response from the API call
126
- def update_order(location_id:,
127
- order_id:,
128
- body:)
129
- # Prepare query url.
130
- _query_builder = config.get_base_uri
131
- _query_builder << '/v2/locations/{location_id}/orders/{order_id}'
132
- _query_builder = APIHelper.append_url_with_template_parameters(
133
- _query_builder,
134
- 'location_id' => location_id,
135
- 'order_id' => order_id
136
- )
137
- _query_url = APIHelper.clean_url _query_builder
138
-
139
- # Prepare headers.
140
- _headers = {
141
- 'accept' => 'application/json',
142
- 'content-type' => 'application/json; charset=utf-8'
143
- }
144
-
145
- # Prepare and execute HttpRequest.
146
- _request = config.http_client.put(
147
- _query_url,
148
- headers: _headers,
149
- parameters: body.to_json
80
+ ApiResponse.new(
81
+ _response, data: decoded, errors: _errors
150
82
  )
151
- OAuth2.apply(config, _request)
152
- _response = execute_request(_request)
153
-
154
- # Return appropriate response type.
155
- decoded = APIHelper.json_deserialize(_response.raw_body)
156
- _errors = APIHelper.map_response(decoded, ['errors'])
157
- ApiResponse.new(_response, data: decoded, errors: _errors)
158
83
  end
159
84
 
160
85
  # Calculates an [Order](#type-order).
@@ -186,7 +111,9 @@ module Square
186
111
  # Return appropriate response type.
187
112
  decoded = APIHelper.json_deserialize(_response.raw_body)
188
113
  _errors = APIHelper.map_response(decoded, ['errors'])
189
- ApiResponse.new(_response, data: decoded, errors: _errors)
114
+ ApiResponse.new(
115
+ _response, data: decoded, errors: _errors
116
+ )
190
117
  end
191
118
 
192
119
  # Search all orders for one or more locations. Orders include all sales,
@@ -233,7 +160,101 @@ module Square
233
160
  # Return appropriate response type.
234
161
  decoded = APIHelper.json_deserialize(_response.raw_body)
235
162
  _errors = APIHelper.map_response(decoded, ['errors'])
236
- ApiResponse.new(_response, data: decoded, errors: _errors)
163
+ ApiResponse.new(
164
+ _response, data: decoded, errors: _errors
165
+ )
166
+ end
167
+
168
+ # Retrieves an [Order](#type-order) by ID.
169
+ # @param [String] order_id Required parameter: The ID of the order to
170
+ # retrieve.
171
+ # @return [RetrieveOrderResponse Hash] response from the API call
172
+ def retrieve_order(order_id:)
173
+ # Prepare query url.
174
+ _query_builder = config.get_base_uri
175
+ _query_builder << '/v2/orders/{order_id}'
176
+ _query_builder = APIHelper.append_url_with_template_parameters(
177
+ _query_builder,
178
+ 'order_id' => { 'value' => order_id, 'encode' => true }
179
+ )
180
+ _query_url = APIHelper.clean_url _query_builder
181
+
182
+ # Prepare headers.
183
+ _headers = {
184
+ 'accept' => 'application/json'
185
+ }
186
+
187
+ # Prepare and execute HttpRequest.
188
+ _request = config.http_client.get(
189
+ _query_url,
190
+ headers: _headers
191
+ )
192
+ OAuth2.apply(config, _request)
193
+ _response = execute_request(_request)
194
+
195
+ # Return appropriate response type.
196
+ decoded = APIHelper.json_deserialize(_response.raw_body)
197
+ _errors = APIHelper.map_response(decoded, ['errors'])
198
+ ApiResponse.new(
199
+ _response, data: decoded, errors: _errors
200
+ )
201
+ end
202
+
203
+ # Updates an open [Order](#type-order) by adding, replacing, or deleting
204
+ # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
205
+ # An UpdateOrder request requires the following:
206
+ # - The `order_id` in the endpoint path, identifying the order to update.
207
+ # - The latest `version` of the order to update.
208
+ # - The [sparse
209
+ # order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
210
+ # -order-objects)
211
+ # containing only the fields to update and the version the update is
212
+ # being applied to.
213
+ # - If deleting fields, the [dot notation
214
+ # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
215
+ # -notation)
216
+ # identifying fields to clear.
217
+ # To pay for an order, please refer to the [Pay for
218
+ # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
219
+ # guide.
220
+ # @param [String] order_id Required parameter: The ID of the order to
221
+ # update.
222
+ # @param [UpdateOrderRequest] body Required parameter: An object containing
223
+ # the fields to POST for the request. See the corresponding object
224
+ # definition for field details.
225
+ # @return [UpdateOrderResponse Hash] response from the API call
226
+ def update_order(order_id:,
227
+ body:)
228
+ # Prepare query url.
229
+ _query_builder = config.get_base_uri
230
+ _query_builder << '/v2/orders/{order_id}'
231
+ _query_builder = APIHelper.append_url_with_template_parameters(
232
+ _query_builder,
233
+ 'order_id' => { 'value' => order_id, 'encode' => true }
234
+ )
235
+ _query_url = APIHelper.clean_url _query_builder
236
+
237
+ # Prepare headers.
238
+ _headers = {
239
+ 'accept' => 'application/json',
240
+ 'content-type' => 'application/json; charset=utf-8'
241
+ }
242
+
243
+ # Prepare and execute HttpRequest.
244
+ _request = config.http_client.put(
245
+ _query_url,
246
+ headers: _headers,
247
+ parameters: body.to_json
248
+ )
249
+ OAuth2.apply(config, _request)
250
+ _response = execute_request(_request)
251
+
252
+ # Return appropriate response type.
253
+ decoded = APIHelper.json_deserialize(_response.raw_body)
254
+ _errors = APIHelper.map_response(decoded, ['errors'])
255
+ ApiResponse.new(
256
+ _response, data: decoded, errors: _errors
257
+ )
237
258
  end
238
259
 
239
260
  # Pay for an [order](#type-order) using one or more approved
@@ -255,8 +276,6 @@ module Square
255
276
  # layed-capture).
256
277
  # Using a delayed capture payment with PayOrder will complete the approved
257
278
  # payment.
258
- # Learn how to [pay for orders with a single payment using the Payments
259
- # API](https://developer.squareup.com/docs/orders-api/pay-for-orders).
260
279
  # @param [String] order_id Required parameter: The ID of the order being
261
280
  # paid.
262
281
  # @param [PayOrderRequest] body Required parameter: An object containing the
@@ -270,7 +289,7 @@ module Square
270
289
  _query_builder << '/v2/orders/{order_id}/pay'
271
290
  _query_builder = APIHelper.append_url_with_template_parameters(
272
291
  _query_builder,
273
- 'order_id' => order_id
292
+ 'order_id' => { 'value' => order_id, 'encode' => true }
274
293
  )
275
294
  _query_url = APIHelper.clean_url _query_builder
276
295
 
@@ -292,7 +311,9 @@ module Square
292
311
  # Return appropriate response type.
293
312
  decoded = APIHelper.json_deserialize(_response.raw_body)
294
313
  _errors = APIHelper.map_response(decoded, ['errors'])
295
- ApiResponse.new(_response, data: decoded, errors: _errors)
314
+ ApiResponse.new(
315
+ _response, data: decoded, errors: _errors
316
+ )
296
317
  end
297
318
  end
298
319
  end
@@ -6,30 +6,35 @@ module Square
6
6
  end
7
7
 
8
8
  # Retrieves a list of payments taken by the account making the request.
9
- # Max results per page: 100
10
- # @param [String] begin_time Optional parameter: Timestamp for the beginning
11
- # of the reporting period, in RFC 3339 format. Inclusive. Default: The
12
- # current time minus one year.
13
- # @param [String] end_time Optional parameter: Timestamp for the end of the
14
- # requested reporting period, in RFC 3339 format. Default: The current
15
- # time.
9
+ # The maximum results per page is 100.
10
+ # @param [String] begin_time Optional parameter: The timestamp for the
11
+ # beginning of the reporting period, in RFC 3339 format. Inclusive. Default:
12
+ # The current time minus one year.
13
+ # @param [String] end_time Optional parameter: The timestamp for the end of
14
+ # the reporting period, in RFC 3339 format. Default: The current time.
16
15
  # @param [String] sort_order Optional parameter: The order in which results
17
- # are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest
16
+ # are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest
18
17
  # (default).
19
18
  # @param [String] cursor Optional parameter: A pagination cursor returned by
20
- # a previous call to this endpoint. Provide this to retrieve the next set of
21
- # results for the original query. See
19
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
20
+ # set of results for the original query. For more information, see
22
21
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
23
- # for more information.
22
+ # .
24
23
  # @param [String] location_id Optional parameter: Limit results to the
25
- # location supplied. By default, results are returned for all locations
26
- # associated with the merchant.
24
+ # location supplied. By default, results are returned for the default (main)
25
+ # location associated with the seller.
27
26
  # @param [Long] total Optional parameter: The exact amount in the
28
- # total_money for a `Payment`.
29
- # @param [String] last_4 Optional parameter: The last 4 digits of `Payment`
30
- # card.
31
- # @param [String] card_brand Optional parameter: The brand of `Payment`
32
- # card. For example, `VISA`
27
+ # `total_money` for a payment.
28
+ # @param [String] last_4 Optional parameter: The last four digits of a
29
+ # payment card.
30
+ # @param [String] card_brand Optional parameter: The brand of the payment
31
+ # card (for example, VISA).
32
+ # @param [Integer] limit Optional parameter: The maximum number of results
33
+ # to be returned in a single page. It is possible to receive fewer results
34
+ # than the specified limit on a given page. The default value of 100 is
35
+ # also the maximum allowed value. If the provided value is greater than
36
+ # 100, it is ignored and the default value is used instead. Default:
37
+ # `100`
33
38
  # @return [ListPaymentsResponse Hash] response from the API call
34
39
  def list_payments(begin_time: nil,
35
40
  end_time: nil,
@@ -38,7 +43,8 @@ module Square
38
43
  location_id: nil,
39
44
  total: nil,
40
45
  last_4: nil,
41
- card_brand: nil)
46
+ card_brand: nil,
47
+ limit: nil)
42
48
  # Prepare query url.
43
49
  _query_builder = config.get_base_uri
44
50
  _query_builder << '/v2/payments'
@@ -51,7 +57,8 @@ module Square
51
57
  'location_id' => location_id,
52
58
  'total' => total,
53
59
  'last_4' => last_4,
54
- 'card_brand' => card_brand
60
+ 'card_brand' => card_brand,
61
+ 'limit' => limit
55
62
  )
56
63
  _query_url = APIHelper.clean_url _query_builder
57
64
 
@@ -71,20 +78,19 @@ module Square
71
78
  # Return appropriate response type.
72
79
  decoded = APIHelper.json_deserialize(_response.raw_body)
73
80
  _errors = APIHelper.map_response(decoded, ['errors'])
74
- ApiResponse.new(_response, data: decoded, errors: _errors)
81
+ ApiResponse.new(
82
+ _response, data: decoded, errors: _errors
83
+ )
75
84
  end
76
85
 
77
- # Charges a payment source, for example, a card
78
- # represented by customer's card on file or a card nonce. In addition
79
- # to the payment source, the request must also include the
86
+ # Charges a payment source (for example, a card
87
+ # represented by customer's card on file or a card nonce). In addition
88
+ # to the payment source, the request must include the
80
89
  # amount to accept for the payment.
81
- # There are several optional parameters that you can include in the request.
82
- # For example, tip money, whether to autocomplete the payment, or a
90
+ # There are several optional parameters that you can include in the request
91
+ # (for example, tip money, whether to autocomplete the payment, or a
83
92
  # reference ID
84
- # to correlate this payment with another system.
85
- # For more information about these
86
- # payment options, see [Take
87
- # Payments](https://developer.squareup.com/docs/payments-api/take-payments).
93
+ # to correlate this payment with another system).
88
94
  # The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
89
95
  # to enable application fees.
90
96
  # @param [CreatePaymentRequest] body Required parameter: An object
@@ -115,24 +121,26 @@ module Square
115
121
  # Return appropriate response type.
116
122
  decoded = APIHelper.json_deserialize(_response.raw_body)
117
123
  _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(_response, data: decoded, errors: _errors)
124
+ ApiResponse.new(
125
+ _response, data: decoded, errors: _errors
126
+ )
119
127
  end
120
128
 
121
129
  # Cancels (voids) a payment identified by the idempotency key that is
122
130
  # specified in the
123
131
  # request.
124
- # Use this method when status of a CreatePayment request is unknown. For
125
- # example, after you send a
126
- # CreatePayment request a network error occurs and you don't get a response.
127
- # In this case, you can
132
+ # Use this method when the status of a `CreatePayment` request is unknown
133
+ # (for example, after you send a
134
+ # `CreatePayment` request, a network error occurs and you do not get a
135
+ # response). In this case, you can
128
136
  # direct Square to cancel the payment using this endpoint. In the request,
129
137
  # you provide the same
130
- # idempotency key that you provided in your CreatePayment request you want
131
- # to cancel. After
132
- # cancelling the payment, you can submit your CreatePayment request again.
138
+ # idempotency key that you provided in your `CreatePayment` request that you
139
+ # want to cancel. After
140
+ # canceling the payment, you can submit your `CreatePayment` request again.
133
141
  # Note that if no payment with the specified idempotency key is found, no
134
- # action is taken, the end
135
- # point returns successfully.
142
+ # action is taken and the endpoint
143
+ # returns successfully.
136
144
  # @param [CancelPaymentByIdempotencyKeyRequest] body Required parameter: An
137
145
  # object containing the fields to POST for the request. See the
138
146
  # corresponding object definition for field details.
@@ -161,12 +169,14 @@ module Square
161
169
  # Return appropriate response type.
162
170
  decoded = APIHelper.json_deserialize(_response.raw_body)
163
171
  _errors = APIHelper.map_response(decoded, ['errors'])
164
- ApiResponse.new(_response, data: decoded, errors: _errors)
172
+ ApiResponse.new(
173
+ _response, data: decoded, errors: _errors
174
+ )
165
175
  end
166
176
 
167
- # Retrieves details for a specific Payment.
168
- # @param [String] payment_id Required parameter: Unique ID for the desired
169
- # `Payment`.
177
+ # Retrieves details for a specific payment.
178
+ # @param [String] payment_id Required parameter: A unique ID for the desired
179
+ # payment.
170
180
  # @return [GetPaymentResponse Hash] response from the API call
171
181
  def get_payment(payment_id:)
172
182
  # Prepare query url.
@@ -174,7 +184,7 @@ module Square
174
184
  _query_builder << '/v2/payments/{payment_id}'
175
185
  _query_builder = APIHelper.append_url_with_template_parameters(
176
186
  _query_builder,
177
- 'payment_id' => payment_id
187
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
178
188
  )
179
189
  _query_url = APIHelper.clean_url _query_builder
180
190
 
@@ -194,17 +204,16 @@ module Square
194
204
  # Return appropriate response type.
195
205
  decoded = APIHelper.json_deserialize(_response.raw_body)
196
206
  _errors = APIHelper.map_response(decoded, ['errors'])
197
- ApiResponse.new(_response, data: decoded, errors: _errors)
207
+ ApiResponse.new(
208
+ _response, data: decoded, errors: _errors
209
+ )
198
210
  end
199
211
 
200
- # Cancels (voids) a payment. If you set `autocomplete` to false when
212
+ # Cancels (voids) a payment. If you set `autocomplete` to `false` when
201
213
  # creating a payment,
202
- # you can cancel the payment using this endpoint. For more information, see
203
- # [Delayed
204
- # Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
205
- # elayed-payments).
206
- # @param [String] payment_id Required parameter: `payment_id` identifying
207
- # the payment to be canceled.
214
+ # you can cancel the payment using this endpoint.
215
+ # @param [String] payment_id Required parameter: The `payment_id`
216
+ # identifying the payment to be canceled.
208
217
  # @return [CancelPaymentResponse Hash] response from the API call
209
218
  def cancel_payment(payment_id:)
210
219
  # Prepare query url.
@@ -212,7 +221,7 @@ module Square
212
221
  _query_builder << '/v2/payments/{payment_id}/cancel'
213
222
  _query_builder = APIHelper.append_url_with_template_parameters(
214
223
  _query_builder,
215
- 'payment_id' => payment_id
224
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
216
225
  )
217
226
  _query_url = APIHelper.clean_url _query_builder
218
227
 
@@ -232,20 +241,19 @@ module Square
232
241
  # Return appropriate response type.
233
242
  decoded = APIHelper.json_deserialize(_response.raw_body)
234
243
  _errors = APIHelper.map_response(decoded, ['errors'])
235
- ApiResponse.new(_response, data: decoded, errors: _errors)
244
+ ApiResponse.new(
245
+ _response, data: decoded, errors: _errors
246
+ )
236
247
  end
237
248
 
238
249
  # Completes (captures) a payment.
239
250
  # By default, payments are set to complete immediately after they are
240
251
  # created.
241
- # If you set autocomplete to false when creating a payment, you can complete
242
- # (capture)
243
- # the payment using this endpoint. For more information, see
244
- # [Delayed
245
- # Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
246
- # elayed-payments).
247
- # @param [String] payment_id Required parameter: Unique ID identifying the
248
- # payment to be completed.
252
+ # If you set `autocomplete` to `false` when creating a payment, you can
253
+ # complete (capture)
254
+ # the payment using this endpoint.
255
+ # @param [String] payment_id Required parameter: The unique ID identifying
256
+ # the payment to be completed.
249
257
  # @return [CompletePaymentResponse Hash] response from the API call
250
258
  def complete_payment(payment_id:)
251
259
  # Prepare query url.
@@ -253,7 +261,7 @@ module Square
253
261
  _query_builder << '/v2/payments/{payment_id}/complete'
254
262
  _query_builder = APIHelper.append_url_with_template_parameters(
255
263
  _query_builder,
256
- 'payment_id' => payment_id
264
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
257
265
  )
258
266
  _query_url = APIHelper.clean_url _query_builder
259
267
 
@@ -273,7 +281,9 @@ module Square
273
281
  # Return appropriate response type.
274
282
  decoded = APIHelper.json_deserialize(_response.raw_body)
275
283
  _errors = APIHelper.map_response(decoded, ['errors'])
276
- ApiResponse.new(_response, data: decoded, errors: _errors)
284
+ ApiResponse.new(
285
+ _response, data: decoded, errors: _errors
286
+ )
277
287
  end
278
288
  end
279
289
  end