square.rb 33.0.0.20231018 → 42.1.0.20250416

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/square/api/apple_pay_api.rb +15 -11
  4. data/lib/square/api/bank_accounts_api.rb +12 -12
  5. data/lib/square/api/base_api.rb +2 -1
  6. data/lib/square/api/booking_custom_attributes_api.rb +44 -44
  7. data/lib/square/api/bookings_api.rb +53 -53
  8. data/lib/square/api/cards_api.rb +16 -16
  9. data/lib/square/api/cash_drawers_api.rb +12 -12
  10. data/lib/square/api/catalog_api.rb +67 -57
  11. data/lib/square/api/checkout_api.rb +111 -26
  12. data/lib/square/api/customer_custom_attributes_api.rb +40 -40
  13. data/lib/square/api/customer_groups_api.rb +20 -20
  14. data/lib/square/api/customer_segments_api.rb +8 -8
  15. data/lib/square/api/customers_api.rb +144 -54
  16. data/lib/square/api/devices_api.rb +20 -20
  17. data/lib/square/api/disputes_api.rb +36 -36
  18. data/lib/square/api/employees_api.rb +8 -8
  19. data/lib/square/api/events_api.rb +84 -0
  20. data/lib/square/api/gift_card_activities_api.rb +10 -11
  21. data/lib/square/api/gift_cards_api.rb +36 -33
  22. data/lib/square/api/inventory_api.rb +52 -52
  23. data/lib/square/api/invoices_api.rb +109 -41
  24. data/lib/square/api/labor_api.rb +81 -80
  25. data/lib/square/api/location_custom_attributes_api.rb +44 -44
  26. data/lib/square/api/locations_api.rb +18 -17
  27. data/lib/square/api/loyalty_api.rb +72 -72
  28. data/lib/square/api/merchant_custom_attributes_api.rb +44 -44
  29. data/lib/square/api/merchants_api.rb +8 -8
  30. data/lib/square/api/mobile_authorization_api.rb +4 -4
  31. data/lib/square/api/o_auth_api.rb +15 -69
  32. data/lib/square/api/order_custom_attributes_api.rb +44 -44
  33. data/lib/square/api/orders_api.rb +32 -32
  34. data/lib/square/api/payments_api.rb +67 -31
  35. data/lib/square/api/payouts_api.rb +12 -12
  36. data/lib/square/api/refunds_api.rb +31 -13
  37. data/lib/square/api/sites_api.rb +4 -4
  38. data/lib/square/api/snippets_api.rb +12 -12
  39. data/lib/square/api/subscriptions_api.rb +48 -48
  40. data/lib/square/api/team_api.rb +146 -40
  41. data/lib/square/api/terminal_api.rb +95 -53
  42. data/lib/square/api/transactions_api.rb +16 -16
  43. data/lib/square/api/v1_transactions_api.rb +13 -292
  44. data/lib/square/api/vendors_api.rb +28 -28
  45. data/lib/square/api/webhook_subscriptions_api.rb +32 -32
  46. data/lib/square/client.rb +32 -24
  47. data/lib/square/configuration.rb +43 -15
  48. data/lib/square/http/api_response.rb +1 -1
  49. data/lib/square/http/auth/o_auth2.rb +21 -2
  50. data/lib/square.rb +4 -3
  51. data/test/api/api_test_base.rb +1 -1
  52. data/test/api/test_locations_api.rb +1 -1
  53. data/test/api/test_refunds_api.rb +4 -1
  54. data/test/webhooks/test_webhooks_helper.rb +17 -0
  55. metadata +12 -17
@@ -5,7 +5,7 @@ module Square
5
5
  # @param [CreateTerminalActionRequest] body Required parameter: An object
6
6
  # containing the fields to POST for the request. See the corresponding
7
7
  # object definition for field details.
8
- # @return [CreateTerminalActionResponse Hash] response from the API call
8
+ # @return [ApiResponse] the complete http response with raw body and status code.
9
9
  def create_terminal_action(body:)
