square.rb 6.3.0.20200826 → 8.1.0.20210121

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +34 -31
  4. data/lib/square.rb +61 -61
  5. data/lib/square/api/apple_pay_api.rb +5 -3
  6. data/lib/square/api/bank_accounts_api.rb +16 -19
  7. data/lib/square/api/base_api.rb +1 -1
  8. data/lib/square/api/bookings_api.rb +308 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +71 -35
  11. data/lib/square/api/checkout_api.rb +4 -2
  12. data/lib/square/api/customer_groups_api.rb +18 -8
  13. data/lib/square/api/customer_segments_api.rb +9 -5
  14. data/lib/square/api/customers_api.rb +47 -27
  15. data/lib/square/api/devices_api.rb +17 -6
  16. data/lib/square/api/disputes_api.rb +71 -68
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/inventory_api.rb +27 -13
  19. data/lib/square/api/invoices_api.rb +44 -40
  20. data/lib/square/api/labor_api.rb +57 -25
  21. data/lib/square/api/locations_api.rb +16 -13
  22. data/lib/square/api/loyalty_api.rb +60 -66
  23. data/lib/square/api/merchants_api.rb +7 -3
  24. data/lib/square/api/mobile_authorization_api.rb +5 -3
  25. data/lib/square/api/o_auth_api.rb +11 -8
  26. data/lib/square/api/orders_api.rb +55 -16
  27. data/lib/square/api/payments_api.rb +75 -65
  28. data/lib/square/api/refunds_api.rb +37 -27
  29. data/lib/square/api/subscriptions_api.rb +26 -14
  30. data/lib/square/api/team_api.rb +46 -30
  31. data/lib/square/api/terminal_api.rb +156 -7
  32. data/lib/square/api/transactions_api.rb +32 -18
  33. data/lib/square/api/v1_employees_api.rb +59 -33
  34. data/lib/square/api/v1_items_api.rb +195 -115
  35. data/lib/square/api/v1_transactions_api.rb +49 -27
  36. data/lib/square/api_helper.rb +14 -9
  37. data/lib/square/client.rb +8 -8
  38. data/lib/square/configuration.rb +2 -2
  39. data/lib/square/http/api_response.rb +2 -0
  40. data/lib/square/http/faraday_client.rb +9 -2
  41. data/spec/user_journey_spec.rb +2 -5
  42. data/test/api/api_test_base.rb +1 -6
  43. data/test/api/test_catalog_api.rb +1 -4
  44. data/test/api/test_customers_api.rb +1 -4
  45. data/test/api/test_employees_api.rb +1 -4
  46. data/test/api/test_labor_api.rb +2 -6
  47. data/test/api/test_locations_api.rb +22 -33
  48. data/test/api/test_merchants_api.rb +1 -4
  49. data/test/api/test_payments_api.rb +3 -6
  50. data/test/api/test_refunds_api.rb +3 -6
  51. data/test/http_response_catcher.rb +0 -5
  52. data/test/test_helper.rb +0 -5
  53. metadata +33 -15
  54. data/lib/square/api/v1_locations_api.rb +0 -65
@@ -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.
@@ -83,7 +85,7 @@ module Square
83
85
  # ```
84
86
  # Replace `APPLICATION_SECRET` with the application secret on the
85
87
  # Credentials
86
- # page in the [application dashboard](https://connect.squareup.com/apps).
88
+ # page in the [Developer Dashboard](https://developer.squareup.com/apps).
87
89
  # @param [RevokeTokenRequest] body Required parameter: An object containing
88
90
  # the fields to POST for the request. See the corresponding object
89
91
  # definition for field details.
@@ -115,16 +117,15 @@ 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.
122
126
  # The endpoint supports distinct methods of obtaining OAuth access tokens.
123
127
  # Applications specify a method by adding the `grant_type` parameter
124
128
  # 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
129
  # __Note:__ Regardless of the method application specified,
129
130
  # the endpoint always returns two items; an OAuth access token and
130
131
  # a refresh token in the response.
@@ -157,7 +158,9 @@ module Square
157
158
  # Return appropriate response type.
158
159
  decoded = APIHelper.json_deserialize(_response.raw_body)
159
160
  _errors = APIHelper.map_response(decoded, ['errors'])
160
- ApiResponse.new(_response, data: decoded, errors: _errors)
161
+ ApiResponse.new(
162
+ _response, data: decoded, errors: _errors
163
+ )
161
164
  end
162
165
  end
163
166
  end
