square.rb 19.0.0.20220420 → 21.0.0.20220720
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 +6 -0
- data/lib/square/api/base_api.rb +8 -1
- data/lib/square/api/bookings_api.rb +12 -3
- data/lib/square/api/cards_api.rb +3 -2
- data/lib/square/api/catalog_api.rb +25 -25
- data/lib/square/api/checkout_api.rb +202 -0
- data/lib/square/api/customer_custom_attributes_api.rb +540 -0
- data/lib/square/api/customers_api.rb +1 -1
- data/lib/square/api/gift_card_activities_api.rb +5 -6
- data/lib/square/api/gift_cards_api.rb +8 -7
- data/lib/square/api/loyalty_api.rb +3 -2
- data/lib/square/api/orders_api.rb +2 -2
- data/lib/square/api/payments_api.rb +1 -1
- data/lib/square/api/terminal_api.rb +141 -0
- data/lib/square/api/v1_transactions_api.rb +4 -4
- data/lib/square/api_helper.rb +176 -4
- data/lib/square/client.rb +12 -6
- data/lib/square/configuration.rb +16 -11
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +5 -4
- data/lib/square.rb +2 -0
- data/test/test_helper.rb +1 -1
- metadata +24 -2
@@ -0,0 +1,540 @@
|
|
1
|
+
module Square
|
2
|
+
# CustomerCustomAttributesApi
|
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
|
+
# Lists the customer-related custom attribute definitions that belong to a
|
9
|
+
# Square seller account.
|
10
|
+
# When all response pages are retrieved, the results include all custom
|
11
|
+
# attribute definitions
|
12
|
+
# that are visible to the requesting application, including those that are
|
13
|
+
# created by other
|
14
|
+
# applications and set to `VISIBILITY_READ_ONLY` or
|
15
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
16
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
17
|
+
# to return in a single paged response. This limit is advisory. The response
|
18
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
19
|
+
# maximum value is 100. The default value is 20. For more information, see
|
20
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
21
|
+
# atterns/pagination).
|
22
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
23
|
+
# paged response from the previous call to this endpoint. Provide this
|
24
|
+
# cursor to retrieve the next page of results for your original request. For
|
25
|
+
# more information, see
|
26
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
27
|
+
# atterns/pagination).
|
28
|
+
# @return [ListCustomerCustomAttributeDefinitionsResponse Hash] response from the API call
|
29
|
+
def list_customer_custom_attribute_definitions(limit: nil,
|
30
|
+
cursor: nil)
|
31
|
+
# Prepare query url.
|
32
|
+
_query_builder = config.get_base_uri
|
33
|
+
_query_builder << '/v2/customers/custom-attribute-definitions'
|
34
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
35
|
+
_query_builder,
|
36
|
+
'limit' => limit,
|
37
|
+
'cursor' => cursor
|
38
|
+
)
|
39
|
+
_query_url = APIHelper.clean_url _query_builder
|
40
|
+
|
41
|
+
# Prepare headers.
|
42
|
+
_headers = {
|
43
|
+
'accept' => 'application/json'
|
44
|
+
}
|
45
|
+
|
46
|
+
# Prepare and execute HttpRequest.
|
47
|
+
_request = config.http_client.get(
|
48
|
+
_query_url,
|
49
|
+
headers: _headers
|
50
|
+
)
|
51
|
+
OAuth2.apply(config, _request)
|
52
|
+
_response = execute_request(_request)
|
53
|
+
|
54
|
+
# Return appropriate response type.
|
55
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
56
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
57
|
+
ApiResponse.new(
|
58
|
+
_response, data: decoded, errors: _errors
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Creates a customer-related custom attribute definition for a Square seller
|
63
|
+
# account. Use this
|
64
|
+
# endpoint to define a custom attribute that can be associated with customer
|
65
|
+
# profiles.
|
66
|
+
# A custom attribute definition specifies the `key`, `visibility`, `schema`,
|
67
|
+
# and other properties
|
68
|
+
# for a custom attribute. After the definition is created, you can call
|
69
|
+
# [UpsertCustomerCustomAttribute]($e/CustomerCustomAttributes/UpsertCustomer
|
70
|
+
# CustomAttribute) or
|
71
|
+
# [BulkUpsertCustomerCustomAttributes]($e/CustomerCustomAttributes/BulkUpser
|
72
|
+
# tCustomerCustomAttributes)
|
73
|
+
# to set the custom attribute for customer profiles in the seller's Customer
|
74
|
+
# Directory.
|
75
|
+
# Sellers can view all custom attributes in exported customer data,
|
76
|
+
# including those set to
|
77
|
+
# `VISIBILITY_HIDDEN`.
|
78
|
+
# @param [CreateCustomerCustomAttributeDefinitionRequest] body Required
|
79
|
+
# parameter: An object containing the fields to POST for the request. See
|
80
|
+
# the corresponding object definition for field details.
|
81
|
+
# @return [CreateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
82
|
+
def create_customer_custom_attribute_definition(body:)
|
83
|
+
# Prepare query url.
|
84
|
+
_query_builder = config.get_base_uri
|
85
|
+
_query_builder << '/v2/customers/custom-attribute-definitions'
|
86
|
+
_query_url = APIHelper.clean_url _query_builder
|
87
|
+
|
88
|
+
# Prepare headers.
|
89
|
+
_headers = {
|
90
|
+
'accept' => 'application/json',
|
91
|
+
'Content-Type' => 'application/json'
|
92
|
+
}
|
93
|
+
|
94
|
+
# Prepare and execute HttpRequest.
|
95
|
+
_request = config.http_client.post(
|
96
|
+
_query_url,
|
97
|
+
headers: _headers,
|
98
|
+
parameters: body.to_json
|
99
|
+
)
|
100
|
+
OAuth2.apply(config, _request)
|
101
|
+
_response = execute_request(_request)
|
102
|
+
|
103
|
+
# Return appropriate response type.
|
104
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
105
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
106
|
+
ApiResponse.new(
|
107
|
+
_response, data: decoded, errors: _errors
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Deletes a customer-related custom attribute definition from a Square
|
112
|
+
# seller account.
|
113
|
+
# Deleting a custom attribute definition also deletes the corresponding
|
114
|
+
# custom attribute from
|
115
|
+
# all customer profiles in the seller's Customer Directory.
|
116
|
+
# Only the definition owner can delete a custom attribute definition.
|
117
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
118
|
+
# definition to delete.
|
119
|
+
# @return [DeleteCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
120
|
+
def delete_customer_custom_attribute_definition(key:)
|
121
|
+
# Prepare query url.
|
122
|
+
_query_builder = config.get_base_uri
|
123
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
124
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
125
|
+
_query_builder,
|
126
|
+
'key' => { 'value' => key, 'encode' => true }
|
127
|
+
)
|
128
|
+
_query_url = APIHelper.clean_url _query_builder
|
129
|
+
|
130
|
+
# Prepare headers.
|
131
|
+
_headers = {
|
132
|
+
'accept' => 'application/json'
|
133
|
+
}
|
134
|
+
|
135
|
+
# Prepare and execute HttpRequest.
|
136
|
+
_request = config.http_client.delete(
|
137
|
+
_query_url,
|
138
|
+
headers: _headers
|
139
|
+
)
|
140
|
+
OAuth2.apply(config, _request)
|
141
|
+
_response = execute_request(_request)
|
142
|
+
|
143
|
+
# Return appropriate response type.
|
144
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
145
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
146
|
+
ApiResponse.new(
|
147
|
+
_response, data: decoded, errors: _errors
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Retrieves a customer-related custom attribute definition from a Square
|
152
|
+
# seller account.
|
153
|
+
# To retrieve a custom attribute definition created by another application,
|
154
|
+
# the `visibility`
|
155
|
+
# setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
156
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
157
|
+
# definition to retrieve. If the requesting application is not the
|
158
|
+
# definition owner, you must use the qualified key.
|
159
|
+
# @param [Integer] version Optional parameter: The current version of the
|
160
|
+
# custom attribute definition, which is used for strongly consistent reads
|
161
|
+
# to guarantee that you receive the most up-to-date data. When included in
|
162
|
+
# the request, Square returns the specified version or a higher version if
|
163
|
+
# one exists. If the specified version is higher than the current version,
|
164
|
+
# Square returns a `BAD_REQUEST` error.
|
165
|
+
# @return [RetrieveCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
166
|
+
def retrieve_customer_custom_attribute_definition(key:,
|
167
|
+
version: nil)
|
168
|
+
# Prepare query url.
|
169
|
+
_query_builder = config.get_base_uri
|
170
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
171
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
172
|
+
_query_builder,
|
173
|
+
'key' => { 'value' => key, 'encode' => true }
|
174
|
+
)
|
175
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'version' => version
|
178
|
+
)
|
179
|
+
_query_url = APIHelper.clean_url _query_builder
|
180
|
+
|
181
|
+
# Prepare headers.
|
182
|
+
_headers = {
|
183
|
+
'accept' => 'application/json'
|
184
|
+
}
|
185
|
+
|
186
|
+
# Prepare and execute HttpRequest.
|
187
|
+
_request = config.http_client.get(
|
188
|
+
_query_url,
|
189
|
+
headers: _headers
|
190
|
+
)
|
191
|
+
OAuth2.apply(config, _request)
|
192
|
+
_response = execute_request(_request)
|
193
|
+
|
194
|
+
# Return appropriate response type.
|
195
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
196
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
197
|
+
ApiResponse.new(
|
198
|
+
_response, data: decoded, errors: _errors
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Updates a customer-related custom attribute definition for a Square seller
|
203
|
+
# account.
|
204
|
+
# Use this endpoint to update the following fields: `name`, `description`,
|
205
|
+
# `visibility`, or the
|
206
|
+
# `schema` for a `Selection` data type.
|
207
|
+
# Only the definition owner can update a custom attribute definition. Note
|
208
|
+
# that sellers can view
|
209
|
+
# all custom attributes in exported customer data, including those set to
|
210
|
+
# `VISIBILITY_HIDDEN`.
|
211
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
212
|
+
# definition to update.
|
213
|
+
# @param [UpdateCustomerCustomAttributeDefinitionRequest] body Required
|
214
|
+
# parameter: An object containing the fields to POST for the request. See
|
215
|
+
# the corresponding object definition for field details.
|
216
|
+
# @return [UpdateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
217
|
+
def update_customer_custom_attribute_definition(key:,
|
218
|
+
body:)
|
219
|
+
# Prepare query url.
|
220
|
+
_query_builder = config.get_base_uri
|
221
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
222
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
223
|
+
_query_builder,
|
224
|
+
'key' => { 'value' => key, 'encode' => true }
|
225
|
+
)
|
226
|
+
_query_url = APIHelper.clean_url _query_builder
|
227
|
+
|
228
|
+
# Prepare headers.
|
229
|
+
_headers = {
|
230
|
+
'accept' => 'application/json',
|
231
|
+
'Content-Type' => 'application/json'
|
232
|
+
}
|
233
|
+
|
234
|
+
# Prepare and execute HttpRequest.
|
235
|
+
_request = config.http_client.put(
|
236
|
+
_query_url,
|
237
|
+
headers: _headers,
|
238
|
+
parameters: body.to_json
|
239
|
+
)
|
240
|
+
OAuth2.apply(config, _request)
|
241
|
+
_response = execute_request(_request)
|
242
|
+
|
243
|
+
# Return appropriate response type.
|
244
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
245
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
246
|
+
ApiResponse.new(
|
247
|
+
_response, data: decoded, errors: _errors
|
248
|
+
)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Creates or updates custom attributes for customer profiles as a bulk
|
252
|
+
# operation.
|
253
|
+
# Use this endpoint to set the value of one or more custom attributes for
|
254
|
+
# one or more customer profiles.
|
255
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
256
|
+
# seller account, which is
|
257
|
+
# created using the
|
258
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
259
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
260
|
+
# This `BulkUpsertCustomerCustomAttributes` endpoint accepts a map of 1 to
|
261
|
+
# 25 individual upsert
|
262
|
+
# requests and returns a map of individual upsert responses. Each upsert
|
263
|
+
# request has a unique ID
|
264
|
+
# and provides a customer ID and custom attribute. Each upsert response is
|
265
|
+
# returned with the ID
|
266
|
+
# of the corresponding request.
|
267
|
+
# To create or update a custom attribute owned by another application, the
|
268
|
+
# `visibility` setting
|
269
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
270
|
+
# @param [BulkUpsertCustomerCustomAttributesRequest] body Required
|
271
|
+
# parameter: An object containing the fields to POST for the request. See
|
272
|
+
# the corresponding object definition for field details.
|
273
|
+
# @return [BulkUpsertCustomerCustomAttributesResponse Hash] response from the API call
|
274
|
+
def bulk_upsert_customer_custom_attributes(body:)
|
275
|
+
# Prepare query url.
|
276
|
+
_query_builder = config.get_base_uri
|
277
|
+
_query_builder << '/v2/customers/custom-attributes/bulk-upsert'
|
278
|
+
_query_url = APIHelper.clean_url _query_builder
|
279
|
+
|
280
|
+
# Prepare headers.
|
281
|
+
_headers = {
|
282
|
+
'accept' => 'application/json',
|
283
|
+
'Content-Type' => 'application/json'
|
284
|
+
}
|
285
|
+
|
286
|
+
# Prepare and execute HttpRequest.
|
287
|
+
_request = config.http_client.post(
|
288
|
+
_query_url,
|
289
|
+
headers: _headers,
|
290
|
+
parameters: body.to_json
|
291
|
+
)
|
292
|
+
OAuth2.apply(config, _request)
|
293
|
+
_response = execute_request(_request)
|
294
|
+
|
295
|
+
# Return appropriate response type.
|
296
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
297
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
298
|
+
ApiResponse.new(
|
299
|
+
_response, data: decoded, errors: _errors
|
300
|
+
)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Lists the custom attributes associated with a customer profile.
|
304
|
+
# You can use the `with_definitions` query parameter to also retrieve custom
|
305
|
+
# attribute definitions
|
306
|
+
# in the same call.
|
307
|
+
# When all response pages are retrieved, the results include all custom
|
308
|
+
# attributes that are
|
309
|
+
# visible to the requesting application, including those that are owned by
|
310
|
+
# other applications
|
311
|
+
# and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
312
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
313
|
+
# [customer profile]($m/Customer).
|
314
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
315
|
+
# to return in a single paged response. This limit is advisory. The response
|
316
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
317
|
+
# maximum value is 100. The default value is 20. For more information, see
|
318
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
319
|
+
# atterns/pagination).
|
320
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
321
|
+
# paged response from the previous call to this endpoint. Provide this
|
322
|
+
# cursor to retrieve the next page of results for your original request. For
|
323
|
+
# more information, see
|
324
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
325
|
+
# atterns/pagination).
|
326
|
+
# @param [TrueClass|FalseClass] with_definitions Optional parameter:
|
327
|
+
# Indicates whether to return the [custom attribute
|
328
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of
|
329
|
+
# each custom attribute. Set this parameter to `true` to get the name and
|
330
|
+
# description of each custom attribute, information about the data type, or
|
331
|
+
# other definition details. The default value is `false`.
|
332
|
+
# @return [ListCustomerCustomAttributesResponse Hash] response from the API call
|
333
|
+
def list_customer_custom_attributes(customer_id:,
|
334
|
+
limit: nil,
|
335
|
+
cursor: nil,
|
336
|
+
with_definitions: false)
|
337
|
+
# Prepare query url.
|
338
|
+
_query_builder = config.get_base_uri
|
339
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes'
|
340
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
|
+
_query_builder,
|
342
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
343
|
+
)
|
344
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
345
|
+
_query_builder,
|
346
|
+
'limit' => limit,
|
347
|
+
'cursor' => cursor,
|
348
|
+
'with_definitions' => with_definitions
|
349
|
+
)
|
350
|
+
_query_url = APIHelper.clean_url _query_builder
|
351
|
+
|
352
|
+
# Prepare headers.
|
353
|
+
_headers = {
|
354
|
+
'accept' => 'application/json'
|
355
|
+
}
|
356
|
+
|
357
|
+
# Prepare and execute HttpRequest.
|
358
|
+
_request = config.http_client.get(
|
359
|
+
_query_url,
|
360
|
+
headers: _headers
|
361
|
+
)
|
362
|
+
OAuth2.apply(config, _request)
|
363
|
+
_response = execute_request(_request)
|
364
|
+
|
365
|
+
# Return appropriate response type.
|
366
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
367
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
368
|
+
ApiResponse.new(
|
369
|
+
_response, data: decoded, errors: _errors
|
370
|
+
)
|
371
|
+
end
|
372
|
+
|
373
|
+
# Deletes a custom attribute associated with a customer profile.
|
374
|
+
# To delete a custom attribute owned by another application, the
|
375
|
+
# `visibility` setting must be
|
376
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
377
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
378
|
+
# [customer profile]($m/Customer).
|
379
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
380
|
+
# delete. This key must match the `key` of a custom attribute definition in
|
381
|
+
# the Square seller account. If the requesting application is not the
|
382
|
+
# definition owner, you must use the qualified key.
|
383
|
+
# @return [DeleteCustomerCustomAttributeResponse Hash] response from the API call
|
384
|
+
def delete_customer_custom_attribute(customer_id:,
|
385
|
+
key:)
|
386
|
+
# Prepare query url.
|
387
|
+
_query_builder = config.get_base_uri
|
388
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
389
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
390
|
+
_query_builder,
|
391
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
392
|
+
'key' => { 'value' => key, 'encode' => true }
|
393
|
+
)
|
394
|
+
_query_url = APIHelper.clean_url _query_builder
|
395
|
+
|
396
|
+
# Prepare headers.
|
397
|
+
_headers = {
|
398
|
+
'accept' => 'application/json'
|
399
|
+
}
|
400
|
+
|
401
|
+
# Prepare and execute HttpRequest.
|
402
|
+
_request = config.http_client.delete(
|
403
|
+
_query_url,
|
404
|
+
headers: _headers
|
405
|
+
)
|
406
|
+
OAuth2.apply(config, _request)
|
407
|
+
_response = execute_request(_request)
|
408
|
+
|
409
|
+
# Return appropriate response type.
|
410
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
411
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
412
|
+
ApiResponse.new(
|
413
|
+
_response, data: decoded, errors: _errors
|
414
|
+
)
|
415
|
+
end
|
416
|
+
|
417
|
+
# Retrieves a custom attribute associated with a customer profile.
|
418
|
+
# You can use the `with_definition` query parameter to also retrieve the
|
419
|
+
# custom attribute definition
|
420
|
+
# in the same call.
|
421
|
+
# To retrieve a custom attribute owned by another application, the
|
422
|
+
# `visibility` setting must be
|
423
|
+
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
424
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
425
|
+
# [customer profile]($m/Customer).
|
426
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
427
|
+
# retrieve. This key must match the `key` of a custom attribute definition
|
428
|
+
# in the Square seller account. If the requesting application is not the
|
429
|
+
# definition owner, you must use the qualified key.
|
430
|
+
# @param [TrueClass|FalseClass] with_definition Optional parameter:
|
431
|
+
# Indicates whether to return the [custom attribute
|
432
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of the
|
433
|
+
# custom attribute. Set this parameter to `true` to get the name and
|
434
|
+
# description of the custom attribute, information about the data type, or
|
435
|
+
# other definition details. The default value is `false`.
|
436
|
+
# @param [Integer] version Optional parameter: The current version of the
|
437
|
+
# custom attribute, which is used for strongly consistent reads to guarantee
|
438
|
+
# that you receive the most up-to-date data. When included in the request,
|
439
|
+
# Square returns the specified version or a higher version if one exists. If
|
440
|
+
# the specified version is higher than the current version, Square returns a
|
441
|
+
# `BAD_REQUEST` error.
|
442
|
+
# @return [RetrieveCustomerCustomAttributeResponse Hash] response from the API call
|
443
|
+
def retrieve_customer_custom_attribute(customer_id:,
|
444
|
+
key:,
|
445
|
+
with_definition: false,
|
446
|
+
version: nil)
|
447
|
+
# Prepare query url.
|
448
|
+
_query_builder = config.get_base_uri
|
449
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
450
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
451
|
+
_query_builder,
|
452
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
453
|
+
'key' => { 'value' => key, 'encode' => true }
|
454
|
+
)
|
455
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
456
|
+
_query_builder,
|
457
|
+
'with_definition' => with_definition,
|
458
|
+
'version' => version
|
459
|
+
)
|
460
|
+
_query_url = APIHelper.clean_url _query_builder
|
461
|
+
|
462
|
+
# Prepare headers.
|
463
|
+
_headers = {
|
464
|
+
'accept' => 'application/json'
|
465
|
+
}
|
466
|
+
|
467
|
+
# Prepare and execute HttpRequest.
|
468
|
+
_request = config.http_client.get(
|
469
|
+
_query_url,
|
470
|
+
headers: _headers
|
471
|
+
)
|
472
|
+
OAuth2.apply(config, _request)
|
473
|
+
_response = execute_request(_request)
|
474
|
+
|
475
|
+
# Return appropriate response type.
|
476
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
477
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
478
|
+
ApiResponse.new(
|
479
|
+
_response, data: decoded, errors: _errors
|
480
|
+
)
|
481
|
+
end
|
482
|
+
|
483
|
+
# Creates or updates a custom attribute for a customer profile.
|
484
|
+
# Use this endpoint to set the value of a custom attribute for a specified
|
485
|
+
# customer profile.
|
486
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
487
|
+
# seller account, which
|
488
|
+
# is created using the
|
489
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
490
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
491
|
+
# To create or update a custom attribute owned by another application, the
|
492
|
+
# `visibility` setting
|
493
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
494
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
495
|
+
# [customer profile]($m/Customer).
|
496
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
497
|
+
# create or update. This key must match the `key` of a custom attribute
|
498
|
+
# definition in the Square seller account. If the requesting application is
|
499
|
+
# not the definition owner, you must use the qualified key.
|
500
|
+
# @param [UpsertCustomerCustomAttributeRequest] body Required parameter: An
|
501
|
+
# object containing the fields to POST for the request. See the
|
502
|
+
# corresponding object definition for field details.
|
503
|
+
# @return [UpsertCustomerCustomAttributeResponse Hash] response from the API call
|
504
|
+
def upsert_customer_custom_attribute(customer_id:,
|
505
|
+
key:,
|
506
|
+
body:)
|
507
|
+
# Prepare query url.
|
508
|
+
_query_builder = config.get_base_uri
|
509
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
510
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
511
|
+
_query_builder,
|
512
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
513
|
+
'key' => { 'value' => key, 'encode' => true }
|
514
|
+
)
|
515
|
+
_query_url = APIHelper.clean_url _query_builder
|
516
|
+
|
517
|
+
# Prepare headers.
|
518
|
+
_headers = {
|
519
|
+
'accept' => 'application/json',
|
520
|
+
'Content-Type' => 'application/json'
|
521
|
+
}
|
522
|
+
|
523
|
+
# Prepare and execute HttpRequest.
|
524
|
+
_request = config.http_client.post(
|
525
|
+
_query_url,
|
526
|
+
headers: _headers,
|
527
|
+
parameters: body.to_json
|
528
|
+
)
|
529
|
+
OAuth2.apply(config, _request)
|
530
|
+
_response = execute_request(_request)
|
531
|
+
|
532
|
+
# Return appropriate response type.
|
533
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
534
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
535
|
+
ApiResponse.new(
|
536
|
+
_response, data: decoded, errors: _errors
|
537
|
+
)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
end
|
@@ -165,7 +165,7 @@ module Square
|
|
165
165
|
# profiles, you must use the ID of the newly created profile.
|
166
166
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
167
167
|
# delete.
|
168
|
-
# @param [
|
168
|
+
# @param [Integer] version Optional parameter: The current version of the
|
169
169
|
# customer profile. As a best practice, you should include this parameter
|
170
170
|
# to enable [optimistic
|
171
171
|
# concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
|
@@ -91,12 +91,11 @@ module Square
|
|
91
91
|
)
|
92
92
|
end
|
93
93
|
|
94
|
-
# Creates a gift card activity
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# #using-activated-gift-cards).
|
94
|
+
# Creates a gift card activity to manage the balance or state of a [gift
|
95
|
+
# card]($m/GiftCard).
|
96
|
+
# For example, you create an `ACTIVATE` activity to activate a gift card
|
97
|
+
# with an initial balance
|
98
|
+
# before the gift card can be used.
|
100
99
|
# @param [CreateGiftCardActivityRequest] body Required parameter: An object
|
101
100
|
# containing the fields to POST for the request. See the corresponding
|
102
101
|
# object definition for field details.
|
@@ -6,7 +6,8 @@ module Square
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Lists all gift cards. You can specify optional filters to retrieve
|
9
|
-
# a subset of the gift cards.
|
9
|
+
# a subset of the gift cards. Results are sorted by `created_at` in
|
10
|
+
# ascending order.
|
10
11
|
# @param [String] type Optional parameter: If a [type]($m/GiftCardType) is
|
11
12
|
# provided, the endpoint returns gift cards of the specified type.
|
12
13
|
# Otherwise, the endpoint returns gift cards of all types.
|
@@ -68,11 +69,11 @@ module Square
|
|
68
69
|
end
|
69
70
|
|
70
71
|
# Creates a digital gift card or registers a physical (plastic) gift card.
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# [
|
74
|
-
#
|
75
|
-
#
|
72
|
+
# After the gift card
|
73
|
+
# is created, you must call
|
74
|
+
# [CreateGiftCardActivity]($e/GiftCardActivities/CreateGiftCardActivity)
|
75
|
+
# to activate the card with an initial balance before it can be used for
|
76
|
+
# payment.
|
76
77
|
# @param [CreateGiftCardRequest] body Required parameter: An object
|
77
78
|
# containing the fields to POST for the request. See the corresponding
|
78
79
|
# object definition for field details.
|
@@ -259,7 +260,7 @@ module Square
|
|
259
260
|
)
|
260
261
|
end
|
261
262
|
|
262
|
-
# Retrieves a gift card using
|
263
|
+
# Retrieves a gift card using the gift card ID.
|
263
264
|
# @param [String] id Required parameter: The ID of the gift card to
|
264
265
|
# retrieve.
|
265
266
|
# @return [RetrieveGiftCardResponse Hash] response from the API call
|
@@ -113,7 +113,7 @@ module Square
|
|
113
113
|
)
|
114
114
|
end
|
115
115
|
|
116
|
-
# Adds points to a loyalty account.
|
116
|
+
# Adds points earned from the base loyalty program to a loyalty account.
|
117
117
|
# - If you are using the Orders API to manage orders, you only provide the
|
118
118
|
# `order_id`.
|
119
119
|
# The endpoint reads the order to compute points to add to the buyer's
|
@@ -124,6 +124,7 @@ module Square
|
|
124
124
|
# [CalculateLoyaltyPoints]($e/Loyalty/CalculateLoyaltyPoints) to compute the
|
125
125
|
# points
|
126
126
|
# that you provide to this endpoint.
|
127
|
+
# This endpoint excludes additional points earned from loyalty promotions.
|
127
128
|
# @param [String] account_id Required parameter: The [loyalty
|
128
129
|
# account]($m/LoyaltyAccount) ID to which to add the points.
|
129
130
|
# @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
|
@@ -329,7 +330,7 @@ module Square
|
|
329
330
|
)
|
330
331
|
end
|
331
332
|
|
332
|
-
# Calculates the points a purchase earns.
|
333
|
+
# Calculates the points a purchase earns from the base loyalty program.
|
333
334
|
# - If you are using the Orders API to manage orders, you provide the
|
334
335
|
# `order_id` in the request. The
|
335
336
|
# endpoint calculates the points by reading the order.
|
@@ -244,8 +244,8 @@ module Square
|
|
244
244
|
# - The `order_id` in the endpoint path, identifying the order to update.
|
245
245
|
# - The latest `version` of the order to update.
|
246
246
|
# - The [sparse
|
247
|
-
# order](https://developer.squareup.com/docs/orders-api/manage-orders
|
248
|
-
# -order-objects)
|
247
|
+
# order](https://developer.squareup.com/docs/orders-api/manage-orders/update
|
248
|
+
# -orders#sparse-order-objects)
|
249
249
|
# containing only the fields to update and the version to which the update
|
250
250
|
# is
|
251
251
|
# being applied.
|
@@ -26,7 +26,7 @@ module Square
|
|
26
26
|
# @param [String] location_id Optional parameter: Limit results to the
|
27
27
|
# location supplied. By default, results are returned for the default (main)
|
28
28
|
# location associated with the seller.
|
29
|
-
# @param [
|
29
|
+
# @param [Integer] total Optional parameter: The exact amount in the
|
30
30
|
# `total_money` for a payment.
|
31
31
|
# @param [String] last_4 Optional parameter: The last four digits of a
|
32
32
|
# payment card.
|