10
10
  new_api_call_builder
11
11
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -17,9 +17,9 @@ module Square
17
17
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
18
18
  .auth(Single.new('global')))
19
19
  .response(new_response_handler
20
- .deserializer(APIHelper.method(:json_deserialize))
21
- .is_api_response(true)
22
- .convertor(ApiResponse.method(:create)))
20
+ .deserializer(APIHelper.method(:json_deserialize))
21
+ .is_api_response(true)
22
+ .convertor(ApiResponse.method(:create)))
23
23
  .execute
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ module Square
29
29
  # @param [SearchTerminalActionsRequest] body Required parameter: An object
30
30
  # containing the fields to POST for the request. See the corresponding
31
31
  # object definition for field details.
32
- # @return [SearchTerminalActionsResponse Hash] response from the API call
32
+ # @return [ApiResponse] the complete http response with raw body and status code.
33
33
  def search_terminal_actions(body:)
34
34
  new_api_call_builder
35
35
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -41,9 +41,9 @@ module Square
41
41
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
42
42
  .auth(Single.new('global')))
43
43
  .response(new_response_handler
44
- .deserializer(APIHelper.method(:json_deserialize))
45
- .is_api_response(true)
46
- .convertor(ApiResponse.method(:create)))
44
+ .deserializer(APIHelper.method(:json_deserialize))
45
+ .is_api_response(true)
46
+ .convertor(ApiResponse.method(:create)))
47
47
  .execute
48
48
  end
49
49
 
@@ -51,7 +51,7 @@ module Square
51
51
  # requests are available for 30 days.
52
52
  # @param [String] action_id Required parameter: Unique ID for the desired
53
53
  # `TerminalAction`.
54
- # @return [GetTerminalActionResponse Hash] response from the API call
54
+ # @return [ApiResponse] the complete http response with raw body and status code.
55
55
  def get_terminal_action(action_id:)
56
56
  new_api_call_builder
57
57
  .request(new_request_builder(HttpMethodEnum::GET,
@@ -62,16 +62,16 @@ module Square
62
62
  .header_param(new_parameter('application/json', key: 'accept'))
63
63
  .auth(Single.new('global')))
64
64
  .response(new_response_handler
65
- .deserializer(APIHelper.method(:json_deserialize))
66
- .is_api_response(true)
67
- .convertor(ApiResponse.method(:create)))
65
+ .deserializer(APIHelper.method(:json_deserialize))
66
+ .is_api_response(true)
67
+ .convertor(ApiResponse.method(:create)))
68
68
  .execute
69
69
  end
70
70
 
71
71
  # Cancels a Terminal action request if the status of the request permits it.
72
72
  # @param [String] action_id Required parameter: Unique ID for the desired
73
73
  # `TerminalAction`.
74
- # @return [CancelTerminalActionResponse Hash] response from the API call
74
+ # @return [ApiResponse] the complete http response with raw body and status code.
75
75
  def cancel_terminal_action(action_id:)
76
76
  new_api_call_builder
77
77
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -82,9 +82,9 @@ module Square
82
82
  .header_param(new_parameter('application/json', key: 'accept'))
83
83
  .auth(Single.new('global')))
84
84
  .response(new_response_handler
85
- .deserializer(APIHelper.method(:json_deserialize))
86
- .is_api_response(true)
87
- .convertor(ApiResponse.method(:create)))
85
+ .deserializer(APIHelper.method(:json_deserialize))
86
+ .is_api_response(true)
87
+ .convertor(ApiResponse.method(:create)))
88
88
  .execute
89
89
  end
90
90
 
@@ -94,8 +94,8 @@ module Square
94
94
  # Actions](https://developer.squareup.com/docs/terminal-api/advanced-feature
95
95
  # s/custom-workflows/link-and-dismiss-actions) for more details.
96
96
  # @param [String] action_id Required parameter: Unique ID for the
