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
@@ -6,30 +6,38 @@ 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
+ # Results are eventually consistent, and new payments or changes to payments
10
+ # might take several
11
+ # seconds to appear.
12
+ # The maximum results per page is 100.
13
+ # @param [String] begin_time Optional parameter: The timestamp for the
14
+ # beginning of the reporting period, in RFC 3339 format. Inclusive. Default:
15
+ # The current time minus one year.
16
+ # @param [String] end_time Optional parameter: The timestamp for the end of
17
+ # the reporting period, in RFC 3339 format. Default: The current time.
16
18
  # @param [String] sort_order Optional parameter: The order in which results
17
- # are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest
19
+ # are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest
18
20
  # (default).
19
21
  # @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
22
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
23
+ # set of results for the original query. For more information, see
22
24
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
23
- # for more information.
25
+ # .
24
26
  # @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.
27
+ # location supplied. By default, results are returned for the default (main)
28
+ # location associated with the seller.
27
29
  # @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`
30
+ # `total_money` for a payment.
31
+ # @param [String] last_4 Optional parameter: The last four digits of a
32
+ # payment card.
33
+ # @param [String] card_brand Optional parameter: The brand of the payment
34
+ # card (for example, VISA).
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. The default value of 100 is
38
+ # also the maximum allowed value. If the provided value is greater than
39
+ # 100, it is ignored and the default value is used instead. Default:
40
+ # `100`
33
41
  # @return [ListPaymentsResponse Hash] response from the API call
34
42
  def list_payments(begin_time: nil,
35
43
  end_time: nil,
@@ -38,7 +46,8 @@ module Square
38
46
  location_id: nil,
39
47
  total: nil,
40
48
  last_4: nil,
41
- card_brand: nil)
49
+ card_brand: nil,
50
+ limit: nil)
42
51
  # Prepare query url.
43
52
  _query_builder = config.get_base_uri
44
53
  _query_builder << '/v2/payments'
@@ -51,7 +60,8 @@ module Square
51
60
  'location_id' => location_id,
52
61
  'total' => total,
53
62
  'last_4' => last_4,
54
- 'card_brand' => card_brand
63
+ 'card_brand' => card_brand,
64
+ 'limit' => limit
55
65
  )
56
66
  _query_url = APIHelper.clean_url _query_builder
57
67
 
@@ -71,22 +81,19 @@ module Square
71
81
  # Return appropriate response type.
72
82
  decoded = APIHelper.json_deserialize(_response.raw_body)
73
83
  _errors = APIHelper.map_response(decoded, ['errors'])
74
- ApiResponse.new(_response, data: decoded, errors: _errors)
84
+ ApiResponse.new(
85
+ _response, data: decoded, errors: _errors
86
+ )
75
87
  end
76
88
 
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
80
- # 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
83
- # 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).
88
- # The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
89
- # to enable application fees.
89
+ # Creates a payment using the provided source. You can use this endpoint
90
+ # to charge a card (credit/debit card or
91
+ # Square gift card) or record a payment that the seller received outside of
92
+ # Square
93
+ # (cash payment from a buyer or a payment that an external entity
94
+ # processed on behalf of the seller).
95
+ # The endpoint creates a
96
+ # `Payment` object and returns it in the response.
90
97
  # @param [CreatePaymentRequest] body Required parameter: An object
91
98
  # containing the fields to POST for the request. See the corresponding
92
99
  # object definition for field details.
@@ -100,7 +107,7 @@ module Square
100
107
  # Prepare headers.
101
108
  _headers = {
102
109
  'accept' => 'application/json',
103
- 'content-type' => 'application/json; charset=utf-8'
110
+ 'Content-Type' => 'application/json'
104
111
  }
105
112
 
106
113
  # Prepare and execute HttpRequest.
@@ -115,24 +122,26 @@ module Square
115
122
  # Return appropriate response type.
116
123
  decoded = APIHelper.json_deserialize(_response.raw_body)
117
124
  _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(_response, data: decoded, errors: _errors)
