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
|
# OrderCustomAttributesApi
|
3
3
|
class OrderCustomAttributesApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Lists the order-related [custom attribute
|
9
5
|
# definitions]($m/CustomAttributeDefinition) that belong to a Square seller
|
10
6
|
# account.
|
@@ -21,7 +17,7 @@ module Square
|
|
21
17
|
# read-only or read-write.
|
22
18
|
# @param [String] cursor Optional parameter: The cursor returned in the
|
23
19
|
# paged response from the previous call to this endpoint. Provide this
|
24
|
-
# cursor to retrieve the next page of results for your original request.
|
20
|
+
# cursor to retrieve the next page of results for your original request.
|
25
21
|
# For more information, see
|
26
22
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
27
23
|
# ion).
|
@@ -36,36 +32,20 @@ module Square
|
|
36
32
|
def list_order_custom_attribute_definitions(visibility_filter: nil,
|
37
33
|
cursor: nil,
|
38
34
|
limit: nil)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
# Prepare and execute HttpRequest.
|
56
|
-
_request = config.http_client.get(
|
57
|
-
_query_url,
|
58
|
-
headers: _headers
|
59
|
-
)
|
60
|
-
OAuth2.apply(config, _request)
|
61
|
-
_response = execute_request(_request)
|
62
|
-
|
63
|
-
# Return appropriate response type.
|
64
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
65
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
66
|
-
ApiResponse.new(
|
67
|
-
_response, data: decoded, errors: _errors
|
68
|
-
)
|
35
|
+
new_api_call_builder
|
36
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
37
|
+
'/v2/orders/custom-attribute-definitions',
|
38
|
+
'default')
|
39
|
+
.query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
|
40
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
41
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
42
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
43
|
+
.auth(Single.new('global')))
|
44
|
+
.response(new_response_handler
|
45
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
46
|
+
.is_api_response(true)
|
47
|
+
.convertor(ApiResponse.method(:create)))
|
48
|
+
.execute
|
69
49
|
end
|
70
50
|
|
71
51
|
# Creates an order-related custom attribute definition. Use this endpoint
|
@@ -79,32 +59,20 @@ module Square
|
|
79
59
|
# the corresponding object definition for field details.
|
80
60
|
# @return [CreateOrderCustomAttributeDefinitionResponse Hash] response from the API call
|
81
61
|
def create_order_custom_attribute_definition(body:)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
headers: _headers,
|
97
|
-
parameters: body.to_json
|
98
|
-
)
|
99
|
-
OAuth2.apply(config, _request)
|
100
|
-
_response = execute_request(_request)
|
101
|
-
|
102
|
-
# Return appropriate response type.
|
103
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
104
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
105
|
-
ApiResponse.new(
|
106
|
-
_response, data: decoded, errors: _errors
|
107
|
-
)
|
62
|
+
new_api_call_builder
|
63
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
64
|
+
'/v2/orders/custom-attribute-definitions',
|
65
|
+
'default')
|
66
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
67
|
+
.body_param(new_parameter(body))
|
68
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
69
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
70
|
+
.auth(Single.new('global')))
|
71
|
+
.response(new_response_handler
|
72
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
73
|
+
.is_api_response(true)
|
74
|
+
.convertor(ApiResponse.method(:create)))
|
75
|
+
.execute
|
108
76
|
end
|
109
77
|
|
110
78
|
# Deletes an order-related [custom attribute
|
@@ -114,34 +82,19 @@ module Square
|
|
114
82
|
# definition to delete.
|
115
83
|
# @return [DeleteOrderCustomAttributeDefinitionResponse Hash] response from the API call
|
116
84
|
def delete_order_custom_attribute_definition(key:)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
# Prepare and execute HttpRequest.
|
132
|
-
_request = config.http_client.delete(
|
133
|
-
_query_url,
|
134
|
-
headers: _headers
|
135
|
-
)
|
136
|
-
OAuth2.apply(config, _request)
|
137
|
-
_response = execute_request(_request)
|
138
|
-
|
139
|
-
# Return appropriate response type.
|
140
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
141
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
142
|
-
ApiResponse.new(
|
143
|
-
_response, data: decoded, errors: _errors
|
144
|
-
)
|
85
|
+
new_api_call_builder
|
86
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
87
|
+
'/v2/orders/custom-attribute-definitions/{key}',
|
88
|
+
'default')
|
89
|
+
.template_param(new_parameter(key, key: 'key')
|
90
|
+
.should_encode(true))
|
91
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
92
|
+
.auth(Single.new('global')))
|
93
|
+
.response(new_response_handler
|
94
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
95
|
+
.is_api_response(true)
|
96
|
+
.convertor(ApiResponse.method(:create)))
|
97
|
+
.execute
|
145
98
|
end
|
146
99
|
|
147
100
|
# Retrieves an order-related [custom attribute
|
@@ -161,38 +114,20 @@ module Square
|
|
161
114
|
# @return [RetrieveOrderCustomAttributeDefinitionResponse Hash] response from the API call
|
162
115
|
def retrieve_order_custom_attribute_definition(key:,
|
163
116
|
version: nil)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
_headers = {
|
179
|
-
'accept' => 'application/json'
|
180
|
-
}
|
181
|
-
|
182
|
-
# Prepare and execute HttpRequest.
|
183
|
-
_request = config.http_client.get(
|
184
|
-
_query_url,
|
185
|
-
headers: _headers
|
186
|
-
)
|
187
|
-
OAuth2.apply(config, _request)
|
188
|
-
_response = execute_request(_request)
|
189
|
-
|
190
|
-
# Return appropriate response type.
|
191
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
192
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
193
|
-
ApiResponse.new(
|
194
|
-
_response, data: decoded, errors: _errors
|
195
|
-
)
|
117
|
+
new_api_call_builder
|
118
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
119
|
+
'/v2/orders/custom-attribute-definitions/{key}',
|
120
|
+
'default')
|
121
|
+
.template_param(new_parameter(key, key: 'key')
|
122
|
+
.should_encode(true))
|
123
|
+
.query_param(new_parameter(version, key: 'version'))
|
124
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
125
|
+
.auth(Single.new('global')))
|
126
|
+
.response(new_response_handler
|
127
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
128
|
+
.is_api_response(true)
|
129
|
+
.convertor(ApiResponse.method(:create)))
|
130
|
+
.execute
|
196
131
|
end
|
197
132
|
|
198
133
|
# Updates an order-related custom attribute definition for a Square seller
|
@@ -208,36 +143,22 @@ module Square
|
|
208
143
|
# @return [UpdateOrderCustomAttributeDefinitionResponse Hash] response from the API call
|
209
144
|
def update_order_custom_attribute_definition(key:,
|
210
145
|
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
|
-
)
|
146
|
+
new_api_call_builder
|
147
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
148
|
+
'/v2/orders/custom-attribute-definitions/{key}',
|
149
|
+
'default')
|
150
|
+
.template_param(new_parameter(key, key: 'key')
|
151
|
+
.should_encode(true))
|
152
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
153
|
+
.body_param(new_parameter(body))
|
154
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
155
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
156
|
+
.auth(Single.new('global')))
|
157
|
+
.response(new_response_handler
|
158
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
159
|
+
.is_api_response(true)
|
160
|
+
.convertor(ApiResponse.method(:create)))
|
161
|
+
.execute
|
241
162
|
end
|
242
163
|
|
243
164
|
# Deletes order [custom attributes]($m/CustomAttribute) as a bulk operation.
|
@@ -266,32 +187,20 @@ module Square
|
|
266
187
|
# corresponding object definition for field details.
|
267
188
|
# @return [BulkDeleteOrderCustomAttributesResponse Hash] response from the API call
|
268
189
|
def bulk_delete_order_custom_attributes(body:)
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
headers: _headers,
|
284
|
-
parameters: body.to_json
|
285
|
-
)
|
286
|
-
OAuth2.apply(config, _request)
|
287
|
-
_response = execute_request(_request)
|
288
|
-
|
289
|
-
# Return appropriate response type.
|
290
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
291
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
292
|
-
ApiResponse.new(
|
293
|
-
_response, data: decoded, errors: _errors
|
294
|
-
)
|
190
|
+
new_api_call_builder
|
191
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
192
|
+
'/v2/orders/custom-attributes/bulk-delete',
|
193
|
+
'default')
|
194
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
195
|
+
.body_param(new_parameter(body))
|
196
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
197
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
198
|
+
.auth(Single.new('global')))
|
199
|
+
.response(new_response_handler
|
200
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
201
|
+
.is_api_response(true)
|
202
|
+
.convertor(ApiResponse.method(:create)))
|
203
|
+
.execute
|
295
204
|
end
|
296
205
|
|
297
206
|
# Creates or updates order [custom attributes]($m/CustomAttribute) as a bulk
|
@@ -321,32 +230,20 @@ module Square
|
|
321
230
|
# corresponding object definition for field details.
|
322
231
|
# @return [BulkUpsertOrderCustomAttributesResponse Hash] response from the API call
|
323
232
|
def bulk_upsert_order_custom_attributes(body:)
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
headers: _headers,
|
339
|
-
parameters: body.to_json
|
340
|
-
)
|
341
|
-
OAuth2.apply(config, _request)
|
342
|
-
_response = execute_request(_request)
|
343
|
-
|
344
|
-
# Return appropriate response type.
|
345
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
346
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
347
|
-
ApiResponse.new(
|
348
|
-
_response, data: decoded, errors: _errors
|
349
|
-
)
|
233
|
+
new_api_call_builder
|
234
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
235
|
+
'/v2/orders/custom-attributes/bulk-upsert',
|
236
|
+
'default')
|
237
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
238
|
+
.body_param(new_parameter(body))
|
239
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
240
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
241
|
+
.auth(Single.new('global')))
|
242
|
+
.response(new_response_handler
|
243
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
244
|
+
.is_api_response(true)
|
245
|
+
.convertor(ApiResponse.method(:create)))
|
246
|
+
.execute
|
350
247
|
end
|
351
248
|
|
352
249
|
# Lists the [custom attributes]($m/CustomAttribute) associated with an
|
@@ -366,7 +263,7 @@ module Square
|
|
366
263
|
# read-only or read-write.
|
367
264
|
# @param [String] cursor Optional parameter: The cursor returned in the
|
368
265
|
# paged response from the previous call to this endpoint. Provide this
|
369
|
-
# cursor to retrieve the next page of results for your original request.
|
266
|
+
# cursor to retrieve the next page of results for your original request.
|
370
267
|
# For more information, see
|
371
268
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
372
269
|
# ion).
|
@@ -389,41 +286,23 @@ module Square
|
|
389
286
|
cursor: nil,
|
390
287
|
limit: nil,
|
391
288
|
with_definitions: false)
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
_headers = {
|
410
|
-
'accept' => 'application/json'
|
411
|
-
}
|
412
|
-
|
413
|
-
# Prepare and execute HttpRequest.
|
414
|
-
_request = config.http_client.get(
|
415
|
-
_query_url,
|
416
|
-
headers: _headers
|
417
|
-
)
|
418
|
-
OAuth2.apply(config, _request)
|
419
|
-
_response = execute_request(_request)
|
420
|
-
|
421
|
-
# Return appropriate response type.
|
422
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
423
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
424
|
-
ApiResponse.new(
|
425
|
-
_response, data: decoded, errors: _errors
|
426
|
-
)
|
289
|
+
new_api_call_builder
|
290
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
291
|
+
'/v2/orders/{order_id}/custom-attributes',
|
292
|
+
'default')
|
293
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
294
|
+
.should_encode(true))
|
295
|
+
.query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
|
296
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
297
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
298
|
+
.query_param(new_parameter(with_definitions, key: 'with_definitions'))
|
299
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
300
|
+
.auth(Single.new('global')))
|
301
|
+
.response(new_response_handler
|
302
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
303
|
+
.is_api_response(true)
|
304
|
+
.convertor(ApiResponse.method(:create)))
|
305
|
+
.execute
|
427
306
|
end
|
428
307
|
|
429
308
|
# Deletes a [custom attribute]($m/CustomAttribute) associated with a
|
@@ -441,35 +320,21 @@ module Square
|
|
441
320
|
# @return [DeleteOrderCustomAttributeResponse Hash] response from the API call
|
442
321
|
def delete_order_custom_attribute(order_id:,
|
443
322
|
custom_attribute_key:)
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
# Prepare and execute HttpRequest.
|
460
|
-
_request = config.http_client.delete(
|
461
|
-
_query_url,
|
462
|
-
headers: _headers
|
463
|
-
)
|
464
|
-
OAuth2.apply(config, _request)
|
465
|
-
_response = execute_request(_request)
|
466
|
-
|
467
|
-
# Return appropriate response type.
|
468
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
469
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
470
|
-
ApiResponse.new(
|
471
|
-
_response, data: decoded, errors: _errors
|
472
|
-
)
|
323
|
+
new_api_call_builder
|
324
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
325
|
+
'/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}',
|
326
|
+
'default')
|
327
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
328
|
+
.should_encode(true))
|
329
|
+
.template_param(new_parameter(custom_attribute_key, key: 'custom_attribute_key')
|
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)))
|
337
|
+
.execute
|
473
338
|
end
|
474
339
|
|
475
340
|
# Retrieves a [custom attribute]($m/CustomAttribute) associated with an
|
@@ -503,40 +368,23 @@ module Square
|
|
503
368
|
custom_attribute_key:,
|
504
369
|
version: nil,
|
505
370
|
with_definition: false)
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
'accept' => 'application/json'
|
524
|
-
}
|
525
|
-
|
526
|
-
# Prepare and execute HttpRequest.
|
527
|
-
_request = config.http_client.get(
|
528
|
-
_query_url,
|
529
|
-
headers: _headers
|
530
|
-
)
|
531
|
-
OAuth2.apply(config, _request)
|
532
|
-
_response = execute_request(_request)
|
533
|
-
|
534
|
-
# Return appropriate response type.
|
535
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
536
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
537
|
-
ApiResponse.new(
|
538
|
-
_response, data: decoded, errors: _errors
|
539
|
-
)
|
371
|
+
new_api_call_builder
|
372
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
373
|
+
'/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}',
|
374
|
+
'default')
|
375
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
376
|
+
.should_encode(true))
|
377
|
+
.template_param(new_parameter(custom_attribute_key, key: 'custom_attribute_key')
|
378
|
+
.should_encode(true))
|
379
|
+
.query_param(new_parameter(version, key: 'version'))
|
380
|
+
.query_param(new_parameter(with_definition, key: 'with_definition'))
|
381
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
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
|
540
388
|
end
|
541
389
|
|
542
390
|
# Creates or updates a [custom attribute]($m/CustomAttribute) for an order.
|
@@ -565,37 +413,24 @@ module Square
|
|
565
413
|
def upsert_order_custom_attribute(order_id:,
|
566
414
|
custom_attribute_key:,
|
567
415
|
body:)
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
_query_url,
|
587
|
-
headers: _headers,
|
588
|
-
parameters: body.to_json
|
589
|
-
)
|
590
|
-
OAuth2.apply(config, _request)
|
591
|
-
_response = execute_request(_request)
|
592
|
-
|
593
|
-
# Return appropriate response type.
|
594
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
595
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
596
|
-
ApiResponse.new(
|
597
|
-
_response, data: decoded, errors: _errors
|
598
|
-
)
|
416
|
+
new_api_call_builder
|
417
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
418
|
+
'/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}',
|
419
|
+
'default')
|
420
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
421
|
+
.should_encode(true))
|
422
|
+
.template_param(new_parameter(custom_attribute_key, key: 'custom_attribute_key')
|
423
|
+
.should_encode(true))
|
424
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
425
|
+
.body_param(new_parameter(body))
|
426
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
427
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
428
|
+
.auth(Single.new('global')))
|
429
|
+
.response(new_response_handler
|
430
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
431
|
+
.is_api_response(true)
|
432
|
+
.convertor(ApiResponse.method(:create)))
|
433
|
+
.execute
|
599
434
|
end
|
600
435
|
end
|
601
436
|
end
|