97
- # `TerminalAction` associated with the waiting dialog to be dismissed.
98
- # @return [DismissTerminalActionResponse Hash] response from the API call
97
+ # `TerminalAction` associated with the action to be dismissed.
98
+ # @return [ApiResponse] the complete http response with raw body and status code.
99
99
  def dismiss_terminal_action(action_id:)
100
100
  new_api_call_builder
101
101
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -106,9 +106,9 @@ module Square
106
106
  .header_param(new_parameter('application/json', key: 'accept'))
107
107
  .auth(Single.new('global')))
108
108
  .response(new_response_handler
109
- .deserializer(APIHelper.method(:json_deserialize))
110
- .is_api_response(true)
111
- .convertor(ApiResponse.method(:create)))
109
+ .deserializer(APIHelper.method(:json_deserialize))
110
+ .is_api_response(true)
111
+ .convertor(ApiResponse.method(:create)))
112
112
  .execute
113
113
  end
114
114
 
@@ -118,7 +118,7 @@ module Square
118
118
  # @param [CreateTerminalCheckoutRequest] body Required parameter: An object
119
119
  # containing the fields to POST for the request. See the corresponding
120
120
  # object definition for field details.
121
- # @return [CreateTerminalCheckoutResponse Hash] response from the API call
121
+ # @return [ApiResponse] the complete http response with raw body and status code.
122
122
  def create_terminal_checkout(body:)
123
123
  new_api_call_builder
124
124
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -130,9 +130,9 @@ module Square
130
130
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
131
131
  .auth(Single.new('global')))
132
132
  .response(new_response_handler
133
- .deserializer(APIHelper.method(:json_deserialize))
134
- .is_api_response(true)
135
- .convertor(ApiResponse.method(:create)))
133
+ .deserializer(APIHelper.method(:json_deserialize))
134
+ .is_api_response(true)
135
+ .convertor(ApiResponse.method(:create)))
136
136
  .execute
137
137
  end
138
138
 
@@ -143,7 +143,7 @@ module Square
143
143
  # @param [SearchTerminalCheckoutsRequest] body Required parameter: An object
144
144
  # containing the fields to POST for the request. See the corresponding
145
145
  # object definition for field details.
146
- # @return [SearchTerminalCheckoutsResponse Hash] response from the API call
146
+ # @return [ApiResponse] the complete http response with raw body and status code.
147
147
  def search_terminal_checkouts(body:)
148
148
  new_api_call_builder
149
149
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -155,9 +155,9 @@ module Square
155
155
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
156
156
  .auth(Single.new('global')))
157
157
  .response(new_response_handler
158
- .deserializer(APIHelper.method(:json_deserialize))
159
- .is_api_response(true)
160
- .convertor(ApiResponse.method(:create)))
158
+ .deserializer(APIHelper.method(:json_deserialize))
159
+ .is_api_response(true)
160
+ .convertor(ApiResponse.method(:create)))
161
161
  .execute
162
162
  end
163
163
 
@@ -165,7 +165,7 @@ module Square
165
165
  # requests are available for 30 days.
166
166
  # @param [String] checkout_id Required parameter: The unique ID for the
167
167
  # desired `TerminalCheckout`.
168
- # @return [GetTerminalCheckoutResponse Hash] response from the API call
168
+ # @return [ApiResponse] the complete http response with raw body and status code.
169
169
  def get_terminal_checkout(checkout_id:)
170
170
  new_api_call_builder
171
171
  .request(new_request_builder(HttpMethodEnum::GET,
@@ -176,9 +176,9 @@ module Square
176
176
  .header_param(new_parameter('application/json', key: 'accept'))
177
177
  .auth(Single.new('global')))
178
178
  .response(new_response_handler
179
- .deserializer(APIHelper.method(:json_deserialize))
180
- .is_api_response(true)
181
- .convertor(ApiResponse.method(:create)))
179
+ .deserializer(APIHelper.method(:json_deserialize))
180
+ .is_api_response(true)
181
+ .convertor(ApiResponse.method(:create)))
182
182
  .execute