125
+ ApiResponse.new(
126
+ _response, data: decoded, errors: _errors
127
+ )
119
128
  end
120
129
 
121
130
  # Cancels (voids) a payment identified by the idempotency key that is
122
131
  # specified in the
123
132
  # 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
133
+ # Use this method when the status of a `CreatePayment` request is unknown
134
+ # (for example, after you send a
135
+ # `CreatePayment` request, a network error occurs and you do not get a
136
+ # response). In this case, you can
128
137
  # direct Square to cancel the payment using this endpoint. In the request,
129
138
  # 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.
139
+ # idempotency key that you provided in your `CreatePayment` request that you
140
+ # want to cancel. After
141
+ # canceling the payment, you can submit your `CreatePayment` request again.
133
142
  # Note that if no payment with the specified idempotency key is found, no
134
- # action is taken, the end
135
- # point returns successfully.
143
+ # action is taken and the endpoint
144
+ # returns successfully.
136
145
  # @param [CancelPaymentByIdempotencyKeyRequest] body Required parameter: An
137
146
  # object containing the fields to POST for the request. See the
138
147
  # corresponding object definition for field details.
@@ -146,7 +155,7 @@ module Square
146
155
  # Prepare headers.
147
156
  _headers = {
148
157
  'accept' => 'application/json',
149
- 'content-type' => 'application/json; charset=utf-8'
158
+ 'Content-Type' => 'application/json'
150
159
  }
151
160
 
152
161
  # Prepare and execute HttpRequest.
@@ -161,12 +170,14 @@ module Square
161
170
  # Return appropriate response type.
162
171
  decoded = APIHelper.json_deserialize(_response.raw_body)
163
172
  _errors = APIHelper.map_response(decoded, ['errors'])
164
- ApiResponse.new(_response, data: decoded, errors: _errors)
173
+ ApiResponse.new(
174
+ _response, data: decoded, errors: _errors
175
+ )
165
176
  end
166
177
 
167
- # Retrieves details for a specific Payment.
168
- # @param [String] payment_id Required parameter: Unique ID for the desired
169
- # `Payment`.
178
+ # Retrieves details for a specific payment.
179
+ # @param [String] payment_id Required parameter: A unique ID for the desired
180
+ # payment.
170
181
  # @return [GetPaymentResponse Hash] response from the API call
171
182
  def get_payment(payment_id:)
172
183
  # Prepare query url.
@@ -174,7 +185,7 @@ module Square
174
185
  _query_builder << '/v2/payments/{payment_id}'
175
186
  _query_builder = APIHelper.append_url_with_template_parameters(
176
187
  _query_builder,
177
- 'payment_id' => payment_id
188
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
178
189
  )
179
190
  _query_url = APIHelper.clean_url _query_builder
180
191
 
@@ -194,17 +205,58 @@ module Square
194
205
  # Return appropriate response type.
195
206
  decoded = APIHelper.json_deserialize(_response.raw_body)
196
207
  _errors = APIHelper.map_response(decoded, ['errors'])
197
- ApiResponse.new(_response, data: decoded, errors: _errors)
208
+ ApiResponse.new(
209
+ _response, data: decoded, errors: _errors
210
+ )
211
+ end
212
+
213
+ # Updates a payment with the APPROVED status.
214
+ # You can update the `amount_money` and `tip_money` using this endpoint.
215
+ # @param [String] payment_id Required parameter: The ID of the payment to
216
+ # update.
217
+ # @param [UpdatePaymentRequest] body Required parameter: An object
218
+ # containing the fields to POST for the request. See the corresponding
219
+ # object definition for field details.
220
+ # @return [UpdatePaymentResponse Hash] response from the API call
221
+ def update_payment(payment_id:,
222
+ body:)
223
+ # Prepare query url.
224
+ _query_builder = config.get_base_uri
225
+ _query_builder << '/v2/payments/{payment_id}'
226
+ _query_builder = APIHelper.append_url_with_template_parameters(
227
+ _query_builder,
228
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
229
+ )
230
+ _query_url = APIHelper.clean_url _query_builder
231
+
232
+ # Prepare headers.
233
+ _headers = {
234
+ 'accept' => 'application/json',
235
+ 'Content-Type' => 'application/json'
236
+ }
237
+
238
+ # Prepare and execute HttpRequest.
239
+ _request = config.http_client.put(
240
+ _query_url,
241
+ headers: _headers,
242
+ parameters: body.to_json
243
+ )
244
+ OAuth2.apply(config, _request)
245
+ _response = execute_request(_request)
246
+
247
+ # Return appropriate response type.
248
+ decoded = APIHelper.json_deserialize(_response.raw_body)
249
+ _errors = APIHelper.map_response(decoded, ['errors'])
250
+ ApiResponse.new(
251
+ _response, data: decoded, errors: _errors
252
+ )
198
253
  end
