square.rb 26.1.0.20230119 → 27.0.0.20230419
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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- 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 +171 -336
- data/lib/square/api/bookings_api.rb +140 -263
- data/lib/square/api/cards_api.rb +58 -120
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +200 -426
- data/lib/square/api/checkout_api.rb +86 -176
- data/lib/square/api/customer_custom_attributes_api.rb +157 -310
- 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 +132 -290
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +34 -66
- data/lib/square/api/gift_cards_api.rb +109 -207
- data/lib/square/api/inventory_api.rb +204 -391
- data/lib/square/api/invoices_api.rb +121 -240
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +173 -338
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +283 -535
- 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 +174 -339
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +118 -217
- data/lib/square/api/payouts_api.rb +54 -107
- data/lib/square/api/refunds_api.rb +59 -104
- 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 +64 -128
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +100 -193
- data/lib/square/api/webhook_subscriptions_api.rb +124 -244
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +77 -47
- 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 +6 -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 +11 -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
|
# CustomerCustomAttributesApi
|
3
3
|
class CustomerCustomAttributesApi < 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 customer-related [custom attribute
|
9
5
|
# definitions]($m/CustomAttributeDefinition) that belong to a Square seller
|
10
6
|
# account.
|
@@ -31,35 +27,19 @@ module Square
|
|
31
27
|
# @return [ListCustomerCustomAttributeDefinitionsResponse Hash] response from the API call
|
32
28
|
def list_customer_custom_attribute_definitions(limit: nil,
|
33
29
|
cursor: nil)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
# Prepare and execute HttpRequest.
|
50
|
-
_request = config.http_client.get(
|
51
|
-
_query_url,
|
52
|
-
headers: _headers
|
53
|
-
)
|
54
|
-
OAuth2.apply(config, _request)
|
55
|
-
_response = execute_request(_request)
|
56
|
-
|
57
|
-
# Return appropriate response type.
|
58
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
59
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
60
|
-
ApiResponse.new(
|
61
|
-
_response, data: decoded, errors: _errors
|
62
|
-
)
|
30
|
+
new_api_call_builder
|
31
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
32
|
+
'/v2/customers/custom-attribute-definitions',
|
33
|
+
'default')
|
34
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
35
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
36
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
37
|
+
.auth(Single.new('global')))
|
38
|
+
.response(new_response_handler
|
39
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
40
|
+
.is_api_response(true)
|
41
|
+
.convertor(ApiResponse.method(:create)))
|
42
|
+
.execute
|
63
43
|
end
|
64
44
|
|
65
45
|
# Creates a customer-related [custom attribute
|
@@ -83,32 +63,20 @@ module Square
|
|
83
63
|
# the corresponding object definition for field details.
|
84
64
|
# @return [CreateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
85
65
|
def create_customer_custom_attribute_definition(body:)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
headers: _headers,
|
101
|
-
parameters: body.to_json
|
102
|
-
)
|
103
|
-
OAuth2.apply(config, _request)
|
104
|
-
_response = execute_request(_request)
|
105
|
-
|
106
|
-
# Return appropriate response type.
|
107
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
108
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
109
|
-
ApiResponse.new(
|
110
|
-
_response, data: decoded, errors: _errors
|
111
|
-
)
|
66
|
+
new_api_call_builder
|
67
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
68
|
+
'/v2/customers/custom-attribute-definitions',
|
69
|
+
'default')
|
70
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
71
|
+
.body_param(new_parameter(body))
|
72
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
73
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
74
|
+
.auth(Single.new('global')))
|
75
|
+
.response(new_response_handler
|
76
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
77
|
+
.is_api_response(true)
|
78
|
+
.convertor(ApiResponse.method(:create)))
|
79
|
+
.execute
|
112
80
|
end
|
113
81
|
|
114
82
|
# Deletes a customer-related [custom attribute
|
@@ -121,34 +89,19 @@ module Square
|
|
121
89
|
# definition to delete.
|
122
90
|
# @return [DeleteCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
123
91
|
def delete_customer_custom_attribute_definition(key:)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
# Prepare and execute HttpRequest.
|
139
|
-
_request = config.http_client.delete(
|
140
|
-
_query_url,
|
141
|
-
headers: _headers
|
142
|
-
)
|
143
|
-
OAuth2.apply(config, _request)
|
144
|
-
_response = execute_request(_request)
|
145
|
-
|
146
|
-
# Return appropriate response type.
|
147
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
148
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
149
|
-
ApiResponse.new(
|
150
|
-
_response, data: decoded, errors: _errors
|
151
|
-
)
|
92
|
+
new_api_call_builder
|
93
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
94
|
+
'/v2/customers/custom-attribute-definitions/{key}',
|
95
|
+
'default')
|
96
|
+
.template_param(new_parameter(key, key: 'key')
|
97
|
+
.should_encode(true))
|
98
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
99
|
+
.auth(Single.new('global')))
|
100
|
+
.response(new_response_handler
|
101
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
102
|
+
.is_api_response(true)
|
103
|
+
.convertor(ApiResponse.method(:create)))
|
104
|
+
.execute
|
152
105
|
end
|
153
106
|
|
154
107
|
# Retrieves a customer-related [custom attribute
|
@@ -171,38 +124,20 @@ module Square
|
|
171
124
|
# @return [RetrieveCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
172
125
|
def retrieve_customer_custom_attribute_definition(key:,
|
173
126
|
version: nil)
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
_headers = {
|
189
|
-
'accept' => 'application/json'
|
190
|
-
}
|
191
|
-
|
192
|
-
# Prepare and execute HttpRequest.
|
193
|
-
_request = config.http_client.get(
|
194
|
-
_query_url,
|
195
|
-
headers: _headers
|
196
|
-
)
|
197
|
-
OAuth2.apply(config, _request)
|
198
|
-
_response = execute_request(_request)
|
199
|
-
|
200
|
-
# Return appropriate response type.
|
201
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
202
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
203
|
-
ApiResponse.new(
|
204
|
-
_response, data: decoded, errors: _errors
|
205
|
-
)
|
127
|
+
new_api_call_builder
|
128
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
129
|
+
'/v2/customers/custom-attribute-definitions/{key}',
|
130
|
+
'default')
|
131
|
+
.template_param(new_parameter(key, key: 'key')
|
132
|
+
.should_encode(true))
|
133
|
+
.query_param(new_parameter(version, key: 'version'))
|
134
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
135
|
+
.auth(Single.new('global')))
|
136
|
+
.response(new_response_handler
|
137
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
138
|
+
.is_api_response(true)
|
139
|
+
.convertor(ApiResponse.method(:create)))
|
140
|
+
.execute
|
206
141
|
end
|
207
142
|
|
208
143
|
# Updates a customer-related [custom attribute
|
@@ -222,36 +157,22 @@ module Square
|
|
222
157
|
# @return [UpdateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
223
158
|
def update_customer_custom_attribute_definition(key:,
|
224
159
|
body:)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
_request = config.http_client.put(
|
242
|
-
_query_url,
|
243
|
-
headers: _headers,
|
244
|
-
parameters: body.to_json
|
245
|
-
)
|
246
|
-
OAuth2.apply(config, _request)
|
247
|
-
_response = execute_request(_request)
|
248
|
-
|
249
|
-
# Return appropriate response type.
|
250
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
251
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
252
|
-
ApiResponse.new(
|
253
|
-
_response, data: decoded, errors: _errors
|
254
|
-
)
|
160
|
+
new_api_call_builder
|
161
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
162
|
+
'/v2/customers/custom-attribute-definitions/{key}',
|
163
|
+
'default')
|
164
|
+
.template_param(new_parameter(key, key: 'key')
|
165
|
+
.should_encode(true))
|
166
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
167
|
+
.body_param(new_parameter(body))
|
168
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
169
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
170
|
+
.auth(Single.new('global')))
|
171
|
+
.response(new_response_handler
|
172
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
173
|
+
.is_api_response(true)
|
174
|
+
.convertor(ApiResponse.method(:create)))
|
175
|
+
.execute
|
255
176
|
end
|
256
177
|
|
257
178
|
# Creates or updates [custom attributes]($m/CustomAttribute) for customer
|
@@ -281,32 +202,20 @@ module Square
|
|
281
202
|
# the corresponding object definition for field details.
|
282
203
|
# @return [BulkUpsertCustomerCustomAttributesResponse Hash] response from the API call
|
283
204
|
def bulk_upsert_customer_custom_attributes(body:)
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
headers: _headers,
|
299
|
-
parameters: body.to_json
|
300
|
-
)
|
301
|
-
OAuth2.apply(config, _request)
|
302
|
-
_response = execute_request(_request)
|
303
|
-
|
304
|
-
# Return appropriate response type.
|
305
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
306
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
307
|
-
ApiResponse.new(
|
308
|
-
_response, data: decoded, errors: _errors
|
309
|
-
)
|
205
|
+
new_api_call_builder
|
206
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
207
|
+
'/v2/customers/custom-attributes/bulk-upsert',
|
208
|
+
'default')
|
209
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
210
|
+
.body_param(new_parameter(body))
|
211
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
212
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
213
|
+
.auth(Single.new('global')))
|
214
|
+
.response(new_response_handler
|
215
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
216
|
+
.is_api_response(true)
|
217
|
+
.convertor(ApiResponse.method(:create)))
|
218
|
+
.execute
|
310
219
|
end
|
311
220
|
|
312
221
|
# Lists the [custom attributes]($m/CustomAttribute) associated with a
|
@@ -320,7 +229,7 @@ module Square
|
|
320
229
|
# other applications
|
321
230
|
# and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
322
231
|
# @param [String] customer_id Required parameter: The ID of the target
|
323
|
-
# [customer profile](
|
232
|
+
# [customer profile](entity:Customer).
|
324
233
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
325
234
|
# to return in a single paged response. This limit is advisory. The response
|
326
235
|
# might contain more or fewer results. The minimum value is 1 and the
|
@@ -335,7 +244,7 @@ module Square
|
|
335
244
|
# atterns/pagination).
|
336
245
|
# @param [TrueClass|FalseClass] with_definitions Optional parameter:
|
337
246
|
# Indicates whether to return the [custom attribute
|
338
|
-
# definition](
|
247
|
+
# definition](entity:CustomAttributeDefinition) in the `definition` field of
|
339
248
|
# each custom attribute. Set this parameter to `true` to get the name and
|
340
249
|
# description of each custom attribute, information about the data type, or
|
341
250
|
# other definition details. The default value is `false`.
|
@@ -344,40 +253,22 @@ module Square
|
|
344
253
|
limit: nil,
|
345
254
|
cursor: nil,
|
346
255
|
with_definitions: false)
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
_headers = {
|
364
|
-
'accept' => 'application/json'
|
365
|
-
}
|
366
|
-
|
367
|
-
# Prepare and execute HttpRequest.
|
368
|
-
_request = config.http_client.get(
|
369
|
-
_query_url,
|
370
|
-
headers: _headers
|
371
|
-
)
|
372
|
-
OAuth2.apply(config, _request)
|
373
|
-
_response = execute_request(_request)
|
374
|
-
|
375
|
-
# Return appropriate response type.
|
376
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
377
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
378
|
-
ApiResponse.new(
|
379
|
-
_response, data: decoded, errors: _errors
|
380
|
-
)
|
256
|
+
new_api_call_builder
|
257
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
258
|
+
'/v2/customers/{customer_id}/custom-attributes',
|
259
|
+
'default')
|
260
|
+
.template_param(new_parameter(customer_id, key: 'customer_id')
|
261
|
+
.should_encode(true))
|
262
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
263
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
264
|
+
.query_param(new_parameter(with_definitions, key: 'with_definitions'))
|
265
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
266
|
+
.auth(Single.new('global')))
|
267
|
+
.response(new_response_handler
|
268
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
269
|
+
.is_api_response(true)
|
270
|
+
.convertor(ApiResponse.method(:create)))
|
271
|
+
.execute
|
381
272
|
end
|
382
273
|
|
383
274
|
# Deletes a [custom attribute]($m/CustomAttribute) associated with a
|
@@ -388,7 +279,7 @@ module Square
|
|
388
279
|
# (also known as custom fields) are always set to
|
389
280
|
# `VISIBILITY_READ_WRITE_VALUES`.
|
390
281
|
# @param [String] customer_id Required parameter: The ID of the target
|
391
|
-
# [customer profile](
|
282
|
+
# [customer profile](entity:Customer).
|
392
283
|
# @param [String] key Required parameter: The key of the custom attribute to
|
393
284
|
# delete. This key must match the `key` of a custom attribute definition in
|
394
285
|
# the Square seller account. If the requesting application is not the
|
@@ -396,35 +287,21 @@ module Square
|
|
396
287
|
# @return [DeleteCustomerCustomAttributeResponse Hash] response from the API call
|
397
288
|
def delete_customer_custom_attribute(customer_id:,
|
398
289
|
key:)
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
# Prepare and execute HttpRequest.
|
415
|
-
_request = config.http_client.delete(
|
416
|
-
_query_url,
|
417
|
-
headers: _headers
|
418
|
-
)
|
419
|
-
OAuth2.apply(config, _request)
|
420
|
-
_response = execute_request(_request)
|
421
|
-
|
422
|
-
# Return appropriate response type.
|
423
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
424
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
425
|
-
ApiResponse.new(
|
426
|
-
_response, data: decoded, errors: _errors
|
427
|
-
)
|
290
|
+
new_api_call_builder
|
291
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
292
|
+
'/v2/customers/{customer_id}/custom-attributes/{key}',
|
293
|
+
'default')
|
294
|
+
.template_param(new_parameter(customer_id, key: 'customer_id')
|
295
|
+
.should_encode(true))
|
296
|
+
.template_param(new_parameter(key, key: 'key')
|
297
|
+
.should_encode(true))
|
298
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
299
|
+
.auth(Single.new('global')))
|
300
|
+
.response(new_response_handler
|
301
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
302
|
+
.is_api_response(true)
|
303
|
+
.convertor(ApiResponse.method(:create)))
|
304
|
+
.execute
|
428
305
|
end
|
429
306
|
|
430
307
|
# Retrieves a [custom attribute]($m/CustomAttribute) associated with a
|
@@ -439,15 +316,15 @@ module Square
|
|
439
316
|
# (also known as custom fields) are always set to
|
440
317
|
# `VISIBILITY_READ_WRITE_VALUES`.
|
441
318
|
# @param [String] customer_id Required parameter: The ID of the target
|
442
|
-
# [customer profile](
|
319
|
+
# [customer profile](entity:Customer).
|
443
320
|
# @param [String] key Required parameter: The key of the custom attribute to
|
444
321
|
# retrieve. This key must match the `key` of a custom attribute definition
|
445
322
|
# in the Square seller account. If the requesting application is not the
|
446
323
|
# definition owner, you must use the qualified key.
|
447
324
|
# @param [TrueClass|FalseClass] with_definition Optional parameter:
|
448
325
|
# Indicates whether to return the [custom attribute
|
449
|
-
# definition](
|
450
|
-
# custom attribute. Set this parameter to `true` to get the name and
|
326
|
+
# definition](entity:CustomAttributeDefinition) in the `definition` field of
|
327
|
+
# the custom attribute. Set this parameter to `true` to get the name and
|
451
328
|
# description of the custom attribute, information about the data type, or
|
452
329
|
# other definition details. The default value is `false`.
|
453
330
|
# @param [Integer] version Optional parameter: The current version of the
|
@@ -461,40 +338,23 @@ module Square
|
|
461
338
|
key:,
|
462
339
|
with_definition: false,
|
463
340
|
version: nil)
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
'accept' => 'application/json'
|
482
|
-
}
|
483
|
-
|
484
|
-
# Prepare and execute HttpRequest.
|
485
|
-
_request = config.http_client.get(
|
486
|
-
_query_url,
|
487
|
-
headers: _headers
|
488
|
-
)
|
489
|
-
OAuth2.apply(config, _request)
|
490
|
-
_response = execute_request(_request)
|
491
|
-
|
492
|
-
# Return appropriate response type.
|
493
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
494
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
495
|
-
ApiResponse.new(
|
496
|
-
_response, data: decoded, errors: _errors
|
497
|
-
)
|
341
|
+
new_api_call_builder
|
342
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
343
|
+
'/v2/customers/{customer_id}/custom-attributes/{key}',
|
344
|
+
'default')
|
345
|
+
.template_param(new_parameter(customer_id, key: 'customer_id')
|
346
|
+
.should_encode(true))
|
347
|
+
.template_param(new_parameter(key, key: 'key')
|
348
|
+
.should_encode(true))
|
349
|
+
.query_param(new_parameter(with_definition, key: 'with_definition'))
|
350
|
+
.query_param(new_parameter(version, key: 'version'))
|
351
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
352
|
+
.auth(Single.new('global')))
|
353
|
+
.response(new_response_handler
|
354
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
355
|
+
.is_api_response(true)
|
356
|
+
.convertor(ApiResponse.method(:create)))
|
357
|
+
.execute
|
498
358
|
end
|
499
359
|
|
500
360
|
# Creates or updates a [custom attribute]($m/CustomAttribute) for a customer
|
@@ -513,7 +373,7 @@ module Square
|
|
513
373
|
# (also known as custom fields) are always set to
|
514
374
|
# `VISIBILITY_READ_WRITE_VALUES`.
|
515
375
|
# @param [String] customer_id Required parameter: The ID of the target
|
516
|
-
# [customer profile](
|
376
|
+
# [customer profile](entity:Customer).
|
517
377
|
# @param [String] key Required parameter: The key of the custom attribute to
|
518
378
|
# create or update. This key must match the `key` of a custom attribute
|
519
379
|
# definition in the Square seller account. If the requesting application is
|
@@ -525,37 +385,24 @@ module Square
|
|
525
385
|
def upsert_customer_custom_attribute(customer_id:,
|
526
386
|
key:,
|
527
387
|
body:)
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
_query_url,
|
547
|
-
headers: _headers,
|
548
|
-
parameters: body.to_json
|
549
|
-
)
|
550
|
-
OAuth2.apply(config, _request)
|
551
|
-
_response = execute_request(_request)
|
552
|
-
|
553
|
-
# Return appropriate response type.
|
554
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
555
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
556
|
-
ApiResponse.new(
|
557
|
-
_response, data: decoded, errors: _errors
|
558
|
-
)
|
388
|
+
new_api_call_builder
|
389
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
390
|
+
'/v2/customers/{customer_id}/custom-attributes/{key}',
|
391
|
+
'default')
|
392
|
+
.template_param(new_parameter(customer_id, key: 'customer_id')
|
393
|
+
.should_encode(true))
|
394
|
+
.template_param(new_parameter(key, key: 'key')
|
395
|
+
.should_encode(true))
|
396
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
397
|
+
.body_param(new_parameter(body))
|
398
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
399
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
400
|
+
.auth(Single.new('global')))
|
401
|
+
.response(new_response_handler
|
402
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
403
|
+
.is_api_response(true)
|
404
|
+
.convertor(ApiResponse.method(:create)))
|
405
|
+
.execute
|
559
406
|
end
|
560
407
|
end
|
561
408
|
end
|