square.rb 8.0.0.20201216 → 26.1.0.20230119
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/README.md +79 -221
- data/lib/square/api/apple_pay_api.rb +15 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +27 -9
- data/lib/square/api/booking_custom_attributes_api.rb +555 -0
- data/lib/square/api/bookings_api.rb +107 -15
- data/lib/square/api/cards_api.rb +171 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +167 -73
- data/lib/square/api/checkout_api.rb +205 -3
- data/lib/square/api/customer_custom_attributes_api.rb +561 -0
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +67 -33
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +109 -105
- data/lib/square/api/gift_card_activities_api.rb +132 -0
- data/lib/square/api/gift_cards_api.rb +298 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +21 -21
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/api/locations_api.rb +21 -14
- data/lib/square/api/loyalty_api.rb +333 -50
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +78 -25
- data/lib/square/api/order_custom_attributes_api.rb +601 -0
- data/lib/square/api/orders_api.rb +84 -45
- data/lib/square/api/payments_api.rb +72 -24
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -15
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +172 -22
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +52 -124
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api/webhook_subscriptions_api.rb +327 -0
- data/lib/square/api_helper.rb +217 -57
- data/lib/square/client.rb +90 -18
- data/lib/square/configuration.rb +64 -20
- 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 +40 -9
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +56 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +2 -2
- metadata +83 -15
- data/lib/square/api/v1_employees_api.rb +0 -751
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -0,0 +1,561 @@
|
|
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
|
9
|
+
# definitions]($m/CustomAttributeDefinition) that belong to a Square seller
|
10
|
+
# account.
|
11
|
+
# When all response pages are retrieved, the results include all custom
|
12
|
+
# attribute definitions
|
13
|
+
# that are visible to the requesting application, including those that are
|
14
|
+
# created by other
|
15
|
+
# applications and set to `VISIBILITY_READ_ONLY` or
|
16
|
+
# `VISIBILITY_READ_WRITE_VALUES`. Note that
|
17
|
+
# seller-defined custom attributes (also known as custom fields) are always
|
18
|
+
# set to `VISIBILITY_READ_WRITE_VALUES`.
|
19
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
20
|
+
# to return in a single paged response. This limit is advisory. The response
|
21
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
22
|
+
# maximum value is 100. The default value is 20. For more information, see
|
23
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
24
|
+
# atterns/pagination).
|
25
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
26
|
+
# paged response from the previous call to this endpoint. Provide this
|
27
|
+
# cursor to retrieve the next page of results for your original request. For
|
28
|
+
# more information, see
|
29
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
30
|
+
# atterns/pagination).
|
31
|
+
# @return [ListCustomerCustomAttributeDefinitionsResponse Hash] response from the API call
|
32
|
+
def list_customer_custom_attribute_definitions(limit: nil,
|
33
|
+
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
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Creates a customer-related [custom attribute
|
66
|
+
# definition]($m/CustomAttributeDefinition) for a Square seller account.
|
67
|
+
# Use this endpoint to define a custom attribute that can be associated with
|
68
|
+
# customer profiles.
|
69
|
+
# A custom attribute definition specifies the `key`, `visibility`, `schema`,
|
70
|
+
# and other properties
|
71
|
+
# for a custom attribute. After the definition is created, you can call
|
72
|
+
# [UpsertCustomerCustomAttribute]($e/CustomerCustomAttributes/UpsertCustomer
|
73
|
+
# CustomAttribute) or
|
74
|
+
# [BulkUpsertCustomerCustomAttributes]($e/CustomerCustomAttributes/BulkUpser
|
75
|
+
# tCustomerCustomAttributes)
|
76
|
+
# to set the custom attribute for customer profiles in the seller's Customer
|
77
|
+
# Directory.
|
78
|
+
# Sellers can view all custom attributes in exported customer data,
|
79
|
+
# including those set to
|
80
|
+
# `VISIBILITY_HIDDEN`.
|
81
|
+
# @param [CreateCustomerCustomAttributeDefinitionRequest] body Required
|
82
|
+
# parameter: An object containing the fields to POST for the request. See
|
83
|
+
# the corresponding object definition for field details.
|
84
|
+
# @return [CreateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
85
|
+
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
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Deletes a customer-related [custom attribute
|
115
|
+
# definition]($m/CustomAttributeDefinition) from a Square seller account.
|
116
|
+
# Deleting a custom attribute definition also deletes the corresponding
|
117
|
+
# custom attribute from
|
118
|
+
# all customer profiles in the seller's Customer Directory.
|
119
|
+
# Only the definition owner can delete a custom attribute definition.
|
120
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
121
|
+
# definition to delete.
|
122
|
+
# @return [DeleteCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
123
|
+
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
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Retrieves a customer-related [custom attribute
|
155
|
+
# definition]($m/CustomAttributeDefinition) from a Square seller account.
|
156
|
+
# To retrieve a custom attribute definition created by another application,
|
157
|
+
# the `visibility`
|
158
|
+
# setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
159
|
+
# Note that seller-defined custom attributes
|
160
|
+
# (also known as custom fields) are always set to
|
161
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
162
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
163
|
+
# definition to retrieve. If the requesting application is not the
|
164
|
+
# definition owner, you must use the qualified key.
|
165
|
+
# @param [Integer] version Optional parameter: The current version of the
|
166
|
+
# custom attribute definition, which is used for strongly consistent reads
|
167
|
+
# to guarantee that you receive the most up-to-date data. When included in
|
168
|
+
# the request, Square returns the specified version or a higher version if
|
169
|
+
# one exists. If the specified version is higher than the current version,
|
170
|
+
# Square returns a `BAD_REQUEST` error.
|
171
|
+
# @return [RetrieveCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
172
|
+
def retrieve_customer_custom_attribute_definition(key:,
|
173
|
+
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
|
+
)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Updates a customer-related [custom attribute
|
209
|
+
# definition]($m/CustomAttributeDefinition) for a Square seller account.
|
210
|
+
# Use this endpoint to update the following fields: `name`, `description`,
|
211
|
+
# `visibility`, or the
|
212
|
+
# `schema` for a `Selection` data type.
|
213
|
+
# Only the definition owner can update a custom attribute definition. Note
|
214
|
+
# that sellers can view
|
215
|
+
# all custom attributes in exported customer data, including those set to
|
216
|
+
# `VISIBILITY_HIDDEN`.
|
217
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
218
|
+
# definition to update.
|
219
|
+
# @param [UpdateCustomerCustomAttributeDefinitionRequest] body Required
|
220
|
+
# parameter: An object containing the fields to POST for the request. See
|
221
|
+
# the corresponding object definition for field details.
|
222
|
+
# @return [UpdateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
223
|
+
def update_customer_custom_attribute_definition(key:,
|
224
|
+
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
|
+
)
|
255
|
+
end
|
256
|
+
|
257
|
+
# Creates or updates [custom attributes]($m/CustomAttribute) for customer
|
258
|
+
# profiles as a bulk operation.
|
259
|
+
# Use this endpoint to set the value of one or more custom attributes for
|
260
|
+
# one or more customer profiles.
|
261
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
262
|
+
# seller account, which is
|
263
|
+
# created using the
|
264
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
265
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
266
|
+
# This `BulkUpsertCustomerCustomAttributes` endpoint accepts a map of 1 to
|
267
|
+
# 25 individual upsert
|
268
|
+
# requests and returns a map of individual upsert responses. Each upsert
|
269
|
+
# request has a unique ID
|
270
|
+
# and provides a customer ID and custom attribute. Each upsert response is
|
271
|
+
# returned with the ID
|
272
|
+
# of the corresponding request.
|
273
|
+
# To create or update a custom attribute owned by another application, the
|
274
|
+
# `visibility` setting
|
275
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
|
276
|
+
# attributes
|
277
|
+
# (also known as custom fields) are always set to
|
278
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
279
|
+
# @param [BulkUpsertCustomerCustomAttributesRequest] body Required
|
280
|
+
# parameter: An object containing the fields to POST for the request. See
|
281
|
+
# the corresponding object definition for field details.
|
282
|
+
# @return [BulkUpsertCustomerCustomAttributesResponse Hash] response from the API call
|
283
|
+
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
|
+
)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Lists the [custom attributes]($m/CustomAttribute) associated with a
|
313
|
+
# customer profile.
|
314
|
+
# You can use the `with_definitions` query parameter to also retrieve custom
|
315
|
+
# attribute definitions
|
316
|
+
# in the same call.
|
317
|
+
# When all response pages are retrieved, the results include all custom
|
318
|
+
# attributes that are
|
319
|
+
# visible to the requesting application, including those that are owned by
|
320
|
+
# other applications
|
321
|
+
# and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
322
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
323
|
+
# [customer profile]($m/Customer).
|
324
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
325
|
+
# to return in a single paged response. This limit is advisory. The response
|
326
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
327
|
+
# maximum value is 100. The default value is 20. For more information, see
|
328
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
329
|
+
# atterns/pagination).
|
330
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
331
|
+
# paged response from the previous call to this endpoint. Provide this
|
332
|
+
# cursor to retrieve the next page of results for your original request. For
|
333
|
+
# more information, see
|
334
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
335
|
+
# atterns/pagination).
|
336
|
+
# @param [TrueClass|FalseClass] with_definitions Optional parameter:
|
337
|
+
# Indicates whether to return the [custom attribute
|
338
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of
|
339
|
+
# each custom attribute. Set this parameter to `true` to get the name and
|
340
|
+
# description of each custom attribute, information about the data type, or
|
341
|
+
# other definition details. The default value is `false`.
|
342
|
+
# @return [ListCustomerCustomAttributesResponse Hash] response from the API call
|
343
|
+
def list_customer_custom_attributes(customer_id:,
|
344
|
+
limit: nil,
|
345
|
+
cursor: nil,
|
346
|
+
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
|
+
)
|
381
|
+
end
|
382
|
+
|
383
|
+
# Deletes a [custom attribute]($m/CustomAttribute) associated with a
|
384
|
+
# customer profile.
|
385
|
+
# To delete a custom attribute owned by another application, the
|
386
|
+
# `visibility` setting must be
|
387
|
+
# `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes
|
388
|
+
# (also known as custom fields) are always set to
|
389
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
390
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
391
|
+
# [customer profile]($m/Customer).
|
392
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
393
|
+
# delete. This key must match the `key` of a custom attribute definition in
|
394
|
+
# the Square seller account. If the requesting application is not the
|
395
|
+
# definition owner, you must use the qualified key.
|
396
|
+
# @return [DeleteCustomerCustomAttributeResponse Hash] response from the API call
|
397
|
+
def delete_customer_custom_attribute(customer_id:,
|
398
|
+
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
|
+
)
|
428
|
+
end
|
429
|
+
|
430
|
+
# Retrieves a [custom attribute]($m/CustomAttribute) associated with a
|
431
|
+
# customer profile.
|
432
|
+
# You can use the `with_definition` query parameter to also retrieve the
|
433
|
+
# custom attribute definition
|
434
|
+
# in the same call.
|
435
|
+
# To retrieve a custom attribute owned by another application, the
|
436
|
+
# `visibility` setting must be
|
437
|
+
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note that
|
438
|
+
# seller-defined custom attributes
|
439
|
+
# (also known as custom fields) are always set to
|
440
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
441
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
442
|
+
# [customer profile]($m/Customer).
|
443
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
444
|
+
# retrieve. This key must match the `key` of a custom attribute definition
|
445
|
+
# in the Square seller account. If the requesting application is not the
|
446
|
+
# definition owner, you must use the qualified key.
|
447
|
+
# @param [TrueClass|FalseClass] with_definition Optional parameter:
|
448
|
+
# Indicates whether to return the [custom attribute
|
449
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of the
|
450
|
+
# custom attribute. Set this parameter to `true` to get the name and
|
451
|
+
# description of the custom attribute, information about the data type, or
|
452
|
+
# other definition details. The default value is `false`.
|
453
|
+
# @param [Integer] version Optional parameter: The current version of the
|
454
|
+
# custom attribute, which is used for strongly consistent reads to guarantee
|
455
|
+
# that you receive the most up-to-date data. When included in the request,
|
456
|
+
# Square returns the specified version or a higher version if one exists. If
|
457
|
+
# the specified version is higher than the current version, Square returns a
|
458
|
+
# `BAD_REQUEST` error.
|
459
|
+
# @return [RetrieveCustomerCustomAttributeResponse Hash] response from the API call
|
460
|
+
def retrieve_customer_custom_attribute(customer_id:,
|
461
|
+
key:,
|
462
|
+
with_definition: false,
|
463
|
+
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
|
+
)
|
498
|
+
end
|
499
|
+
|
500
|
+
# Creates or updates a [custom attribute]($m/CustomAttribute) for a customer
|
501
|
+
# profile.
|
502
|
+
# Use this endpoint to set the value of a custom attribute for a specified
|
503
|
+
# customer profile.
|
504
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
505
|
+
# seller account, which
|
506
|
+
# is created using the
|
507
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
508
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
509
|
+
# To create or update a custom attribute owned by another application, the
|
510
|
+
# `visibility` setting
|
511
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
|
512
|
+
# attributes
|
513
|
+
# (also known as custom fields) are always set to
|
514
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
515
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
516
|
+
# [customer profile]($m/Customer).
|
517
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
518
|
+
# create or update. This key must match the `key` of a custom attribute
|
519
|
+
# definition in the Square seller account. If the requesting application is
|
520
|
+
# not the definition owner, you must use the qualified key.
|
521
|
+
# @param [UpsertCustomerCustomAttributeRequest] body Required parameter: An
|
522
|
+
# object containing the fields to POST for the request. See the
|
523
|
+
# corresponding object definition for field details.
|
524
|
+
# @return [UpsertCustomerCustomAttributeResponse Hash] response from the API call
|
525
|
+
def upsert_customer_custom_attribute(customer_id:,
|
526
|
+
key:,
|
527
|
+
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
|
+
)
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
@@ -7,18 +7,27 @@ module Square
|
|
7
7
|
|
8
8
|
# Retrieves the list of customer groups of a business.
|
9
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
|
-
# a previous call to this endpoint. Provide this to retrieve the next
|
11
|
-
# results for your original query.
|
12
|
-
#
|
13
|
-
#
|
10
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
11
|
+
# set of results for your original query. For more information, see
|
12
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
13
|
+
# atterns/pagination).
|
14
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
15
|
+
# to return in a single page. This limit is advisory. The response might
|
16
|
+
# contain more or fewer results. If the limit is less than 1 or greater than
|
17
|
+
# 50, Square returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error.
|
18
|
+
# The default value is 50. For more information, see
|
19
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
20
|
+
# atterns/pagination).
|
14
21
|
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
15
|
-
def list_customer_groups(cursor: nil
|
22
|
+
def list_customer_groups(cursor: nil,
|
23
|
+
limit: nil)
|
16
24
|
# Prepare query url.
|
17
25
|
_query_builder = config.get_base_uri
|
18
26
|
_query_builder << '/v2/customers/groups'
|
19
27
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
28
|
_query_builder,
|
21
|
-
'cursor' => cursor
|
29
|
+
'cursor' => cursor,
|
30
|
+
'limit' => limit
|
22
31
|
)
|
23
32
|
_query_url = APIHelper.clean_url _query_builder
|
24
33
|
|
@@ -58,7 +67,7 @@ module Square
|
|
58
67
|
# Prepare headers.
|
59
68
|
_headers = {
|
60
69
|
'accept' => 'application/json',
|
61
|
-
'
|
70
|
+
'Content-Type' => 'application/json'
|
62
71
|
}
|
63
72
|
|
64
73
|
# Prepare and execute HttpRequest.
|
@@ -169,7 +178,7 @@ module Square
|
|
169
178
|
# Prepare headers.
|
170
179
|
_headers = {
|
171
180
|
'accept' => 'application/json',
|
172
|
-
'
|
181
|
+
'Content-Type' => 'application/json'
|
173
182
|
}
|
174
183
|
|
175
184
|
# Prepare and execute HttpRequest.
|
@@ -7,18 +7,27 @@ module Square
|
|
7
7
|
|
8
8
|
# Retrieves the list of customer segments of a business.
|
9
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
|
-
# previous calls to
|
11
|
-
# of query results.
|
12
|
-
#
|
13
|
-
#
|
10
|
+
# previous calls to `ListCustomerSegments`. This cursor is used to retrieve
|
11
|
+
# the next set of query results. For more information, see
|
12
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
13
|
+
# atterns/pagination).
|
14
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
15
|
+
# to return in a single page. This limit is advisory. The response might
|
16
|
+
# contain more or fewer results. If the specified limit is less than 1 or
|
17
|
+
# greater than 50, Square returns a `400 VALUE_TOO_LOW` or `400
|
18
|
+
# VALUE_TOO_HIGH` error. The default value is 50. For more information, see
|
19
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
20
|
+
# atterns/pagination).
|
14
21
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
15
|
-
def list_customer_segments(cursor: nil
|
22
|
+
def list_customer_segments(cursor: nil,
|
23
|
+
limit: nil)
|
16
24
|
# Prepare query url.
|
17
25
|
_query_builder = config.get_base_uri
|
18
26
|
_query_builder << '/v2/customers/segments'
|
19
27
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
28
|
_query_builder,
|
21
|
-
'cursor' => cursor
|
29
|
+
'cursor' => cursor,
|
30
|
+
'limit' => limit
|
22
31
|
)
|
23
32
|
_query_url = APIHelper.clean_url _query_builder
|
24
33
|
|