183
183
  end
184
184
 
@@ -186,7 +186,7 @@ module Square
186
186
  # it.
187
187
  # @param [String] checkout_id Required parameter: The unique ID for the
188
188
  # desired `TerminalCheckout`.
189
- # @return [CancelTerminalCheckoutResponse Hash] response from the API call
189
+ # @return [ApiResponse] the complete http response with raw body and status code.
190
190
  def cancel_terminal_checkout(checkout_id:)
191
191
  new_api_call_builder
192
192
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -197,9 +197,30 @@ module Square
197
197
  .header_param(new_parameter('application/json', key: 'accept'))
198
198
  .auth(Single.new('global')))
199
199
  .response(new_response_handler
200
- .deserializer(APIHelper.method(:json_deserialize))
201
- .is_api_response(true)
202
- .convertor(ApiResponse.method(:create)))
200
+ .deserializer(APIHelper.method(:json_deserialize))
201
+ .is_api_response(true)
202
+ .convertor(ApiResponse.method(:create)))
203
+ .execute
204
+ end
205
+
206
+ # Dismisses a Terminal checkout request if the status and type of the
207
+ # request permits it.
208
+ # @param [String] checkout_id Required parameter: Unique ID for the
209
+ # `TerminalCheckout` associated with the checkout to be dismissed.
210
+ # @return [ApiResponse] the complete http response with raw body and status code.
211
+ def dismiss_terminal_checkout(checkout_id:)
212
+ new_api_call_builder
213
+ .request(new_request_builder(HttpMethodEnum::POST,
214
+ '/v2/terminals/checkouts/{checkout_id}/dismiss',
215
+ 'default')
216
+ .template_param(new_parameter(checkout_id, key: 'checkout_id')
217
+ .should_encode(true))
218
+ .header_param(new_parameter('application/json', key: 'accept'))
219
+ .auth(Single.new('global')))
220
+ .response(new_response_handler
221
+ .deserializer(APIHelper.method(:json_deserialize))
222
+ .is_api_response(true)
223
+ .convertor(ApiResponse.method(:create)))
203
224
  .execute
204
225
  end
205
226
 
@@ -211,7 +232,7 @@ module Square
211
232
  # @param [CreateTerminalRefundRequest] body Required parameter: An object
212
233
  # containing the fields to POST for the request. See the corresponding
213
234
  # object definition for field details.
214
- # @return [CreateTerminalRefundResponse Hash] response from the API call
235
+ # @return [ApiResponse] the complete http response with raw body and status code.
215
236
  def create_terminal_refund(body:)
216
237
  new_api_call_builder
217
238
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -223,9 +244,9 @@ module Square
223
244
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
224
245
  .auth(Single.new('global')))
225
246
  .response(new_response_handler
226
- .deserializer(APIHelper.method(:json_deserialize))
227
- .is_api_response(true)
228
- .convertor(ApiResponse.method(:create)))
247
+ .deserializer(APIHelper.method(:json_deserialize))
248
+ .is_api_response(true)
249
+ .convertor(ApiResponse.method(:create)))
229
250
  .execute
230
251
  end
231
252
 
@@ -235,7 +256,7 @@ module Square
235
256
  # @param [SearchTerminalRefundsRequest] body Required parameter: An object
236
257
  # containing the fields to POST for the request. See the corresponding
237
258
  # object definition for field details.
238
- # @return [SearchTerminalRefundsResponse Hash] response from the API call
259
+ # @return [ApiResponse] the complete http response with raw body and status code.
239
260
  def search_terminal_refunds(body:)
240
261
  new_api_call_builder
241
262
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -247,9 +268,9 @@ module Square
247
268
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
248
269
  .auth(Single.new('global')))
