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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/square/api/apple_pay_api.rb +14 -30
  4. data/lib/square/api/bank_accounts_api.rb +40 -90
  5. data/lib/square/api/base_api.rb +42 -42
  6. data/lib/square/api/booking_custom_attributes_api.rb +164 -329
  7. data/lib/square/api/bookings_api.rb +135 -260
  8. data/lib/square/api/cards_api.rb +56 -118
  9. data/lib/square/api/cash_drawers_api.rb +47 -103
  10. data/lib/square/api/catalog_api.rb +197 -423
  11. data/lib/square/api/checkout_api.rb +85 -175
  12. data/lib/square/api/customer_custom_attributes_api.rb +150 -303
  13. data/lib/square/api/customer_groups_api.rb +69 -145
  14. data/lib/square/api/customer_segments_api.rb +26 -61
  15. data/lib/square/api/customers_api.rb +147 -294
  16. data/lib/square/api/devices_api.rb +42 -89
  17. data/lib/square/api/disputes_api.rb +130 -288
  18. data/lib/square/api/employees_api.rb +28 -63
  19. data/lib/square/api/gift_card_activities_api.rb +33 -65
  20. data/lib/square/api/gift_cards_api.rb +103 -202
  21. data/lib/square/api/inventory_api.rb +179 -366
  22. data/lib/square/api/invoices_api.rb +118 -237
  23. data/lib/square/api/labor_api.rb +223 -459
  24. data/lib/square/api/location_custom_attributes_api.rb +419 -0
  25. data/lib/square/api/locations_api.rb +54 -112
  26. data/lib/square/api/loyalty_api.rb +259 -512
  27. data/lib/square/api/merchants_api.rb +25 -60
  28. data/lib/square/api/mobile_authorization_api.rb +14 -30
  29. data/lib/square/api/o_auth_api.rb +54 -109
  30. data/lib/square/api/order_custom_attributes_api.rb +168 -333
  31. data/lib/square/api/orders_api.rb +115 -222
  32. data/lib/square/api/payments_api.rb +106 -208
  33. data/lib/square/api/payouts_api.rb +47 -100
  34. data/lib/square/api/refunds_api.rb +46 -93
  35. data/lib/square/api/sites_api.rb +11 -28
  36. data/lib/square/api/snippets_api.rb +42 -90
  37. data/lib/square/api/subscriptions_api.rb +150 -299
  38. data/lib/square/api/team_api.rb +114 -224
  39. data/lib/square/api/terminal_api.rb +162 -328
  40. data/lib/square/api/transactions_api.rb +62 -126
  41. data/lib/square/api/v1_transactions_api.rb +155 -296
  42. data/lib/square/api/vendors_api.rb +99 -192
  43. data/lib/square/api/webhook_subscriptions_api.rb +115 -235
  44. data/lib/square/api_helper.rb +1 -437
  45. data/lib/square/client.rb +82 -46
  46. data/lib/square/configuration.rb +28 -53
  47. data/lib/square/exceptions/api_exception.rb +1 -11
  48. data/lib/square/http/api_response.rb +13 -19
  49. data/lib/square/http/auth/o_auth2.rb +14 -7
  50. data/lib/square/http/http_call_back.rb +1 -15
  51. data/lib/square/http/http_method_enum.rb +1 -4
  52. data/lib/square/http/http_request.rb +1 -45
  53. data/lib/square/http/http_response.rb +1 -20
  54. data/lib/square/utilities/date_time_helper.rb +1 -146
  55. data/lib/square/utilities/file_wrapper.rb +5 -5
  56. data/lib/square.rb +7 -6
  57. data/spec/user_journey_spec.rb +2 -2
  58. data/test/api/api_test_base.rb +13 -5
  59. data/test/api/test_catalog_api.rb +5 -4
  60. data/test/api/test_customers_api.rb +3 -2
  61. data/test/api/test_employees_api.rb +4 -3
  62. data/test/api/test_labor_api.rb +6 -5
  63. data/test/api/test_locations_api.rb +3 -2
  64. data/test/api/test_merchants_api.rb +4 -3
  65. data/test/api/test_payments_api.rb +4 -3
  66. data/test/api/test_refunds_api.rb +4 -3
  67. metadata +12 -111
  68. data/lib/square/exceptions/validation_exception.rb +0 -13
  69. data/lib/square/http/faraday_client.rb +0 -93
  70. data/lib/square/http/http_client.rb +0 -118
  71. 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