199
254
 
200
- # Cancels (voids) a payment. If you set `autocomplete` to false when
201
- # 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.
255
+ # Cancels (voids) a payment. You can use this endpoint to cancel a payment
256
+ # with
257
+ # the APPROVED `status`.
258
+ # @param [String] payment_id Required parameter: The ID of the payment to
259
+ # cancel.
208
260
  # @return [CancelPaymentResponse Hash] response from the API call
209
261
  def cancel_payment(payment_id:)
210
262
  # Prepare query url.
@@ -212,7 +264,7 @@ module Square
212
264
  _query_builder << '/v2/payments/{payment_id}/cancel'
213
265
  _query_builder = APIHelper.append_url_with_template_parameters(
214
266
  _query_builder,
215
- 'payment_id' => payment_id
267
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
216
268
  )
217
269
  _query_url = APIHelper.clean_url _query_builder
218
270
 
@@ -232,40 +284,44 @@ module Square
232
284
  # Return appropriate response type.
233
285
  decoded = APIHelper.json_deserialize(_response.raw_body)
234
286
  _errors = APIHelper.map_response(decoded, ['errors'])
235
- ApiResponse.new(_response, data: decoded, errors: _errors)
287
+ ApiResponse.new(
288
+ _response, data: decoded, errors: _errors
289
+ )
236
290
  end
237
291
 
238
292
  # Completes (captures) a payment.
239
293
  # By default, payments are set to complete immediately after they are
240
294
  # 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.
295
+ # You can use this endpoint to complete a payment with the APPROVED
296
+ # `status`.
297
+ # @param [String] payment_id Required parameter: The unique ID identifying
298
+ # the payment to be completed.
299
+ # @param [CompletePaymentRequest] body Required parameter: An object
300
+ # containing the fields to POST for the request. See the corresponding
301
+ # object definition for field details.
249
302
  # @return [CompletePaymentResponse Hash] response from the API call
250
- def complete_payment(payment_id:)
303
+ def complete_payment(payment_id:,
304
+ body:)
251
305
  # Prepare query url.
252
306
  _query_builder = config.get_base_uri
253
307
  _query_builder << '/v2/payments/{payment_id}/complete'
254
308
  _query_builder = APIHelper.append_url_with_template_parameters(
255
309
  _query_builder,
256
- 'payment_id' => payment_id
310
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
257
311
  )
258
312
  _query_url = APIHelper.clean_url _query_builder
259
313
 
260
314
  # Prepare headers.
261
315
  _headers = {
262
- 'accept' => 'application/json'
316
+ 'accept' => 'application/json',
317
+ 'Content-Type' => 'application/json'
263
318
  }
264
319
 
265
320
  # Prepare and execute HttpRequest.
266
321
  _request = config.http_client.post(
267
322
  _query_url,
268
- headers: _headers
323
+ headers: _headers,
324
+ parameters: body.to_json
269
325
  )
270
326
  OAuth2.apply(config, _request)
271
327
  _response = execute_request(_request)
@@ -273,7 +329,9 @@ module Square
273
329
  # Return appropriate response type.
274
330
  decoded = APIHelper.json_deserialize(_response.raw_body)