@@ -13,9 +13,6 @@ 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
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.
@@ -44,7 +41,9 @@ 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
49
  # Retrieves a set of [Order](#type-order)s by their IDs.
@@ -78,7 +77,9 @@ 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
85
  # Calculates an [Order](#type-order).
@@ -110,7 +111,9 @@ 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
+ )
114
117
  end
115
118
 
116
119
  # Search all orders for one or more locations. Orders include all sales,
@@ -157,7 +160,44 @@ module Square
157
160
  # Return appropriate response type.
158
161
  decoded = APIHelper.json_deserialize(_response.raw_body)
159
162
  _errors = APIHelper.map_response(decoded, ['errors'])
160
- 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
+ )
161
201
  end
162
202
 
163
203
  # Updates an open [Order](#type-order) by adding, replacing, or deleting
@@ -177,9 +217,6 @@ module Square
177
217
  # To pay for an order, please refer to the [Pay for
178
218
  # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
179
219
  # 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).
183
220
  # @param [String] order_id Required parameter: The ID of the order to
184
221
  # update.
185
222
  # @param [UpdateOrderRequest] body Required parameter: An object containing
@@ -193,7 +230,7 @@ module Square
193
230
  _query_builder << '/v2/orders/{order_id}'
194
231
  _query_builder = APIHelper.append_url_with_template_parameters(
195
232
  _query_builder,
196
- 'order_id' => order_id
233
+ 'order_id' => { 'value' => order_id, 'encode' => true }
197
234
  )
198
235
  _query_url = APIHelper.clean_url _query_builder
199
236
 
@@ -215,7 +252,9 @@ module Square
215
252
  # Return appropriate response type.
216
253
  decoded = APIHelper.json_deserialize(_response.raw_body)
217
254
  _errors = APIHelper.map_response(decoded, ['errors'])
218
- ApiResponse.new(_response, data: decoded, errors: _errors)
255
+ ApiResponse.new(
256
+ _response, data: decoded, errors: _errors
257
+ )
219
258
  end
220
259
 
221
260
  # Pay for an [order](#type-order) using one or more approved
@@ -237,8 +276,6 @@ module Square
237
276
  # layed-capture).
238
277
  # Using a delayed capture payment with PayOrder will complete the approved
239
278
  # 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
279
  # @param [String] order_id Required parameter: The ID of the order being
243
280
  # paid.
244
281
  # @param [PayOrderRequest] body Required parameter: An object containing the
@@ -252,7 +289,7 @@ module Square
252
289
  _query_builder << '/v2/orders/{order_id}/pay'
253
290
  _query_builder = APIHelper.append_url_with_template_parameters(
254
291
  _query_builder,
255
- 'order_id' => order_id
292
+ 'order_id' => { 'value' => order_id, 'encode' => true }
256
293
  )
257
294
  _query_url = APIHelper.clean_url _query_builder
258
295
 
@@ -274,7 +311,9 @@ module Square
274
311
  # Return appropriate response type.
275
312
  decoded = APIHelper.json_deserialize(_response.raw_body)
276
313
  _errors = APIHelper.map_response(decoded, ['errors'])
277
- ApiResponse.new(_response, data: decoded, errors: _errors)
314
+ ApiResponse.new(
315
+ _response, data: decoded, errors: _errors
316
+ )
278
317
  end
279
318
  end
280
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
@@ -6,32 +6,36 @@ module Square
6
6
  end
7
7
 
8
8
  # Retrieves a list of refunds for 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 requested reporting period, in RFC 3339 format. 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
9
+ # The maximum results per page is 100.
10
+ # @param [String] begin_time Optional parameter: The timestamp for the
11
+ # beginning of the requested reporting period, in RFC 3339 format. Default:
12
+ # The current time minus one year.
13
+ # @param [String] end_time Optional parameter: The timestamp for the end of
14
+ # the requested reporting period, in RFC 3339 format. Default: The current
15
15
  # time.
16
16
  # @param [String] sort_order Optional parameter: The order in which results
17
- # are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest
17
+ # are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest
18
18
  # (default).
19
19
  # @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
20
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
21
+ # set of results for the original query. For more information, see
22
22
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
23
- # for more information.
23
+ # .
24
24
  # @param [String] location_id Optional parameter: Limit results to the
25
25
  # location supplied. By default, results are returned for all locations
26
- # associated with the merchant.
26
+ # associated with the seller.
27
27
  # @param [String] status Optional parameter: If provided, only refunds with
28
28
  # the given status are returned. For a list of refund status values, see
