square.rb 8.0.0.20201216 → 26.1.0.20230119
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +79 -221
- data/lib/square/api/apple_pay_api.rb +15 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +27 -9
- data/lib/square/api/booking_custom_attributes_api.rb +555 -0
- data/lib/square/api/bookings_api.rb +107 -15
- data/lib/square/api/cards_api.rb +171 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +167 -73
- data/lib/square/api/checkout_api.rb +205 -3
- data/lib/square/api/customer_custom_attributes_api.rb +561 -0
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +67 -33
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +109 -105
- data/lib/square/api/gift_card_activities_api.rb +132 -0
- data/lib/square/api/gift_cards_api.rb +298 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +21 -21
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/api/locations_api.rb +21 -14
- data/lib/square/api/loyalty_api.rb +333 -50
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +78 -25
- data/lib/square/api/order_custom_attributes_api.rb +601 -0
- data/lib/square/api/orders_api.rb +84 -45
- data/lib/square/api/payments_api.rb +72 -24
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -15
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +172 -22
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +52 -124
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api/webhook_subscriptions_api.rb +327 -0
- data/lib/square/api_helper.rb +217 -57
- data/lib/square/client.rb +90 -18
- data/lib/square/configuration.rb +64 -20
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +40 -9
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +56 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +2 -2
- metadata +83 -15
- data/lib/square/api/v1_employees_api.rb +0 -751
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -0,0 +1,327 @@
|
|
1
|
+
module Square
|
2
|
+
# WebhookSubscriptionsApi
|
3
|
+
class WebhookSubscriptionsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists all webhook event types that can be subscribed to.
|
9
|
+
# @param [String] api_version Optional parameter: The API version for which
|
10
|
+
# to list event types. Setting this field overrides the default version used
|
11
|
+
# by the application.
|
12
|
+
# @return [ListWebhookEventTypesResponse Hash] response from the API call
|
13
|
+
def list_webhook_event_types(api_version: nil)
|
14
|
+
# Prepare query url.
|
15
|
+
_query_builder = config.get_base_uri
|
16
|
+
_query_builder << '/v2/webhooks/event-types'
|
17
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
18
|
+
_query_builder,
|
19
|
+
'api_version' => api_version
|
20
|
+
)
|
21
|
+
_query_url = APIHelper.clean_url _query_builder
|
22
|
+
|
23
|
+
# Prepare headers.
|
24
|
+
_headers = {
|
25
|
+
'accept' => 'application/json'
|
26
|
+
}
|
27
|
+
|
28
|
+
# Prepare and execute HttpRequest.
|
29
|
+
_request = config.http_client.get(
|
30
|
+
_query_url,
|
31
|
+
headers: _headers
|
32
|
+
)
|
33
|
+
OAuth2.apply(config, _request)
|
34
|
+
_response = execute_request(_request)
|
35
|
+
|
36
|
+
# Return appropriate response type.
|
37
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
38
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
39
|
+
ApiResponse.new(
|
40
|
+
_response, data: decoded, errors: _errors
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Lists all webhook subscriptions owned by your application.
|
45
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
46
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
47
|
+
# results for your original query. For more information, see
|
48
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
49
|
+
# .
|
50
|
+
# @param [TrueClass|FalseClass] include_disabled Optional parameter:
|
51
|
+
# Includes disabled [Subscription]($m/WebhookSubscription)s. By default, all
|
52
|
+
# enabled [Subscription]($m/WebhookSubscription)s are returned.
|
53
|
+
# @param [SortOrder] sort_order Optional parameter: Sorts the returned list
|
54
|
+
# by when the [Subscription]($m/WebhookSubscription) was created with the
|
55
|
+
# specified order. This field defaults to ASC.
|
56
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
57
|
+
# to be returned in a single page. It is possible to receive fewer results
|
58
|
+
# than the specified limit on a given page. The default value of 100 is also
|
59
|
+
# the maximum allowed value. Default: 100
|
60
|
+
# @return [ListWebhookSubscriptionsResponse Hash] response from the API call
|
61
|
+
def list_webhook_subscriptions(cursor: nil,
|
62
|
+
include_disabled: false,
|
63
|
+
sort_order: nil,
|
64
|
+
limit: nil)
|
65
|
+
# Prepare query url.
|
66
|
+
_query_builder = config.get_base_uri
|
67
|
+
_query_builder << '/v2/webhooks/subscriptions'
|
68
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
69
|
+
_query_builder,
|
70
|
+
'cursor' => cursor,
|
71
|
+
'include_disabled' => include_disabled,
|
72
|
+
'sort_order' => sort_order,
|
73
|
+
'limit' => limit
|
74
|
+
)
|
75
|
+
_query_url = APIHelper.clean_url _query_builder
|
76
|
+
|
77
|
+
# Prepare headers.
|
78
|
+
_headers = {
|
79
|
+
'accept' => 'application/json'
|
80
|
+
}
|
81
|
+
|
82
|
+
# Prepare and execute HttpRequest.
|
83
|
+
_request = config.http_client.get(
|
84
|
+
_query_url,
|
85
|
+
headers: _headers
|
86
|
+
)
|
87
|
+
OAuth2.apply(config, _request)
|
88
|
+
_response = execute_request(_request)
|
89
|
+
|
90
|
+
# Return appropriate response type.
|
91
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
92
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
93
|
+
ApiResponse.new(
|
94
|
+
_response, data: decoded, errors: _errors
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Creates a webhook subscription.
|
99
|
+
# @param [CreateWebhookSubscriptionRequest] body Required parameter: An
|
100
|
+
# object containing the fields to POST for the request. See the
|
101
|
+
# corresponding object definition for field details.
|
102
|
+
# @return [CreateWebhookSubscriptionResponse Hash] response from the API call
|
103
|
+
def create_webhook_subscription(body:)
|
104
|
+
# Prepare query url.
|
105
|
+
_query_builder = config.get_base_uri
|
106
|
+
_query_builder << '/v2/webhooks/subscriptions'
|
107
|
+
_query_url = APIHelper.clean_url _query_builder
|
108
|
+
|
109
|
+
# Prepare headers.
|
110
|
+
_headers = {
|
111
|
+
'accept' => 'application/json',
|
112
|
+
'Content-Type' => 'application/json'
|
113
|
+
}
|
114
|
+
|
115
|
+
# Prepare and execute HttpRequest.
|
116
|
+
_request = config.http_client.post(
|
117
|
+
_query_url,
|
118
|
+
headers: _headers,
|
119
|
+
parameters: body.to_json
|
120
|
+
)
|
121
|
+
OAuth2.apply(config, _request)
|
122
|
+
_response = execute_request(_request)
|
123
|
+
|
124
|
+
# Return appropriate response type.
|
125
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
126
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
127
|
+
ApiResponse.new(
|
128
|
+
_response, data: decoded, errors: _errors
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deletes a webhook subscription.
|
133
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
134
|
+
# the [Subscription]($m/WebhookSubscription) to delete.
|
135
|
+
# @return [DeleteWebhookSubscriptionResponse Hash] response from the API call
|
136
|
+
def delete_webhook_subscription(subscription_id:)
|
137
|
+
# Prepare query url.
|
138
|
+
_query_builder = config.get_base_uri
|
139
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}'
|
140
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
141
|
+
_query_builder,
|
142
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
143
|
+
)
|
144
|
+
_query_url = APIHelper.clean_url _query_builder
|
145
|
+
|
146
|
+
# Prepare headers.
|
147
|
+
_headers = {
|
148
|
+
'accept' => 'application/json'
|
149
|
+
}
|
150
|
+
|
151
|
+
# Prepare and execute HttpRequest.
|
152
|
+
_request = config.http_client.delete(
|
153
|
+
_query_url,
|
154
|
+
headers: _headers
|
155
|
+
)
|
156
|
+
OAuth2.apply(config, _request)
|
157
|
+
_response = execute_request(_request)
|
158
|
+
|
159
|
+
# Return appropriate response type.
|
160
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
161
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
162
|
+
ApiResponse.new(
|
163
|
+
_response, data: decoded, errors: _errors
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Retrieves a webhook subscription identified by its ID.
|
168
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
169
|
+
# the [Subscription]($m/WebhookSubscription) to retrieve.
|
170
|
+
# @return [RetrieveWebhookSubscriptionResponse Hash] response from the API call
|
171
|
+
def retrieve_webhook_subscription(subscription_id:)
|
172
|
+
# Prepare query url.
|
173
|
+
_query_builder = config.get_base_uri
|
174
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}'
|
175
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
178
|
+
)
|
179
|
+
_query_url = APIHelper.clean_url _query_builder
|
180
|
+
|
181
|
+
# Prepare headers.
|
182
|
+
_headers = {
|
183
|
+
'accept' => 'application/json'
|
184
|
+
}
|
185
|
+
|
186
|
+
# Prepare and execute HttpRequest.
|
187
|
+
_request = config.http_client.get(
|
188
|
+
_query_url,
|
189
|
+
headers: _headers
|
190
|
+
)
|
191
|
+
OAuth2.apply(config, _request)
|
192
|
+
_response = execute_request(_request)
|
193
|
+
|
194
|
+
# Return appropriate response type.
|
195
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
196
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
197
|
+
ApiResponse.new(
|
198
|
+
_response, data: decoded, errors: _errors
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Updates a webhook subscription.
|
203
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
204
|
+
# the [Subscription]($m/WebhookSubscription) to update.
|
205
|
+
# @param [UpdateWebhookSubscriptionRequest] body Required parameter: An
|
206
|
+
# object containing the fields to POST for the request. See the
|
207
|
+
# corresponding object definition for field details.
|
208
|
+
# @return [UpdateWebhookSubscriptionResponse Hash] response from the API call
|
209
|
+
def update_webhook_subscription(subscription_id:,
|
210
|
+
body:)
|
211
|
+
# Prepare query url.
|
212
|
+
_query_builder = config.get_base_uri
|
213
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}'
|
214
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
215
|
+
_query_builder,
|
216
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
217
|
+
)
|
218
|
+
_query_url = APIHelper.clean_url _query_builder
|
219
|
+
|
220
|
+
# Prepare headers.
|
221
|
+
_headers = {
|
222
|
+
'accept' => 'application/json',
|
223
|
+
'Content-Type' => 'application/json'
|
224
|
+
}
|
225
|
+
|
226
|
+
# Prepare and execute HttpRequest.
|
227
|
+
_request = config.http_client.put(
|
228
|
+
_query_url,
|
229
|
+
headers: _headers,
|
230
|
+
parameters: body.to_json
|
231
|
+
)
|
232
|
+
OAuth2.apply(config, _request)
|
233
|
+
_response = execute_request(_request)
|
234
|
+
|
235
|
+
# Return appropriate response type.
|
236
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
237
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
238
|
+
ApiResponse.new(
|
239
|
+
_response, data: decoded, errors: _errors
|
240
|
+
)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Updates a webhook subscription by replacing the existing signature key
|
244
|
+
# with a new one.
|
245
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
246
|
+
# the [Subscription]($m/WebhookSubscription) to update.
|
247
|
+
# @param [UpdateWebhookSubscriptionSignatureKeyRequest] body Required
|
248
|
+
# parameter: An object containing the fields to POST for the request. See
|
249
|
+
# the corresponding object definition for field details.
|
250
|
+
# @return [UpdateWebhookSubscriptionSignatureKeyResponse Hash] response from the API call
|
251
|
+
def update_webhook_subscription_signature_key(subscription_id:,
|
252
|
+
body:)
|
253
|
+
# Prepare query url.
|
254
|
+
_query_builder = config.get_base_uri
|
255
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}/signature-key'
|
256
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
257
|
+
_query_builder,
|
258
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
259
|
+
)
|
260
|
+
_query_url = APIHelper.clean_url _query_builder
|
261
|
+
|
262
|
+
# Prepare headers.
|
263
|
+
_headers = {
|
264
|
+
'accept' => 'application/json',
|
265
|
+
'Content-Type' => 'application/json'
|
266
|
+
}
|
267
|
+
|
268
|
+
# Prepare and execute HttpRequest.
|
269
|
+
_request = config.http_client.post(
|
270
|
+
_query_url,
|
271
|
+
headers: _headers,
|
272
|
+
parameters: body.to_json
|
273
|
+
)
|
274
|
+
OAuth2.apply(config, _request)
|
275
|
+
_response = execute_request(_request)
|
276
|
+
|
277
|
+
# Return appropriate response type.
|
278
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
279
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
280
|
+
ApiResponse.new(
|
281
|
+
_response, data: decoded, errors: _errors
|
282
|
+
)
|
283
|
+
end
|
284
|
+
|
285
|
+
# Tests a webhook subscription by sending a test event to the notification
|
286
|
+
# URL.
|
287
|
+
# @param [String] subscription_id Required parameter: [REQUIRED] The ID of
|
288
|
+
# the [Subscription]($m/WebhookSubscription) to test.
|
289
|
+
# @param [TestWebhookSubscriptionRequest] body Required parameter: An object
|
290
|
+
# containing the fields to POST for the request. See the corresponding
|
291
|
+
# object definition for field details.
|
292
|
+
# @return [TestWebhookSubscriptionResponse Hash] response from the API call
|
293
|
+
def test_webhook_subscription(subscription_id:,
|
294
|
+
body:)
|
295
|
+
# Prepare query url.
|
296
|
+
_query_builder = config.get_base_uri
|
297
|
+
_query_builder << '/v2/webhooks/subscriptions/{subscription_id}/test'
|
298
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
299
|
+
_query_builder,
|
300
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
301
|
+
)
|
302
|
+
_query_url = APIHelper.clean_url _query_builder
|
303
|
+
|
304
|
+
# Prepare headers.
|
305
|
+
_headers = {
|
306
|
+
'accept' => 'application/json',
|
307
|
+
'Content-Type' => 'application/json'
|
308
|
+
}
|
309
|
+
|
310
|
+
# Prepare and execute HttpRequest.
|
311
|
+
_request = config.http_client.post(
|
312
|
+
_query_url,
|
313
|
+
headers: _headers,
|
314
|
+
parameters: body.to_json
|
315
|
+
)
|
316
|
+
OAuth2.apply(config, _request)
|
317
|
+
_response = execute_request(_request)
|
318
|
+
|
319
|
+
# Return appropriate response type.
|
320
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
321
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
322
|
+
ApiResponse.new(
|
323
|
+
_response, data: decoded, errors: _errors
|
324
|
+
)
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|