275
331
  _errors = APIHelper.map_response(decoded, ['errors'])
276
- ApiResponse.new(_response, data: decoded, errors: _errors)
332
+ ApiResponse.new(
333
+ _response, data: decoded, errors: _errors
334
+ )
277
335
  end
278
336
  end
279
337
  end
@@ -6,32 +6,42 @@ 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
+ # Results are eventually consistent, and new refunds or changes to refunds
10
+ # might take several
11
+ # seconds to appear.
12
+ # The maximum results per page is 100.
13
+ # @param [String] begin_time Optional parameter: The timestamp for the
14
+ # beginning of the requested reporting period, in RFC 3339 format. Default:
15
+ # The current time minus one year.
16
+ # @param [String] end_time Optional parameter: The timestamp for the end of
17
+ # the requested reporting period, in RFC 3339 format. Default: The current
15
18
  # time.
16
19
  # @param [String] sort_order Optional parameter: The order in which results
17
- # are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest
20
+ # are listed: - `ASC` - Oldest to newest. - `DESC` - Newest to oldest
18
21
  # (default).
19
22
  # @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
23
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
24
+ # set of results for the original query. For more information, see
22
25
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
23
- # for more information.
26
+ # .
24
27
  # @param [String] location_id Optional parameter: Limit results to the
25
28
  # location supplied. By default, results are returned for all locations
26
- # associated with the merchant.
29
+ # associated with the seller.
27
30
  # @param [String] status Optional parameter: If provided, only refunds with
28
31
  # 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.
31
- # @param [String] source_type Optional parameter: If provided, only refunds
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.
32
+ # [PaymentRefund]($m/PaymentRefund). Default: If omitted, refunds are
33
+ # returned regardless of their status.
34
+ # @param [String] source_type Optional parameter: If provided, only returns
35
+ # refunds whose payments have the indicated source type. Current values
36
+ # include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`. For
37
+ # information about these payment source types, see [Take
38
+ # Payments](https://developer.squareup.com/docs/payments-api/take-payments).
39
+ # Default: If omitted, refunds are returned regardless of the source
40
+ # type.
41
+ # @param [Integer] limit Optional parameter: The maximum number of results
42
+ # to be returned in a single page. It is possible to receive fewer results
43
+ # than the specified limit on a given page. If the supplied value is
44
+ # greater than 100, no more than 100 results are returned. Default: 100
35
45
  # @return [ListPaymentRefundsResponse Hash] response from the API call
36
46
  def list_payment_refunds(begin_time: nil,
37
47
  end_time: nil,
@@ -39,7 +49,8 @@ module Square
39
49
  cursor: nil,
40
50
  location_id: nil,
41
51
  status: nil,
42
- source_type: nil)
52
+ source_type: nil,
53
+ limit: nil)
43
54
  # Prepare query url.
44
55
  _query_builder = config.get_base_uri
45
56
  _query_builder << '/v2/refunds'
@@ -51,7 +62,8 @@ module Square
51
62
  'cursor' => cursor,
52
63
  'location_id' => location_id,
53
64
  'status' => status,
54
- 'source_type' => source_type
65
+ 'source_type' => source_type,
66
+ 'limit' => limit
55
67
  )
56
68
  _query_url = APIHelper.clean_url _query_builder
57
69
 
@@ -71,13 +83,18 @@ module Square
71
83
  # Return appropriate response type.
72
84
  decoded = APIHelper.json_deserialize(_response.raw_body)
73
85
  _errors = APIHelper.map_response(decoded, ['errors'])
74
- ApiResponse.new(_response, data: decoded, errors: _errors)
86
+ ApiResponse.new(
87
+ _response, data: decoded, errors: _errors
88
+ )
75
89
  end
76
90
 
77
91
  # 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).
92
+ # portion of it. You can use this endpoint to refund a card payment or
93
+ # record a
94
+ # refund of a cash or external payment. For more information, see
95
+ # [Refund
96
+ # Payment](https://developer.squareup.com/docs/payments-api/refund-payments)
97
+ # .
81
98
  # @param [RefundPaymentRequest] body Required parameter: An object