29
- # [PaymentRefund](#type-paymentrefund). Default: If omitted refunds are
30
- # returned regardless of status.
29
+ # [PaymentRefund](#type-paymentrefund). Default: If omitted, refunds are
30
+ # returned regardless of their status.
31
31
  # @param [String] source_type Optional parameter: If provided, only refunds
32
32
  # with the given source type are returned. - `CARD` - List refunds only for
33
- # payments where card was specified as payment source. Default: If omitted
34
- # refunds are returned regardless of source type.
33
+ # payments where `CARD` was specified as the payment source. Default: If
34
+ # omitted, refunds are returned regardless of the source type.
35
+ # @param [Integer] limit Optional parameter: The maximum number of results
36
+ # to be returned in a single page. It is possible to receive fewer results
37
+ # than the specified limit on a given page. If the supplied value is
38
+ # greater than 100, no more than 100 results are returned. Default: 100
35
39
  # @return [ListPaymentRefundsResponse Hash] response from the API call
36
40
  def list_payment_refunds(begin_time: nil,
37
41
  end_time: nil,
@@ -39,7 +43,8 @@ module Square
39
43
  cursor: nil,
40
44
  location_id: nil,
41
45
  status: nil,
42
- source_type: nil)
46
+ source_type: nil,
47
+ limit: nil)
43
48
  # Prepare query url.
44
49
  _query_builder = config.get_base_uri
45
50
  _query_builder << '/v2/refunds'
@@ -51,7 +56,8 @@ module Square
51
56
  'cursor' => cursor,
52
57
  'location_id' => location_id,
53
58
  'status' => status,
54
- 'source_type' => source_type
59
+ 'source_type' => source_type,
60
+ 'limit' => limit
55
61
  )
56
62
  _query_url = APIHelper.clean_url _query_builder
57
63
 
@@ -71,13 +77,13 @@ module Square
71
77
  # Return appropriate response type.
72
78
  decoded = APIHelper.json_deserialize(_response.raw_body)
73
79
  _errors = APIHelper.map_response(decoded, ['errors'])
74
- ApiResponse.new(_response, data: decoded, errors: _errors)
80
+ ApiResponse.new(
81
+ _response, data: decoded, errors: _errors
82
+ )
75
83
  end
76
84
 
77
85
  # Refunds a payment. You can refund the entire payment amount or a
78
- # portion of it. For more information, see
79
- # [Payments and Refunds
80
- # Overview](https://developer.squareup.com/docs/payments-api/overview).
86
+ # portion of it.
81
87
  # @param [RefundPaymentRequest] body Required parameter: An object
82
88
  # containing the fields to POST for the request. See the corresponding
83
89
  # object definition for field details.
@@ -106,12 +112,14 @@ module Square
106
112
  # Return appropriate response type.
107
113
  decoded = APIHelper.json_deserialize(_response.raw_body)
108
114
  _errors = APIHelper.map_response(decoded, ['errors'])
109
- ApiResponse.new(_response, data: decoded, errors: _errors)
115
+ ApiResponse.new(
116
+ _response, data: decoded, errors: _errors
117
+ )
110
118
  end
111
119
 
112
- # Retrieves a specific `Refund` using the `refund_id`.
113
- # @param [String] refund_id Required parameter: Unique ID for the desired
114
- # `PaymentRefund`.
120
+ # Retrieves a specific refund using the `refund_id`.
121
+ # @param [String] refund_id Required parameter: The unique ID for the
122
+ # desired `PaymentRefund`.
115
123
  # @return [GetPaymentRefundResponse Hash] response from the API call
116
124
  def get_payment_refund(refund_id:)
117
125
  # Prepare query url.
@@ -119,7 +127,7 @@ module Square
119
127
  _query_builder << '/v2/refunds/{refund_id}'
120
128
  _query_builder = APIHelper.append_url_with_template_parameters(
121
129
  _query_builder,
122
- 'refund_id' => refund_id
130
+ 'refund_id' => { 'value' => refund_id, 'encode' => true }
123
131
  )
124
132
  _query_url = APIHelper.clean_url _query_builder
125
133
 
@@ -139,7 +147,9 @@ module Square
139
147
  # Return appropriate response type.
140
148
  decoded = APIHelper.json_deserialize(_response.raw_body)
141
149
  _errors = APIHelper.map_response(decoded, ['errors'])
142
- ApiResponse.new(_response, data: decoded, errors: _errors)
150
+ ApiResponse.new(
151
+ _response, data: decoded, errors: _errors
152
+ )
143
153
  end
144
154
  end
145
155
  end