249
270
  .response(new_response_handler
250
- .deserializer(APIHelper.method(:json_deserialize))
251
- .is_api_response(true)
252
- .convertor(ApiResponse.method(:create)))
271
+ .deserializer(APIHelper.method(:json_deserialize))
272
+ .is_api_response(true)
273
+ .convertor(ApiResponse.method(:create)))
253
274
  .execute
254
275
  end
255
276
 
@@ -257,7 +278,7 @@ module Square
257
278
  # are available for 30 days.
258
279
  # @param [String] terminal_refund_id Required parameter: The unique ID for
259
280
  # the desired `TerminalRefund`.
260
- # @return [GetTerminalRefundResponse Hash] response from the API call
281
+ # @return [ApiResponse] the complete http response with raw body and status code.
261
282
  def get_terminal_refund(terminal_refund_id:)
262
283
  new_api_call_builder
263
284
  .request(new_request_builder(HttpMethodEnum::GET,
@@ -268,9 +289,9 @@ module Square
268
289
  .header_param(new_parameter('application/json', key: 'accept'))
269
290
  .auth(Single.new('global')))
270
291
  .response(new_response_handler
271
- .deserializer(APIHelper.method(:json_deserialize))
272
- .is_api_response(true)
273
- .convertor(ApiResponse.method(:create)))
292
+ .deserializer(APIHelper.method(:json_deserialize))
293
+ .is_api_response(true)
294
+ .convertor(ApiResponse.method(:create)))
274
295
  .execute
275
296
  end
276
297
 
@@ -278,7 +299,7 @@ module Square
278
299
  # status of the request permits it.
279
300
  # @param [String] terminal_refund_id Required parameter: The unique ID for
280
301
  # the desired `TerminalRefund`.
281
- # @return [CancelTerminalRefundResponse Hash] response from the API call
302
+ # @return [ApiResponse] the complete http response with raw body and status code.
282
303
  def cancel_terminal_refund(terminal_refund_id:)
283
304
  new_api_call_builder
284
305
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -289,9 +310,30 @@ module Square
289
310
  .header_param(new_parameter('application/json', key: 'accept'))
290
311
  .auth(Single.new('global')))
291
312
  .response(new_response_handler
292
- .deserializer(APIHelper.method(:json_deserialize))
293
- .is_api_response(true)
294
- .convertor(ApiResponse.method(:create)))
313
+ .deserializer(APIHelper.method(:json_deserialize))
314
+ .is_api_response(true)
315
+ .convertor(ApiResponse.method(:create)))
316
+ .execute
317
+ end
318
+
319
+ # Dismisses a Terminal refund request if the status and type of the request
320
+ # permits it.
321
+ # @param [String] terminal_refund_id Required parameter: Unique ID for the
322
+ # `TerminalRefund` associated with the refund to be dismissed.
323
+ # @return [ApiResponse] the complete http response with raw body and status code.
324
+ def dismiss_terminal_refund(terminal_refund_id:)
325
+ new_api_call_builder
326
+ .request(new_request_builder(HttpMethodEnum::POST,
327
+ '/v2/terminals/refunds/{terminal_refund_id}/dismiss',
328
+ 'default')
329
+ .template_param(new_parameter(terminal_refund_id, key: 'terminal_refund_id')
330
+ .should_encode(true))
331
+ .header_param(new_parameter('application/json', key: 'accept'))
332
+ .auth(Single.new('global')))
333
+ .response(new_response_handler
334
+ .deserializer(APIHelper.method(:json_deserialize))
335
+ .is_api_response(true)
336
+ .convertor(ApiResponse.method(:create)))
295
337
  .execute
296
338
  end
297
339
  end
@@ -28,7 +28,7 @@ module Square
28
28
  # results for your original query. See [Paginating
29
29
  # results](https://developer.squareup.com/docs/working-with-apis/pagination)
30
30
  # for more information.
