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,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# CatalogApi
|
3
3
|
class CatalogApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Deletes a set of [CatalogItem]($m/CatalogItem)s based on the
|
9
5
|
# provided list of target IDs and returns a set of successfully deleted IDs
|
10
6
|
# in
|
@@ -26,32 +22,20 @@ module Square
|
|
26
22
|
# corresponding object definition for field details.
|
27
23
|
# @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
|
28
24
|
def batch_delete_catalog_objects(body:)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
headers: _headers,
|
44
|
-
parameters: body.to_json
|
45
|
-
)
|
46
|
-
OAuth2.apply(config, _request)
|
47
|
-
_response = execute_request(_request)
|
48
|
-
|
49
|
-
# Return appropriate response type.
|
50
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
51
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
52
|
-
ApiResponse.new(
|
53
|
-
_response, data: decoded, errors: _errors
|
54
|
-
)
|
25
|
+
new_api_call_builder
|
26
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
27
|
+
'/v2/catalog/batch-delete',
|
28
|
+
'default')
|
29
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
30
|
+
.body_param(new_parameter(body))
|
31
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
32
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
33
|
+
.auth(Single.new('global')))
|
34
|
+
.response(new_response_handler
|
35
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
36
|
+
.is_api_response(true)
|
37
|
+
.convertor(ApiResponse.method(:create)))
|
38
|
+
.execute
|
55
39
|
end
|
56
40
|
|
57
41
|
# Returns a set of objects based on the provided ID.
|
@@ -65,32 +49,20 @@ module Square
|
|
65
49
|
# corresponding object definition for field details.
|
66
50
|
# @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
|
67
51
|
def batch_retrieve_catalog_objects(body:)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
headers: _headers,
|
83
|
-
parameters: body.to_json
|
84
|
-
)
|
85
|
-
OAuth2.apply(config, _request)
|
86
|
-
_response = execute_request(_request)
|
87
|
-
|
88
|
-
# Return appropriate response type.
|
89
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
90
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
91
|
-
ApiResponse.new(
|
92
|
-
_response, data: decoded, errors: _errors
|
93
|
-
)
|
52
|
+
new_api_call_builder
|
53
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
54
|
+
'/v2/catalog/batch-retrieve',
|
55
|
+
'default')
|
56
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
57
|
+
.body_param(new_parameter(body))
|
58
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
59
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
60
|
+
.auth(Single.new('global')))
|
61
|
+
.response(new_response_handler
|
62
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
63
|
+
.is_api_response(true)
|
64
|
+
.convertor(ApiResponse.method(:create)))
|
65
|
+
.execute
|
94
66
|
end
|
95
67
|
|
96
68
|
# Creates or updates up to 10,000 target objects based on the provided
|
@@ -117,32 +89,20 @@ module Square
|
|
117
89
|
# corresponding object definition for field details.
|
118
90
|
# @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
|
119
91
|
def batch_upsert_catalog_objects(body:)
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
headers: _headers,
|
135
|
-
parameters: body.to_json
|
136
|
-
)
|
137
|
-
OAuth2.apply(config, _request)
|
138
|
-
_response = execute_request(_request)
|
139
|
-
|
140
|
-
# Return appropriate response type.
|
141
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
142
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
143
|
-
ApiResponse.new(
|
144
|
-
_response, data: decoded, errors: _errors
|
145
|
-
)
|
92
|
+
new_api_call_builder
|
93
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
94
|
+
'/v2/catalog/batch-upsert',
|
95
|
+
'default')
|
96
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
97
|
+
.body_param(new_parameter(body))
|
98
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
99
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
100
|
+
.auth(Single.new('global')))
|
101
|
+
.response(new_response_handler
|
102
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
103
|
+
.is_api_response(true)
|
104
|
+
.convertor(ApiResponse.method(:create)))
|
105
|
+
.execute
|
146
106
|
end
|
147
107
|
|
148
108
|
# Uploads an image file to be represented by a
|
@@ -158,52 +118,21 @@ module Square
|
|
158
118
|
# @return [CreateCatalogImageResponse Hash] response from the API call
|
159
119
|
def create_catalog_image(request: nil,
|
160
120
|
image_file: nil)
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
'accept' => 'application/json'
|
177
|
-
}
|
178
|
-
|
179
|
-
# Prepare form parameters.
|
180
|
-
_parameters = {
|
181
|
-
'request' => Faraday::UploadIO.new(
|
182
|
-
StringIO.new(request.to_json),
|
183
|
-
'application/json'
|
184
|
-
),
|
185
|
-
'image_file' => Faraday::UploadIO.new(
|
186
|
-
image_file_wrapper,
|
187
|
-
image_file_content_type
|
188
|
-
)
|
189
|
-
}
|
190
|
-
_parameters = APIHelper.form_encode_parameters(_parameters)
|
191
|
-
|
192
|
-
# Prepare and execute HttpRequest.
|
193
|
-
_request = config.http_client.post(
|
194
|
-
_query_url,
|
195
|
-
headers: _headers,
|
196
|
-
parameters: _parameters
|
197
|
-
)
|
198
|
-
OAuth2.apply(config, _request)
|
199
|
-
_response = execute_request(_request)
|
200
|
-
|
201
|
-
# Return appropriate response type.
|
202
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
203
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
204
|
-
ApiResponse.new(
|
205
|
-
_response, data: decoded, errors: _errors
|
206
|
-
)
|
121
|
+
new_api_call_builder
|
122
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
123
|
+
'/v2/catalog/images',
|
124
|
+
'default')
|
125
|
+
.multipart_param(new_parameter(StringIO.new(request.to_json), key: 'request')
|
126
|
+
.default_content_type('application/json; charset=utf-8'))
|
127
|
+
.multipart_param(new_parameter(image_file, key: 'image_file')
|
128
|
+
.default_content_type('image/jpeg'))
|
129
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
130
|
+
.auth(Single.new('global')))
|
131
|
+
.response(new_response_handler
|
132
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
133
|
+
.is_api_response(true)
|
134
|
+
.convertor(ApiResponse.method(:create)))
|
135
|
+
.execute
|
207
136
|
end
|
208
137
|
|
209
138
|
# Uploads a new image file to replace the existing one in the specified
|
@@ -219,86 +148,40 @@ module Square
|
|
219
148
|
def update_catalog_image(image_id:,
|
220
149
|
request: nil,
|
221
150
|
image_file: nil)
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
# Prepare headers.
|
240
|
-
_headers = {
|
241
|
-
'accept' => 'application/json'
|
242
|
-
}
|
243
|
-
|
244
|
-
# Prepare form parameters.
|
245
|
-
_parameters = {
|
246
|
-
'request' => Faraday::UploadIO.new(
|
247
|
-
StringIO.new(request.to_json),
|
248
|
-
'application/json'
|
249
|
-
),
|
250
|
-
'image_file' => Faraday::UploadIO.new(
|
251
|
-
image_file_wrapper,
|
252
|
-
image_file_content_type
|
253
|
-
)
|
254
|
-
}
|
255
|
-
_parameters = APIHelper.form_encode_parameters(_parameters)
|
256
|
-
|
257
|
-
# Prepare and execute HttpRequest.
|
258
|
-
_request = config.http_client.put(
|
259
|
-
_query_url,
|
260
|
-
headers: _headers,
|
261
|
-
parameters: _parameters
|
262
|
-
)
|
263
|
-
OAuth2.apply(config, _request)
|
264
|
-
_response = execute_request(_request)
|
265
|
-
|
266
|
-
# Return appropriate response type.
|
267
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
268
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
269
|
-
ApiResponse.new(
|
270
|
-
_response, data: decoded, errors: _errors
|
271
|
-
)
|
151
|
+
new_api_call_builder
|
152
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
153
|
+
'/v2/catalog/images/{image_id}',
|
154
|
+
'default')
|
155
|
+
.template_param(new_parameter(image_id, key: 'image_id')
|
156
|
+
.should_encode(true))
|
157
|
+
.multipart_param(new_parameter(StringIO.new(request.to_json), key: 'request')
|
158
|
+
.default_content_type('application/json; charset=utf-8'))
|
159
|
+
.multipart_param(new_parameter(image_file, key: 'image_file')
|
160
|
+
.default_content_type('image/jpeg'))
|
161
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
162
|
+
.auth(Single.new('global')))
|
163
|
+
.response(new_response_handler
|
164
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
165
|
+
.is_api_response(true)
|
166
|
+
.convertor(ApiResponse.method(:create)))
|
167
|
+
.execute
|
272
168
|
end
|
273
169
|
|
274
170
|
# Retrieves information about the Square Catalog API, such as batch size
|
275
171
|
# limits that can be used by the `BatchUpsertCatalogObjects` endpoint.
|
276
172
|
# @return [CatalogInfoResponse Hash] response from the API call
|
277
173
|
def catalog_info
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
_request = config.http_client.get(
|
290
|
-
_query_url,
|
291
|
-
headers: _headers
|
292
|
-
)
|
293
|
-
OAuth2.apply(config, _request)
|
294
|
-
_response = execute_request(_request)
|
295
|
-
|
296
|
-
# Return appropriate response type.
|
297
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
298
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
299
|
-
ApiResponse.new(
|
300
|
-
_response, data: decoded, errors: _errors
|
301
|
-
)
|
174
|
+
new_api_call_builder
|
175
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
176
|
+
'/v2/catalog/info',
|
177
|
+
'default')
|
178
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
179
|
+
.auth(Single.new('global')))
|
180
|
+
.response(new_response_handler
|
181
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
182
|
+
.is_api_response(true)
|
183
|
+
.convertor(ApiResponse.method(:create)))
|
184
|
+
.execute
|
302
185
|
end
|
303
186
|
|
304
187
|
# Returns a list of all [CatalogObject]($m/CatalogObject)s of the specified
|
@@ -339,36 +222,20 @@ module Square
|
|
339
222
|
def list_catalog(cursor: nil,
|
340
223
|
types: nil,
|
341
224
|
catalog_version: nil)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
}
|
357
|
-
|
358
|
-
# Prepare and execute HttpRequest.
|
359
|
-
_request = config.http_client.get(
|
360
|
-
_query_url,
|
361
|
-
headers: _headers
|
362
|
-
)
|
363
|
-
OAuth2.apply(config, _request)
|
364
|
-
_response = execute_request(_request)
|
365
|
-
|
366
|
-
# Return appropriate response type.
|
367
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
368
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
369
|
-
ApiResponse.new(
|
370
|
-
_response, data: decoded, errors: _errors
|
371
|
-
)
|
225
|
+
new_api_call_builder
|
226
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
227
|
+
'/v2/catalog/list',
|
228
|
+
'default')
|
229
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
230
|
+
.query_param(new_parameter(types, key: 'types'))
|
231
|
+
.query_param(new_parameter(catalog_version, key: 'catalog_version'))
|
232
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
233
|
+
.auth(Single.new('global')))
|
234
|
+
.response(new_response_handler
|
235
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
236
|
+
.is_api_response(true)
|
237
|
+
.convertor(ApiResponse.method(:create)))
|
238
|
+
.execute
|
372
239
|
end
|
373
240
|
|
374
241
|
# Creates a new or updates the specified [CatalogObject]($m/CatalogObject).
|
@@ -382,32 +249,20 @@ module Square
|
|
382
249
|
# object definition for field details.
|
383
250
|
# @return [UpsertCatalogObjectResponse Hash] response from the API call
|
384
251
|
def upsert_catalog_object(body:)
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
headers: _headers,
|
400
|
-
parameters: body.to_json
|
401
|
-
)
|
402
|
-
OAuth2.apply(config, _request)
|
403
|
-
_response = execute_request(_request)
|
404
|
-
|
405
|
-
# Return appropriate response type.
|
406
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
407
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
408
|
-
ApiResponse.new(
|
409
|
-
_response, data: decoded, errors: _errors
|
410
|
-
)
|
252
|
+
new_api_call_builder
|
253
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
254
|
+
'/v2/catalog/object',
|
255
|
+
'default')
|
256
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
257
|
+
.body_param(new_parameter(body))
|
258
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
259
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
260
|
+
.auth(Single.new('global')))
|
261
|
+
.response(new_response_handler
|
262
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
263
|
+
.is_api_response(true)
|
264
|
+
.convertor(ApiResponse.method(:create)))
|
265
|
+
.execute
|
411
266
|
end
|
412
267
|
|
413
268
|
# Deletes a single [CatalogObject]($m/CatalogObject) based on the
|
@@ -429,34 +284,19 @@ module Square
|
|
429
284
|
# catalog item will delete its catalog item variations).
|
430
285
|
# @return [DeleteCatalogObjectResponse Hash] response from the API call
|
431
286
|
def delete_catalog_object(object_id:)
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
# Prepare and execute HttpRequest.
|
447
|
-
_request = config.http_client.delete(
|
448
|
-
_query_url,
|
449
|
-
headers: _headers
|
450
|
-
)
|
451
|
-
OAuth2.apply(config, _request)
|
452
|
-
_response = execute_request(_request)
|
453
|
-
|
454
|
-
# Return appropriate response type.
|
455
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
456
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
457
|
-
ApiResponse.new(
|
458
|
-
_response, data: decoded, errors: _errors
|
459
|
-
)
|
287
|
+
new_api_call_builder
|
288
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
289
|
+
'/v2/catalog/object/{object_id}',
|
290
|
+
'default')
|
291
|
+
.template_param(new_parameter(object_id, key: 'object_id')
|
292
|
+
.should_encode(true))
|
293
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
294
|
+
.auth(Single.new('global')))
|
295
|
+
.response(new_response_handler
|
296
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
297
|
+
.is_api_response(true)
|
298
|
+
.convertor(ApiResponse.method(:create)))
|
299
|
+
.execute
|
460
300
|
end
|
461
301
|
|
462
302
|
# Returns a single [CatalogItem]($m/CatalogItem) as a
|
@@ -492,39 +332,21 @@ module Square
|
|
492
332
|
def retrieve_catalog_object(object_id:,
|
493
333
|
include_related_objects: false,
|
494
334
|
catalog_version: nil)
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
_headers = {
|
511
|
-
'accept' => 'application/json'
|
512
|
-
}
|
513
|
-
|
514
|
-
# Prepare and execute HttpRequest.
|
515
|
-
_request = config.http_client.get(
|
516
|
-
_query_url,
|
517
|
-
headers: _headers
|
518
|
-
)
|
519
|
-
OAuth2.apply(config, _request)
|
520
|
-
_response = execute_request(_request)
|
521
|
-
|
522
|
-
# Return appropriate response type.
|
523
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
524
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
525
|
-
ApiResponse.new(
|
526
|
-
_response, data: decoded, errors: _errors
|
527
|
-
)
|
335
|
+
new_api_call_builder
|
336
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
337
|
+
'/v2/catalog/object/{object_id}',
|
338
|
+
'default')
|
339
|
+
.template_param(new_parameter(object_id, key: 'object_id')
|
340
|
+
.should_encode(true))
|
341
|
+
.query_param(new_parameter(include_related_objects, key: 'include_related_objects'))
|
342
|
+
.query_param(new_parameter(catalog_version, key: 'catalog_version'))
|
343
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
344
|
+
.auth(Single.new('global')))
|
345
|
+
.response(new_response_handler
|
346
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
347
|
+
.is_api_response(true)
|
348
|
+
.convertor(ApiResponse.method(:create)))
|
349
|
+
.execute
|
528
350
|
end
|
529
351
|
|
530
352
|
# Searches for [CatalogObject]($m/CatalogObject) of any type by matching
|
@@ -549,32 +371,20 @@ module Square
|
|
549
371
|
# object definition for field details.
|
550
372
|
# @return [SearchCatalogObjectsResponse Hash] response from the API call
|
551
373
|
def search_catalog_objects(body:)
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
headers: _headers,
|
567
|
-
parameters: body.to_json
|
568
|
-
)
|
569
|
-
OAuth2.apply(config, _request)
|
570
|
-
_response = execute_request(_request)
|
571
|
-
|
572
|
-
# Return appropriate response type.
|
573
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
574
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
575
|
-
ApiResponse.new(
|
576
|
-
_response, data: decoded, errors: _errors
|
577
|
-
)
|
374
|
+
new_api_call_builder
|
375
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
376
|
+
'/v2/catalog/search',
|
377
|
+
'default')
|
378
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
379
|
+
.body_param(new_parameter(body))
|
380
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
381
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
382
|
+
.auth(Single.new('global')))
|
383
|
+
.response(new_response_handler
|
384
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
385
|
+
.is_api_response(true)
|
386
|
+
.convertor(ApiResponse.method(:create)))
|
387
|
+
.execute
|
578
388
|
end
|
579
389
|
|
580
390
|
# Searches for catalog items or item variations by matching supported search
|
@@ -599,32 +409,20 @@ module Square
|
|
599
409
|
# object definition for field details.
|
600
410
|
# @return [SearchCatalogItemsResponse Hash] response from the API call
|
601
411
|
def search_catalog_items(body:)
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
headers: _headers,
|
617
|
-
parameters: body.to_json
|
618
|
-
)
|
619
|
-
OAuth2.apply(config, _request)
|
620
|
-
_response = execute_request(_request)
|
621
|
-
|
622
|
-
# Return appropriate response type.
|
623
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
624
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
625
|
-
ApiResponse.new(
|
626
|
-
_response, data: decoded, errors: _errors
|
627
|
-
)
|
412
|
+
new_api_call_builder
|
413
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
414
|
+
'/v2/catalog/search-catalog-items',
|
415
|
+
'default')
|
416
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
417
|
+
.body_param(new_parameter(body))
|
418
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
419
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
420
|
+
.auth(Single.new('global')))
|
421
|
+
.response(new_response_handler
|
422
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
423
|
+
.is_api_response(true)
|
424
|
+
.convertor(ApiResponse.method(:create)))
|
425
|
+
.execute
|
628
426
|
end
|
629
427
|
|
630
428
|
# Updates the [CatalogModifierList]($m/CatalogModifierList) objects
|
@@ -635,32 +433,20 @@ module Square
|
|
635
433
|
# object definition for field details.
|
636
434
|
# @return [UpdateItemModifierListsResponse Hash] response from the API call
|
637
435
|
def update_item_modifier_lists(body:)
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
headers: _headers,
|
653
|
-
parameters: body.to_json
|
654
|
-
)
|
655
|
-
OAuth2.apply(config, _request)
|
656
|
-
_response = execute_request(_request)
|
657
|
-
|
658
|
-
# Return appropriate response type.
|
659
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
660
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
661
|
-
ApiResponse.new(
|
662
|
-
_response, data: decoded, errors: _errors
|
663
|
-
)
|
436
|
+
new_api_call_builder
|
437
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
438
|
+
'/v2/catalog/update-item-modifier-lists',
|
439
|
+
'default')
|
440
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
441
|
+
.body_param(new_parameter(body))
|
442
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
443
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
444
|
+
.auth(Single.new('global')))
|
445
|
+
.response(new_response_handler
|
446
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
447
|
+
.is_api_response(true)
|
448
|
+
.convertor(ApiResponse.method(:create)))
|
449
|
+
.execute
|
664
450
|
end
|
665
451
|
|
666
452
|
# Updates the [CatalogTax]($m/CatalogTax) objects that apply to the
|
@@ -671,32 +457,20 @@ module Square
|
|
671
457
|
# object definition for field details.
|
672
458
|
# @return [UpdateItemTaxesResponse Hash] response from the API call
|
673
459
|
def update_item_taxes(body:)
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
headers: _headers,
|
689
|
-
parameters: body.to_json
|
690
|
-
)
|
691
|
-
OAuth2.apply(config, _request)
|
692
|
-
_response = execute_request(_request)
|
693
|
-
|
694
|
-
# Return appropriate response type.
|
695
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
696
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
697
|
-
ApiResponse.new(
|
698
|
-
_response, data: decoded, errors: _errors
|
699
|
-
)
|
460
|
+
new_api_call_builder
|
461
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
462
|
+
'/v2/catalog/update-item-taxes',
|
463
|
+
'default')
|
464
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
465
|
+
.body_param(new_parameter(body))
|
466
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
467
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
468
|
+
.auth(Single.new('global')))
|
469
|
+
.response(new_response_handler
|
470
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
471
|
+
.is_api_response(true)
|
472
|
+
.convertor(ApiResponse.method(:create)))
|
473
|
+
.execute
|
700
474
|
end
|
701
475
|
end
|
702
476
|
end
|