square.rb 26.0.0.20221214 → 26.2.0.20230315
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/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +419 -0
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +82 -46
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +7 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +12 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,44 +1,24 @@
|
|
1
1
|
module Square
|
2
2
|
# WebhookSubscriptionsApi
|
3
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
4
|
# Lists all webhook event types that can be subscribed to.
|
9
5
|
# @param [String] api_version Optional parameter: The API version for which
|
10
6
|
# to list event types. Setting this field overrides the default version used
|
11
7
|
# by the application.
|
12
8
|
# @return [ListWebhookEventTypesResponse Hash] response from the API call
|
13
9
|
def list_webhook_event_types(api_version: nil)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
)
|
10
|
+
new_api_call_builder
|
11
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
12
|
+
'/v2/webhooks/event-types',
|
13
|
+
'default')
|
14
|
+
.query_param(new_parameter(api_version, key: 'api_version'))
|
15
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
16
|
+
.auth(Single.new('global')))
|
17
|
+
.response(new_response_handler
|
18
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
19
|
+
.is_api_response(true)
|
20
|
+
.convertor(ApiResponse.method(:create)))
|
21
|
+
.execute
|
42
22
|
end
|
43
23
|
|
44
24
|
# Lists all webhook subscriptions owned by your application.
|
@@ -62,37 +42,21 @@ module Square
|
|
62
42
|
include_disabled: false,
|
63
43
|
sort_order: nil,
|
64
44
|
limit: nil)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
)
|
45
|
+
new_api_call_builder
|
46
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
47
|
+
'/v2/webhooks/subscriptions',
|
48
|
+
'default')
|
49
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
50
|
+
.query_param(new_parameter(include_disabled, key: 'include_disabled'))
|
51
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
52
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
53
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
54
|
+
.auth(Single.new('global')))
|
55
|
+
.response(new_response_handler
|
56
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
57
|
+
.is_api_response(true)
|
58
|
+
.convertor(ApiResponse.method(:create)))
|
59
|
+
.execute
|
96
60
|
end
|
97
61
|
|
98
62
|
# Creates a webhook subscription.
|
@@ -101,32 +65,20 @@ module Square
|
|
101
65
|
# corresponding object definition for field details.
|
102
66
|
# @return [CreateWebhookSubscriptionResponse Hash] response from the API call
|
103
67
|
def create_webhook_subscription(body:)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
)
|
68
|
+
new_api_call_builder
|
69
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
70
|
+
'/v2/webhooks/subscriptions',
|
71
|
+
'default')
|
72
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
73
|
+
.body_param(new_parameter(body))
|
74
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
75
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
76
|
+
.auth(Single.new('global')))
|
77
|
+
.response(new_response_handler
|
78
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
79
|
+
.is_api_response(true)
|
80
|
+
.convertor(ApiResponse.method(:create)))
|
81
|
+
.execute
|
130
82
|
end
|
131
83
|
|
132
84
|
# Deletes a webhook subscription.
|
@@ -134,34 +86,19 @@ module Square
|
|
134
86
|
# the [Subscription]($m/WebhookSubscription) to delete.
|
135
87
|
# @return [DeleteWebhookSubscriptionResponse Hash] response from the API call
|
136
88
|
def delete_webhook_subscription(subscription_id:)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
-
)
|
89
|
+
new_api_call_builder
|
90
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
91
|
+
'/v2/webhooks/subscriptions/{subscription_id}',
|
92
|
+
'default')
|
93
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
94
|
+
.should_encode(true))
|
95
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
96
|
+
.auth(Single.new('global')))
|
97
|
+
.response(new_response_handler
|
98
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
99
|
+
.is_api_response(true)
|
100
|
+
.convertor(ApiResponse.method(:create)))
|
101
|
+
.execute
|
165
102
|
end
|
166
103
|
|
167
104
|
# Retrieves a webhook subscription identified by its ID.
|
@@ -169,34 +106,19 @@ module Square
|
|
169
106
|
# the [Subscription]($m/WebhookSubscription) to retrieve.
|
170
107
|
# @return [RetrieveWebhookSubscriptionResponse Hash] response from the API call
|
171
108
|
def retrieve_webhook_subscription(subscription_id:)
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
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
|
-
)
|
109
|
+
new_api_call_builder
|
110
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
111
|
+
'/v2/webhooks/subscriptions/{subscription_id}',
|
112
|
+
'default')
|
113
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
114
|
+
.should_encode(true))
|
115
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
116
|
+
.auth(Single.new('global')))
|
117
|
+
.response(new_response_handler
|
118
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
119
|
+
.is_api_response(true)
|
120
|
+
.convertor(ApiResponse.method(:create)))
|
121
|
+
.execute
|
200
122
|
end
|
201
123
|
|
202
124
|
# Updates a webhook subscription.
|
@@ -208,36 +130,22 @@ module Square
|
|
208
130
|
# @return [UpdateWebhookSubscriptionResponse Hash] response from the API call
|
209
131
|
def update_webhook_subscription(subscription_id:,
|
210
132
|
body:)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
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
|
-
)
|
133
|
+
new_api_call_builder
|
134
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
135
|
+
'/v2/webhooks/subscriptions/{subscription_id}',
|
136
|
+
'default')
|
137
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
138
|
+
.should_encode(true))
|
139
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
140
|
+
.body_param(new_parameter(body))
|
141
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
142
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
143
|
+
.auth(Single.new('global')))
|
144
|
+
.response(new_response_handler
|
145
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
146
|
+
.is_api_response(true)
|
147
|
+
.convertor(ApiResponse.method(:create)))
|
148
|
+
.execute
|
241
149
|
end
|
242
150
|
|
243
151
|
# Updates a webhook subscription by replacing the existing signature key
|
@@ -250,36 +158,22 @@ module Square
|
|
250
158
|
# @return [UpdateWebhookSubscriptionSignatureKeyResponse Hash] response from the API call
|
251
159
|
def update_webhook_subscription_signature_key(subscription_id:,
|
252
160
|
body:)
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
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
|
-
)
|
161
|
+
new_api_call_builder
|
162
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
163
|
+
'/v2/webhooks/subscriptions/{subscription_id}/signature-key',
|
164
|
+
'default')
|
165
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
166
|
+
.should_encode(true))
|
167
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
168
|
+
.body_param(new_parameter(body))
|
169
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
170
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
171
|
+
.auth(Single.new('global')))
|
172
|
+
.response(new_response_handler
|
173
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
174
|
+
.is_api_response(true)
|
175
|
+
.convertor(ApiResponse.method(:create)))
|
176
|
+
.execute
|
283
177
|
end
|
284
178
|
|
285
179
|
# Tests a webhook subscription by sending a test event to the notification
|
@@ -292,36 +186,22 @@ module Square
|
|
292
186
|
# @return [TestWebhookSubscriptionResponse Hash] response from the API call
|
293
187
|
def test_webhook_subscription(subscription_id:,
|
294
188
|
body:)
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
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
|
-
)
|
189
|
+
new_api_call_builder
|
190
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
191
|
+
'/v2/webhooks/subscriptions/{subscription_id}/test',
|
192
|
+
'default')
|
193
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
194
|
+
.should_encode(true))
|
195
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
196
|
+
.body_param(new_parameter(body))
|
197
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
198
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
199
|
+
.auth(Single.new('global')))
|
200
|
+
.response(new_response_handler
|
201
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
202
|
+
.is_api_response(true)
|
203
|
+
.convertor(ApiResponse.method(:create)))
|
204
|
+
.execute
|
325
205
|
end
|
326
206
|
end
|
327
207
|
end
|