square.rb 9.1.0.20210317 → 12.0.0.20210616
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/square.rb +5 -0
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +3 -5
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +40 -41
- data/lib/square/api/customer_groups_api.rb +4 -4
- data/lib/square/api/customer_segments_api.rb +4 -4
- data/lib/square/api/customers_api.rb +45 -26
- data/lib/square/api/devices_api.rb +2 -1
- data/lib/square/api/disputes_api.rb +100 -91
- data/lib/square/api/gift_card_activities_api.rb +127 -0
- data/lib/square/api/gift_cards_api.rb +291 -0
- data/lib/square/api/inventory_api.rb +16 -16
- data/lib/square/api/invoices_api.rb +14 -14
- data/lib/square/api/locations_api.rb +1 -2
- data/lib/square/api/loyalty_api.rb +66 -14
- data/lib/square/api/merchants_api.rb +1 -1
- data/lib/square/api/o_auth_api.rb +8 -9
- data/lib/square/api/orders_api.rb +35 -33
- data/lib/square/api/payments_api.rb +4 -1
- data/lib/square/api/refunds_api.rb +4 -1
- data/lib/square/api/sites_api.rb +42 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +36 -1
- data/lib/square/api/team_api.rb +40 -40
- data/lib/square/api/transactions_api.rb +32 -20
- data/lib/square/api/v1_employees_api.rb +2 -1
- data/lib/square/api/v1_transactions_api.rb +9 -0
- data/lib/square/api_helper.rb +5 -5
- data/lib/square/client.rb +37 -3
- data/lib/square/configuration.rb +23 -8
- data/lib/square/http/faraday_client.rb +5 -2
- data/test/api/test_locations_api.rb +1 -1
- metadata +11 -6
@@ -7,10 +7,10 @@ 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/working-with-apis/paginat
|
13
|
+
# ion).
|
14
14
|
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
15
15
|
def list_customer_groups(cursor: nil)
|
16
16
|
# Prepare query url.
|
@@ -7,10 +7,10 @@ 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/working-with-apis/paginat
|
13
|
+
# ion).
|
14
14
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
15
15
|
def list_customer_segments(cursor: nil)
|
16
16
|
# Prepare query url.
|
@@ -13,14 +13,14 @@ module Square
|
|
13
13
|
# profiles can take closer to one minute or longer, especially during
|
14
14
|
# network incidents and outages.
|
15
15
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
16
|
-
# a previous call to this endpoint. Provide this to retrieve the next
|
17
|
-
# results for your original query.
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
17
|
+
# set of results for your original query. For more information, see
|
18
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
19
|
+
# ion).
|
20
20
|
# @param [CustomerSortField] sort_field Optional parameter: Indicates how
|
21
|
-
#
|
21
|
+
# customers should be sorted. Default: `DEFAULT`.
|
22
22
|
# @param [SortOrder] sort_order Optional parameter: Indicates whether
|
23
|
-
#
|
23
|
+
# customers should be sorted in ascending (`ASC`) or descending (`DESC`)
|
24
24
|
# order. Default: `ASC`.
|
25
25
|
# @return [ListCustomersResponse Hash] response from the API call
|
26
26
|
def list_customers(cursor: nil,
|
@@ -58,10 +58,9 @@ module Square
|
|
58
58
|
)
|
59
59
|
end
|
60
60
|
|
61
|
-
# Creates a new customer for a business
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# to this
|
61
|
+
# Creates a new customer for a business.
|
62
|
+
# You must provide at least one of the following values in your request to
|
63
|
+
# this
|
65
64
|
# endpoint:
|
66
65
|
# - `given_name`
|
67
66
|
# - `family_name`
|
@@ -145,15 +144,27 @@ module Square
|
|
145
144
|
)
|
146
145
|
end
|
147
146
|
|
148
|
-
# Deletes a customer from a business
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
147
|
+
# Deletes a customer profile from a business. This operation also unlinks
|
148
|
+
# any associated cards on file.
|
149
|
+
# As a best practice, you should include the `version` field in the request
|
150
|
+
# to enable [optimistic
|
151
|
+
# concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
|
152
|
+
# tic-concurrency) control. The value must be set to the current version of
|
153
|
+
# the customer profile.
|
154
|
+
# To delete a customer profile that was created by merging existing
|
155
|
+
# profiles, you must use the ID of the newly created profile.
|
153
156
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
154
157
|
# delete.
|
158
|
+
# @param [Long] version Optional parameter: The current version of the
|
159
|
+
# customer profile. As a best practice, you should include this parameter
|
160
|
+
# to enable [optimistic
|
161
|
+
# concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
|
162
|
+
# tic-concurrency) control. For more information, see [Delete a customer
|
163
|
+
# profile](https://developer.squareup.com/docs/customers-api/use-the-api/kee
|
164
|
+
# p-records#delete-customer-profile).
|
155
165
|
# @return [DeleteCustomerResponse Hash] response from the API call
|
156
|
-
def delete_customer(customer_id
|
166
|
+
def delete_customer(customer_id:,
|
167
|
+
version: nil)
|
157
168
|
# Prepare query url.
|
158
169
|
_query_builder = config.get_base_uri
|
159
170
|
_query_builder << '/v2/customers/{customer_id}'
|
@@ -161,6 +172,10 @@ module Square
|
|
161
172
|
_query_builder,
|
162
173
|
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
163
174
|
)
|
175
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'version' => version
|
178
|
+
)
|
164
179
|
_query_url = APIHelper.clean_url _query_builder
|
165
180
|
|
166
181
|
# Prepare headers.
|
@@ -219,16 +234,18 @@ module Square
|
|
219
234
|
)
|
220
235
|
end
|
221
236
|
|
222
|
-
# Updates
|
223
|
-
#
|
224
|
-
#
|
225
|
-
# the
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
#
|
231
|
-
#
|
237
|
+
# Updates a customer profile. To change an attribute, specify the new value.
|
238
|
+
# To remove an attribute, specify the value as an empty string or empty
|
239
|
+
# object.
|
240
|
+
# As a best practice, you should include the `version` field in the request
|
241
|
+
# to enable [optimistic
|
242
|
+
# concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
|
243
|
+
# tic-concurrency) control. The value must be set to the current version of
|
244
|
+
# the customer profile.
|
245
|
+
# To update a customer profile that was created by merging existing
|
246
|
+
# profiles, you must use the ID of the newly created profile.
|
247
|
+
# You cannot use this endpoint to change cards on file. To make changes, use
|
248
|
+
# the [Cards API]($e/Cards) or [Gift Cards API]($e/GiftCards).
|
232
249
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
233
250
|
# update.
|
234
251
|
# @param [UpdateCustomerRequest] body Required parameter: An object
|
@@ -282,6 +299,7 @@ module Square
|
|
282
299
|
# @return [CreateCustomerCardResponse Hash] response from the API call
|
283
300
|
def create_customer_card(customer_id:,
|
284
301
|
body:)
|
302
|
+
warn 'Endpoint create_customer_card in CustomersApi is deprecated'
|
285
303
|
# Prepare query url.
|
286
304
|
_query_builder = config.get_base_uri
|
287
305
|
_query_builder << '/v2/customers/{customer_id}/cards'
|
@@ -322,6 +340,7 @@ module Square
|
|
322
340
|
# @return [DeleteCustomerCardResponse Hash] response from the API call
|
323
341
|
def delete_customer_card(customer_id:,
|
324
342
|
card_id:)
|
343
|
+
warn 'Endpoint delete_customer_card in CustomersApi is deprecated'
|
325
344
|
# Prepare query url.
|
326
345
|
_query_builder = config.get_base_uri
|
327
346
|
_query_builder << '/v2/customers/{customer_id}/cards/{card_id}'
|
@@ -9,7 +9,8 @@ module Square
|
|
9
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
10
|
# a previous call to this endpoint. Provide this to retrieve the next set of
|
11
11
|
# results for your original query. See [Paginating
|
12
|
-
# results](
|
12
|
+
# results](https://developer.squareup.com/docs/working-with-apis/pagination)
|
13
|
+
# for more information.
|
13
14
|
# @param [String] location_id Optional parameter: If specified, only returns
|
14
15
|
# DeviceCodes of the specified location. Returns DeviceCodes of all
|
15
16
|
# locations if empty.
|
@@ -131,8 +131,14 @@ module Square
|
|
131
131
|
|
132
132
|
# Returns a list of evidence associated with a dispute.
|
133
133
|
# @param [String] dispute_id Required parameter: The ID of the dispute.
|
134
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
135
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
136
|
+
# set of results for the original query. For more information, see
|
137
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
138
|
+
# .
|
134
139
|
# @return [ListDisputeEvidenceResponse Hash] response from the API call
|
135
|
-
def list_dispute_evidence(dispute_id
|
140
|
+
def list_dispute_evidence(dispute_id:,
|
141
|
+
cursor: nil)
|
136
142
|
# Prepare query url.
|
137
143
|
_query_builder = config.get_base_uri
|
138
144
|
_query_builder << '/v2/disputes/{dispute_id}/evidence'
|
@@ -140,91 +146,9 @@ module Square
|
|
140
146
|
_query_builder,
|
141
147
|
'dispute_id' => { 'value' => dispute_id, 'encode' => true }
|
142
148
|
)
|
143
|
-
|
144
|
-
|
145
|
-
# Prepare headers.
|
146
|
-
_headers = {
|
147
|
-
'accept' => 'application/json'
|
148
|
-
}
|
149
|
-
|
150
|
-
# Prepare and execute HttpRequest.
|
151
|
-
_request = config.http_client.get(
|
152
|
-
_query_url,
|
153
|
-
headers: _headers
|
154
|
-
)
|
155
|
-
OAuth2.apply(config, _request)
|
156
|
-
_response = execute_request(_request)
|
157
|
-
|
158
|
-
# Return appropriate response type.
|
159
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
160
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
161
|
-
ApiResponse.new(
|
162
|
-
_response, data: decoded, errors: _errors
|
163
|
-
)
|
164
|
-
end
|
165
|
-
|
166
|
-
# Removes specified evidence from a dispute.
|
167
|
-
# Square does not send the bank any evidence that is removed. Also, you
|
168
|
-
# cannot remove evidence after
|
169
|
-
# submitting it to the bank using
|
170
|
-
# [SubmitEvidence](https://developer.squareup.com/docs/reference/square/disp
|
171
|
-
# utes-api/submit-evidence).
|
172
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
173
|
-
# want to remove evidence from.
|
174
|
-
# @param [String] evidence_id Required parameter: The ID of the evidence you
|
175
|
-
# want to remove.
|
176
|
-
# @return [RemoveDisputeEvidenceResponse Hash] response from the API call
|
177
|
-
def remove_dispute_evidence(dispute_id:,
|
178
|
-
evidence_id:)
|
179
|
-
# Prepare query url.
|
180
|
-
_query_builder = config.get_base_uri
|
181
|
-
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
182
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
183
|
-
_query_builder,
|
184
|
-
'dispute_id' => { 'value' => dispute_id, 'encode' => true },
|
185
|
-
'evidence_id' => { 'value' => evidence_id, 'encode' => true }
|
186
|
-
)
|
187
|
-
_query_url = APIHelper.clean_url _query_builder
|
188
|
-
|
189
|
-
# Prepare headers.
|
190
|
-
_headers = {
|
191
|
-
'accept' => 'application/json'
|
192
|
-
}
|
193
|
-
|
194
|
-
# Prepare and execute HttpRequest.
|
195
|
-
_request = config.http_client.delete(
|
196
|
-
_query_url,
|
197
|
-
headers: _headers
|
198
|
-
)
|
199
|
-
OAuth2.apply(config, _request)
|
200
|
-
_response = execute_request(_request)
|
201
|
-
|
202
|
-
# Return appropriate response type.
|
203
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
204
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
205
|
-
ApiResponse.new(
|
206
|
-
_response, data: decoded, errors: _errors
|
207
|
-
)
|
208
|
-
end
|
209
|
-
|
210
|
-
# Returns the specific evidence metadata associated with a specific dispute.
|
211
|
-
# You must maintain a copy of the evidence you upload if you want to
|
212
|
-
# reference it later. You cannot
|
213
|
-
# download the evidence after you upload it.
|
214
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
215
|
-
# you want to retrieve evidence from.
|
216
|
-
# @param [String] evidence_id Required parameter: The ID of the evidence to
|
217
|
-
# retrieve.
|
218
|
-
# @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
|
219
|
-
def retrieve_dispute_evidence(dispute_id:,
|
220
|
-
evidence_id:)
|
221
|
-
# Prepare query url.
|
222
|
-
_query_builder = config.get_base_uri
|
223
|
-
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
224
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
149
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
225
150
|
_query_builder,
|
226
|
-
'
|
227
|
-
'evidence_id' => { 'value' => evidence_id, 'encode' => true }
|
151
|
+
'cursor' => cursor
|
228
152
|
)
|
229
153
|
_query_url = APIHelper.clean_url _query_builder
|
230
154
|
|
@@ -264,7 +188,7 @@ module Square
|
|
264
188
|
image_file: nil)
|
265
189
|
# Prepare query url.
|
266
190
|
_query_builder = config.get_base_uri
|
267
|
-
_query_builder << '/v2/disputes/{dispute_id}/
|
191
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence-files'
|
268
192
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
269
193
|
_query_builder,
|
270
194
|
'dispute_id' => { 'value' => dispute_id, 'encode' => true }
|
@@ -325,7 +249,7 @@ module Square
|
|
325
249
|
body:)
|
326
250
|
# Prepare query url.
|
327
251
|
_query_builder = config.get_base_uri
|
328
|
-
_query_builder << '/v2/disputes/{dispute_id}/
|
252
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence-text'
|
329
253
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
330
254
|
_query_builder,
|
331
255
|
'dispute_id' => { 'value' => dispute_id, 'encode' => true }
|
@@ -355,14 +279,99 @@ module Square
|
|
355
279
|
)
|
356
280
|
end
|
357
281
|
|
282
|
+
# Removes specified evidence from a dispute.
|
283
|
+
# Square does not send the bank any evidence that is removed. Also, you
|
284
|
+
# cannot remove evidence after
|
285
|
+
# submitting it to the bank using
|
286
|
+
# [SubmitEvidence]($e/Disputes/SubmitEvidence).
|
287
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
288
|
+
# want to remove evidence from.
|
289
|
+
# @param [String] evidence_id Required parameter: The ID of the evidence you
|
290
|
+
# want to remove.
|
291
|
+
# @return [DeleteDisputeEvidenceResponse Hash] response from the API call
|
292
|
+
def delete_dispute_evidence(dispute_id:,
|
293
|
+
evidence_id:)
|
294
|
+
# Prepare query url.
|
295
|
+
_query_builder = config.get_base_uri
|
296
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
297
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
298
|
+
_query_builder,
|
299
|
+
'dispute_id' => { 'value' => dispute_id, 'encode' => true },
|
300
|
+
'evidence_id' => { 'value' => evidence_id, 'encode' => true }
|
301
|
+
)
|
302
|
+
_query_url = APIHelper.clean_url _query_builder
|
303
|
+
|
304
|
+
# Prepare headers.
|
305
|
+
_headers = {
|
306
|
+
'accept' => 'application/json'
|
307
|
+
}
|
308
|
+
|
309
|
+
# Prepare and execute HttpRequest.
|
310
|
+
_request = config.http_client.delete(
|
311
|
+
_query_url,
|
312
|
+
headers: _headers
|
313
|
+
)
|
314
|
+
OAuth2.apply(config, _request)
|
315
|
+
_response = execute_request(_request)
|
316
|
+
|
317
|
+
# Return appropriate response type.
|
318
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
319
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
320
|
+
ApiResponse.new(
|
321
|
+
_response, data: decoded, errors: _errors
|
322
|
+
)
|
323
|
+
end
|
324
|
+
|
325
|
+
# Returns the evidence metadata specified by the evidence ID in the request
|
326
|
+
# URL path
|
327
|
+
# You must maintain a copy of the evidence you upload if you want to
|
328
|
+
# reference it later. You cannot
|
329
|
+
# download the evidence after you upload it.
|
330
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
331
|
+
# you want to retrieve evidence from.
|
332
|
+
# @param [String] evidence_id Required parameter: The ID of the evidence to
|
333
|
+
# retrieve.
|
334
|
+
# @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
|
335
|
+
def retrieve_dispute_evidence(dispute_id:,
|
336
|
+
evidence_id:)
|
337
|
+
# Prepare query url.
|
338
|
+
_query_builder = config.get_base_uri
|
339
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
340
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
|
+
_query_builder,
|
342
|
+
'dispute_id' => { 'value' => dispute_id, 'encode' => true },
|
343
|
+
'evidence_id' => { 'value' => evidence_id, 'encode' => true }
|
344
|
+
)
|
345
|
+
_query_url = APIHelper.clean_url _query_builder
|
346
|
+
|
347
|
+
# Prepare headers.
|
348
|
+
_headers = {
|
349
|
+
'accept' => 'application/json'
|
350
|
+
}
|
351
|
+
|
352
|
+
# Prepare and execute HttpRequest.
|
353
|
+
_request = config.http_client.get(
|
354
|
+
_query_url,
|
355
|
+
headers: _headers
|
356
|
+
)
|
357
|
+
OAuth2.apply(config, _request)
|
358
|
+
_response = execute_request(_request)
|
359
|
+
|
360
|
+
# Return appropriate response type.
|
361
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
362
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
363
|
+
ApiResponse.new(
|
364
|
+
_response, data: decoded, errors: _errors
|
365
|
+
)
|
366
|
+
end
|
367
|
+
|
358
368
|
# Submits evidence to the cardholder's bank.
|
359
369
|
# Before submitting evidence, Square compiles all available evidence. This
|
360
370
|
# includes evidence uploaded
|
361
371
|
# using the
|
362
|
-
# [CreateDisputeEvidenceFile](
|
363
|
-
#
|
364
|
-
#
|
365
|
-
# square/disputes-api/create-dispute-evidence-text) endpoints and
|
372
|
+
# [CreateDisputeEvidenceFile]($e/Disputes/CreateDisputeEvidenceFile) and
|
373
|
+
# [CreateDisputeEvidenceText]($e/Disputes/CreateDisputeEvidenceText)
|
374
|
+
# endpoints and
|
366
375
|
# evidence automatically provided by Square, when available.
|
367
376
|
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
368
377
|
# you want to submit evidence for.
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Square
|
2
|
+
# GiftCardActivitiesApi
|
3
|
+
class GiftCardActivitiesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists gift card activities. By default, you get gift card activities for
|
9
|
+
# all
|
10
|
+
# gift cards in the seller's account. You can optionally specify query
|
11
|
+
# parameters to
|
12
|
+
# filter the list. For example, you can get a list of gift card activities
|
13
|
+
# for a gift card,
|
14
|
+
# for all gift cards in a specific region, or for activities within a time
|
15
|
+
# window.
|
16
|
+
# @param [String] gift_card_id Optional parameter: If you provide a gift
|
17
|
+
# card ID, the endpoint returns activities that belong to the specified
|
18
|
+
# gift card. Otherwise, the endpoint returns all gift card activities for
|
19
|
+
# the seller.
|
20
|
+
# @param [String] type Optional parameter: If you provide a type, the
|
21
|
+
# endpoint returns gift card activities of this type. Otherwise, the
|
22
|
+
# endpoint returns all types of gift card activities.
|
23
|
+
# @param [String] location_id Optional parameter: If you provide a location
|
24
|
+
# ID, the endpoint returns gift card activities for that location.
|
25
|
+
# Otherwise, the endpoint returns gift card activities for all locations.
|
26
|
+
# @param [String] begin_time Optional parameter: The timestamp for the
|
27
|
+
# beginning of the reporting period, in RFC 3339 format. Inclusive. Default:
|
28
|
+
# The current time minus one year.
|
29
|
+
# @param [String] end_time Optional parameter: The timestamp for the end of
|
30
|
+
# the reporting period, in RFC 3339 format. Inclusive. Default: The current
|
31
|
+
# time.
|
32
|
+
# @param [Integer] limit Optional parameter: If you provide a limit value,
|
33
|
+
# the endpoint returns the specified number of results (or less) per page.
|
34
|
+
# A maximum value is 100. The default value is 50.
|
35
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
36
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
37
|
+
# set of results for the original query. If you do not provide the cursor,
|
38
|
+
# the call returns the first page of the results.
|
39
|
+
# @param [String] sort_order Optional parameter: The order in which the
|
40
|
+
# endpoint returns the activities, based on `created_at`. - `ASC` - Oldest
|
41
|
+
# to newest. - `DESC` - Newest to oldest (default).
|
42
|
+
# @return [ListGiftCardActivitiesResponse Hash] response from the API call
|
43
|
+
def list_gift_card_activities(gift_card_id: nil,
|
44
|
+
type: nil,
|
45
|
+
location_id: nil,
|
46
|
+
begin_time: nil,
|
47
|
+
end_time: nil,
|
48
|
+
limit: nil,
|
49
|
+
cursor: nil,
|
50
|
+
sort_order: nil)
|
51
|
+
# Prepare query url.
|
52
|
+
_query_builder = config.get_base_uri
|
53
|
+
_query_builder << '/v2/gift-cards/activities'
|
54
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
55
|
+
_query_builder,
|
56
|
+
'gift_card_id' => gift_card_id,
|
57
|
+
'type' => type,
|
58
|
+
'location_id' => location_id,
|
59
|
+
'begin_time' => begin_time,
|
60
|
+
'end_time' => end_time,
|
61
|
+
'limit' => limit,
|
62
|
+
'cursor' => cursor,
|
63
|
+
'sort_order' => sort_order
|
64
|
+
)
|
65
|
+
_query_url = APIHelper.clean_url _query_builder
|
66
|
+
|
67
|
+
# Prepare headers.
|
68
|
+
_headers = {
|
69
|
+
'accept' => 'application/json'
|
70
|
+
}
|
71
|
+
|
72
|
+
# Prepare and execute HttpRequest.
|
73
|
+
_request = config.http_client.get(
|
74
|
+
_query_url,
|
75
|
+
headers: _headers
|
76
|
+
)
|
77
|
+
OAuth2.apply(config, _request)
|
78
|
+
_response = execute_request(_request)
|
79
|
+
|
80
|
+
# Return appropriate response type.
|
81
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
82
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
83
|
+
ApiResponse.new(
|
84
|
+
_response, data: decoded, errors: _errors
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Creates a gift card activity. For more information, see
|
89
|
+
# [GiftCardActivity](https://developer.squareup.com/docs/gift-cards/using-gi
|
90
|
+
# ft-cards-api#giftcardactivity) and
|
91
|
+
# [Using activated gift
|
92
|
+
# cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
|
93
|
+
# #using-activated-gift-cards).
|
94
|
+
# @param [CreateGiftCardActivityRequest] body Required parameter: An object
|
95
|
+
# containing the fields to POST for the request. See the corresponding
|
96
|
+
# object definition for field details.
|
97
|
+
# @return [CreateGiftCardActivityResponse Hash] response from the API call
|
98
|
+
def create_gift_card_activity(body:)
|
99
|
+
# Prepare query url.
|
100
|
+
_query_builder = config.get_base_uri
|
101
|
+
_query_builder << '/v2/gift-cards/activities'
|
102
|
+
_query_url = APIHelper.clean_url _query_builder
|
103
|
+
|
104
|
+
# Prepare headers.
|
105
|
+
_headers = {
|
106
|
+
'accept' => 'application/json',
|
107
|
+
'content-type' => 'application/json; charset=utf-8'
|
108
|
+
}
|
109
|
+
|
110
|
+
# Prepare and execute HttpRequest.
|
111
|
+
_request = config.http_client.post(
|
112
|
+
_query_url,
|
113
|
+
headers: _headers,
|
114
|
+
parameters: body.to_json
|
115
|
+
)
|
116
|
+
OAuth2.apply(config, _request)
|
117
|
+
_response = execute_request(_request)
|
118
|
+
|
119
|
+
# Return appropriate response type.
|
120
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
121
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
122
|
+
ApiResponse.new(
|
123
|
+
_response, data: decoded, errors: _errors
|
124
|
+
)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|