82
99
  # containing the fields to POST for the request. See the corresponding
83
100
  # object definition for field details.
@@ -91,7 +108,7 @@ module Square
91
108
  # Prepare headers.
92
109
  _headers = {
93
110
  'accept' => 'application/json',
94
- 'content-type' => 'application/json; charset=utf-8'
111
+ 'Content-Type' => 'application/json'
95
112
  }
96
113
 
97
114
  # Prepare and execute HttpRequest.
@@ -106,12 +123,14 @@ module Square
106
123
  # Return appropriate response type.
107
124
  decoded = APIHelper.json_deserialize(_response.raw_body)
108
125
  _errors = APIHelper.map_response(decoded, ['errors'])
109
- ApiResponse.new(_response, data: decoded, errors: _errors)
126
+ ApiResponse.new(
127
+ _response, data: decoded, errors: _errors
128
+ )
110
129
  end
111
130
 
112
- # Retrieves a specific `Refund` using the `refund_id`.
113
- # @param [String] refund_id Required parameter: Unique ID for the desired
114
- # `PaymentRefund`.
131
+ # Retrieves a specific refund using the `refund_id`.
132
+ # @param [String] refund_id Required parameter: The unique ID for the
133
+ # desired `PaymentRefund`.
115
134
  # @return [GetPaymentRefundResponse Hash] response from the API call
116
135
  def get_payment_refund(refund_id:)
117
136
  # Prepare query url.
@@ -119,7 +138,7 @@ module Square
119
138
  _query_builder << '/v2/refunds/{refund_id}'
120
139
  _query_builder = APIHelper.append_url_with_template_parameters(
121
140
  _query_builder,
122
- 'refund_id' => refund_id
141
+ 'refund_id' => { 'value' => refund_id, 'encode' => true }
123
142
  )
124
143
  _query_url = APIHelper.clean_url _query_builder
125
144
 
@@ -139,7 +158,9 @@ module Square
139
158
  # Return appropriate response type.
140
159
  decoded = APIHelper.json_deserialize(_response.raw_body)
141
160
  _errors = APIHelper.map_response(decoded, ['errors'])
142
- ApiResponse.new(_response, data: decoded, errors: _errors)
161
+ ApiResponse.new(
162
+ _response, data: decoded, errors: _errors
163
+ )
143
164
  end
144
165
  end
145
166
  end
@@ -0,0 +1,43 @@
1
+ module Square
2
+ # SitesApi
3
+ class SitesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists the Square Online sites that belong to a seller. Sites are listed in
9
+ # descending order by the `created_at` date.
10
+ # __Note:__ Square Online APIs are publicly available as part of an early
11
+ # access program. For more information, see [Early access program for Square
12
+ # Online
13
+ # APIs](https://developer.squareup.com/docs/online-api#early-access-program-
14
+ # for-square-online-apis).
15
+ # @return [ListSitesResponse Hash] response from the API call
16
+ def list_sites
17
+ # Prepare query url.
18
+ _query_builder = config.get_base_uri
19
+ _query_builder << '/v2/sites'
20
+ _query_url = APIHelper.clean_url _query_builder
21
+
22
+ # Prepare headers.
23
+ _headers = {
24
+ 'accept' => 'application/json'
25
+ }
26
+
27
+ # Prepare and execute HttpRequest.
28
+ _request = config.http_client.get(
29
+ _query_url,
30
+ headers: _headers
31
+ )
32
+ OAuth2.apply(config, _request)
33
+ _response = execute_request(_request)
34
+
35
+ # Return appropriate response type.
36
+ decoded = APIHelper.json_deserialize(_response.raw_body)
37
+ _errors = APIHelper.map_response(decoded, ['errors'])
38
+ ApiResponse.new(
39
+ _response, data: decoded, errors: _errors
40
+ )
41
+ end
42
+ end
43
+ end