- # Prepare query url.
35
- _query_builder = config.get_base_uri
36
- _query_builder << '/v2/customers/custom-attribute-definitions'
37
- _query_builder = APIHelper.append_url_with_query_parameters(
38
- _query_builder,
39
- 'limit' => limit,
40
- 'cursor' => cursor
41
- )
42
- _query_url = APIHelper.clean_url _query_builder
43
-
44
- # Prepare headers.
45
- _headers = {
46
- 'accept' => 'application/json'
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
- # Prepare query url.
87
- _query_builder = config.get_base_uri
88
- _query_builder << '/v2/customers/custom-attribute-definitions'
89
- _query_url = APIHelper.clean_url _query_builder
90
-
91
- # Prepare headers.
92
- _headers = {
93
- 'accept' => 'application/json',
94
- 'Content-Type' => 'application/json'
95
- }
96
-
97
- # Prepare and execute HttpRequest.
98
- _request = config.http_client.post(
99
- _query_url,
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
- # Prepare query url.
125
- _query_builder = config.get_base_uri
126
- _query_builder << '/v2/customers/custom-attribute-definitions/{key}'
127
- _query_builder = APIHelper.append_url_with_template_parameters(
128
- _query_builder,
129
- 'key' => { 'value' => key, 'encode' => true }
130
- )
131
- _query_url = APIHelper.clean_url _query_builder
132
-
133
- # Prepare headers.
134
- _headers = {
135
- 'accept' => 'application/json'
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
- # Prepare query url.
175
- _query_builder = config.get_base_uri
176
- _query_builder << '/v2/customers/custom-attribute-definitions/{key}'
177
- _query_builder = APIHelper.append_url_with_template_parameters(
178
- _query_builder,
179
- 'key' => { 'value' => key, 'encode' => true }
180
- )
181
- _query_builder = APIHelper.append_url_with_query_parameters(
182
- _query_builder,
183
- 'version' => version
184
- )
185
- _query_url = APIHelper.clean_url _query_builder
186
-
187
- # Prepare headers.
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
- # Prepare query url.
226
- _query_builder = config.get_base_uri
227
- _query_builder << '/v2/customers/custom-attribute-definitions/{key}'
228
- _query_builder = APIHelper.append_url_with_template_parameters(
229
- _query_builder,
230
- 'key' => { 'value' => key, 'encode' => true }
231
- )
232
- _query_url = APIHelper.clean_url _query_builder
233
-
234
- # Prepare headers.
235
- _headers = {
236
- 'accept' => 'application/json',
237
- 'Content-Type' => 'application/json'
238
- }
239
-
240
- # Prepare and execute HttpRequest.
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
- # Prepare query url.
285
- _query_builder = config.get_base_uri
286
- _query_builder << '/v2/customers/custom-attributes/bulk-upsert'
287
- _query_url = APIHelper.clean_url _query_builder
288
-
289
- # Prepare headers.
290
- _headers = {
291
- 'accept' => 'application/json',
292
- 'Content-Type' => 'application/json'
293
- }
294
-
295
- # Prepare and execute HttpRequest.
296
- _request = config.http_client.post(
297
- _query_url,
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
@@ -344,40 +253,22 @@ module Square
344
253
  limit: nil,
345
254
  cursor: nil,
346
255
  with_definitions: false)
347
- # Prepare query url.
348
- _query_builder = config.get_base_uri
349
- _query_builder << '/v2/customers/{customer_id}/custom-attributes'
350
- _query_builder = APIHelper.append_url_with_template_parameters(
351
- _query_builder,
352
- 'customer_id' => { 'value' => customer_id, 'encode' => true }
353
- )
354
- _query_builder = APIHelper.append_url_with_query_parameters(
355
- _query_builder,
356
- 'limit' => limit,
357
- 'cursor' => cursor,
358
- 'with_definitions' => with_definitions
359
- )
360
- _query_url = APIHelper.clean_url _query_builder
361
-
362
- # Prepare headers.
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
@@ -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
- # Prepare query url.
400
- _query_builder = config.get_base_uri
401
- _query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
402
- _query_builder = APIHelper.append_url_with_template_parameters(
403
- _query_builder,
404
- 'customer_id' => { 'value' => customer_id, 'encode' => true },
405
- 'key' => { 'value' => key, 'encode' => true }
406
- )
407
- _query_url = APIHelper.clean_url _query_builder
408
-
409
- # Prepare headers.
410
- _headers = {
411
- 'accept' => 'application/json'
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
@@ -461,40 +338,23 @@ module Square
461
338
  key:,
462
339
  with_definition: false,
463
340
  version: nil)
464
- # Prepare query url.
465
- _query_builder = config.get_base_uri
466
- _query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
467
- _query_builder = APIHelper.append_url_with_template_parameters(
468
- _query_builder,
469
- 'customer_id' => { 'value' => customer_id, 'encode' => true },
470
- 'key' => { 'value' => key, 'encode' => true }
471
- )
472
- _query_builder = APIHelper.append_url_with_query_parameters(
473
- _query_builder,
474
- 'with_definition' => with_definition,
475
- 'version' => version
476
- )
477
- _query_url = APIHelper.clean_url _query_builder
478
-
479
- # Prepare headers.
480
- _headers = {
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
@@ -525,37 +385,24 @@ module Square
525
385
  def upsert_customer_custom_attribute(customer_id:,
526
386
  key:,
527
387
  body:)
528
- # Prepare query url.
529
- _query_builder = config.get_base_uri
530
- _query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
531
- _query_builder = APIHelper.append_url_with_template_parameters(
532
- _query_builder,
533
- 'customer_id' => { 'value' => customer_id, 'encode' => true },
534
- 'key' => { 'value' => key, 'encode' => true }
535
- )
536
- _query_url = APIHelper.clean_url _query_builder
537
-
538
- # Prepare headers.
539
- _headers = {
540
- 'accept' => 'application/json',
541
- 'Content-Type' => 'application/json'
542
- }
543
-
544
- # Prepare and execute HttpRequest.
545
- _request = config.http_client.post(
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