31
- # @return [ListTransactionsResponse Hash] response from the API call
31
+ # @return [ApiResponse] the complete http response with raw body and status code.
32
32
  def list_transactions(location_id:,
33
33
  begin_time: nil,
34
34
  end_time: nil,
@@ -48,9 +48,9 @@ module Square
48
48
  .header_param(new_parameter('application/json', key: 'accept'))
49
49
  .auth(Single.new('global')))
50
50
  .response(new_response_handler
51
- .deserializer(APIHelper.method(:json_deserialize))
52
- .is_api_response(true)
53
- .convertor(ApiResponse.method(:create)))
51
+ .deserializer(APIHelper.method(:json_deserialize))
52
+ .is_api_response(true)
53
+ .convertor(ApiResponse.method(:create)))
54
54
  .execute
55
55
  end
56
56
 
@@ -59,7 +59,7 @@ module Square
59
59
  # transaction's associated location.
60
60
  # @param [String] transaction_id Required parameter: The ID of the
61
61
  # transaction to retrieve.
62
- # @return [RetrieveTransactionResponse Hash] response from the API call
62
+ # @return [ApiResponse] the complete http response with raw body and status code.
63
63
  def retrieve_transaction(location_id:,
64
64
  transaction_id:)
65
65
  warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
@@ -74,9 +74,9 @@ module Square
74
74
  .header_param(new_parameter('application/json', key: 'accept'))
75
75
  .auth(Single.new('global')))
76
76
  .response(new_response_handler
77
- .deserializer(APIHelper.method(:json_deserialize))
78
- .is_api_response(true)
79
- .convertor(ApiResponse.method(:create)))
77
+ .deserializer(APIHelper.method(:json_deserialize))
78
+ .is_api_response(true)
79
+ .convertor(ApiResponse.method(:create)))
80
80
  .execute
81
81
  end
82
82
 
@@ -89,7 +89,7 @@ module Square
89
89
  # for more information.
90
90
  # @param [String] location_id Required parameter: Example:
91
91
  # @param [String] transaction_id Required parameter: Example:
92
- # @return [CaptureTransactionResponse Hash] response from the API call
92
+ # @return [ApiResponse] the complete http response with raw body and status code.
93
93
  def capture_transaction(location_id:,
94
94
  transaction_id:)
95
95
  warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
@@ -104,9 +104,9 @@ module Square
104
104
  .header_param(new_parameter('application/json', key: 'accept'))
105
105
  .auth(Single.new('global')))
106
106
  .response(new_response_handler
107
- .deserializer(APIHelper.method(:json_deserialize))
108
- .is_api_response(true)
109
- .convertor(ApiResponse.method(:create)))
107
+ .deserializer(APIHelper.method(:json_deserialize))
108
+ .is_api_response(true)
109
+ .convertor(ApiResponse.method(:create)))
110
110
  .execute
111
111
  end
112
112
 
@@ -119,7 +119,7 @@ module Square
119
119
  # for more information.
120
120
  # @param [String] location_id Required parameter: Example:
121
121
  # @param [String] transaction_id Required parameter: Example:
122
- # @return [VoidTransactionResponse Hash] response from the API call
122
+ # @return [ApiResponse] the complete http response with raw body and status code.
123
123
  def void_transaction(location_id:,
124
124
  transaction_id:)
125
125
  warn 'Endpoint void_transaction in TransactionsApi is deprecated'
@@ -134,9 +134,9 @@ module Square
134
134
  .header_param(new_parameter('application/json', key: 'accept'))
135
135
  .auth(Single.new('global')))
136
136
  .response(new_response_handler
137
- .deserializer(APIHelper.method(:json_deserialize))
138
- .is_api_response(true)
139
- .convertor(ApiResponse.method(:create)))
137
+ .deserializer(APIHelper.method(:json_deserialize))
138
+ .is_api_response(true)
139
+ .convertor(ApiResponse.method(:create)))
140
140
  .execute
141
141
  end
142
142
  end