square.rb 10.0.0.202104217 → 13.1.0.20210818
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/square.rb +6 -0
- data/lib/square/api/base_api.rb +4 -6
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/catalog_api.rb +8 -5
- data/lib/square/api/customer_groups_api.rb +10 -2
- data/lib/square/api/customer_segments_api.rb +10 -2
- data/lib/square/api/customers_api.rb +18 -12
- data/lib/square/api/disputes_api.rb +97 -86
- data/lib/square/api/gift_card_activities_api.rb +127 -0
- data/lib/square/api/gift_cards_api.rb +292 -0
- data/lib/square/api/inventory_api.rb +244 -5
- data/lib/square/api/labor_api.rb +64 -62
- data/lib/square/api/loyalty_api.rb +24 -8
- data/lib/square/api/o_auth_api.rb +8 -9
- data/lib/square/api/orders_api.rb +27 -27
- data/lib/square/api/sites_api.rb +42 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/team_api.rb +30 -30
- data/lib/square/api/transactions_api.rb +3 -2
- data/lib/square/api/v1_transactions_api.rb +9 -0
- data/lib/square/api_helper.rb +18 -29
- data/lib/square/client.rb +37 -3
- data/lib/square/configuration.rb +23 -8
- data/lib/square/http/faraday_client.rb +6 -3
- data/lib/square/utilities/date_time_helper.rb +151 -0
- metadata +16 -7
@@ -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,90 +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]($e/Disputes/SubmitEvidence).
|
171
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
172
|
-
# want to remove evidence from.
|
173
|
-
# @param [String] evidence_id Required parameter: The ID of the evidence you
|
174
|
-
# want to remove.
|
175
|
-
# @return [RemoveDisputeEvidenceResponse Hash] response from the API call
|
176
|
-
def remove_dispute_evidence(dispute_id:,
|
177
|
-
evidence_id:)
|
178
|
-
# Prepare query url.
|
179
|
-
_query_builder = config.get_base_uri
|
180
|
-
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
181
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
182
|
-
_query_builder,
|
183
|
-
'dispute_id' => { 'value' => dispute_id, 'encode' => true },
|
184
|
-
'evidence_id' => { 'value' => evidence_id, 'encode' => true }
|
185
|
-
)
|
186
|
-
_query_url = APIHelper.clean_url _query_builder
|
187
|
-
|
188
|
-
# Prepare headers.
|
189
|
-
_headers = {
|
190
|
-
'accept' => 'application/json'
|
191
|
-
}
|
192
|
-
|
193
|
-
# Prepare and execute HttpRequest.
|
194
|
-
_request = config.http_client.delete(
|
195
|
-
_query_url,
|
196
|
-
headers: _headers
|
197
|
-
)
|
198
|
-
OAuth2.apply(config, _request)
|
199
|
-
_response = execute_request(_request)
|
200
|
-
|
201
|
-
# Return appropriate response type.
|
202
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
203
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
204
|
-
ApiResponse.new(
|
205
|
-
_response, data: decoded, errors: _errors
|
206
|
-
)
|
207
|
-
end
|
208
|
-
|
209
|
-
# Returns the specific evidence metadata associated with a specific dispute.
|
210
|
-
# You must maintain a copy of the evidence you upload if you want to
|
211
|
-
# reference it later. You cannot
|
212
|
-
# download the evidence after you upload it.
|
213
|
-
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
214
|
-
# you want to retrieve evidence from.
|
215
|
-
# @param [String] evidence_id Required parameter: The ID of the evidence to
|
216
|
-
# retrieve.
|
217
|
-
# @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
|
218
|
-
def retrieve_dispute_evidence(dispute_id:,
|
219
|
-
evidence_id:)
|
220
|
-
# Prepare query url.
|
221
|
-
_query_builder = config.get_base_uri
|
222
|
-
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
223
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
149
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
224
150
|
_query_builder,
|
225
|
-
'
|
226
|
-
'evidence_id' => { 'value' => evidence_id, 'encode' => true }
|
151
|
+
'cursor' => cursor
|
227
152
|
)
|
228
153
|
_query_url = APIHelper.clean_url _query_builder
|
229
154
|
|
@@ -263,7 +188,7 @@ module Square
|
|
263
188
|
image_file: nil)
|
264
189
|
# Prepare query url.
|
265
190
|
_query_builder = config.get_base_uri
|
266
|
-
_query_builder << '/v2/disputes/{dispute_id}/
|
191
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence-files'
|
267
192
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
268
193
|
_query_builder,
|
269
194
|
'dispute_id' => { 'value' => dispute_id, 'encode' => true }
|
@@ -324,7 +249,7 @@ module Square
|
|
324
249
|
body:)
|
325
250
|
# Prepare query url.
|
326
251
|
_query_builder = config.get_base_uri
|
327
|
-
_query_builder << '/v2/disputes/{dispute_id}/
|
252
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence-text'
|
328
253
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
329
254
|
_query_builder,
|
330
255
|
'dispute_id' => { 'value' => dispute_id, 'encode' => true }
|
@@ -354,6 +279,92 @@ module Square
|
|
354
279
|
)
|
355
280
|
end
|
356
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
|
+
|
357
368
|
# Submits evidence to the cardholder's bank.
|
358
369
|
# Before submitting evidence, Square compiles all available evidence. This
|
359
370
|
# includes evidence uploaded
|
@@ -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
|
@@ -0,0 +1,292 @@
|
|
1
|
+
module Square
|
2
|
+
# GiftCardsApi
|
3
|
+
class GiftCardsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists all gift cards. You can specify optional filters to retrieve
|
9
|
+
# a subset of the gift cards.
|
10
|
+
# @param [String] type Optional parameter: If a type is provided, gift cards
|
11
|
+
# of this type are returned (see [GiftCardType]($m/GiftCardType)). If no
|
12
|
+
# type is provided, it returns gift cards of all types.
|
13
|
+
# @param [String] state Optional parameter: If the state is provided, it
|
14
|
+
# returns the gift cards in the specified state (see
|
15
|
+
# [GiftCardStatus]($m/GiftCardStatus)). Otherwise, it returns the gift cards
|
16
|
+
# of all states.
|
17
|
+
# @param [Integer] limit Optional parameter: If a value is provided, it
|
18
|
+
# returns only that number of results per page. The maximum number of
|
19
|
+
# results allowed per page is 50. The default value is 30.
|
20
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
21
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
22
|
+
# set of results for the original query. If a cursor is not provided, it
|
23
|
+
# returns the first page of the results. For more information, see
|
24
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
25
|
+
# ion).
|
26
|
+
# @param [String] customer_id Optional parameter: If a value is provided,
|
27
|
+
# returns only the gift cards linked to the specified customer
|
28
|
+
# @return [ListGiftCardsResponse Hash] response from the API call
|
29
|
+
def list_gift_cards(type: nil,
|
30
|
+
state: nil,
|
31
|
+
limit: nil,
|
32
|
+
cursor: nil,
|
33
|
+
customer_id: nil)
|
34
|
+
# Prepare query url.
|
35
|
+
_query_builder = config.get_base_uri
|
36
|
+
_query_builder << '/v2/gift-cards'
|
37
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
38
|
+
_query_builder,
|
39
|
+
'type' => type,
|
40
|
+
'state' => state,
|
41
|
+
'limit' => limit,
|
42
|
+
'cursor' => cursor,
|
43
|
+
'customer_id' => customer_id
|
44
|
+
)
|
45
|
+
_query_url = APIHelper.clean_url _query_builder
|
46
|
+
|
47
|
+
# Prepare headers.
|
48
|
+
_headers = {
|
49
|
+
'accept' => 'application/json'
|
50
|
+
}
|
51
|
+
|
52
|
+
# Prepare and execute HttpRequest.
|
53
|
+
_request = config.http_client.get(
|
54
|
+
_query_url,
|
55
|
+
headers: _headers
|
56
|
+
)
|
57
|
+
OAuth2.apply(config, _request)
|
58
|
+
_response = execute_request(_request)
|
59
|
+
|
60
|
+
# Return appropriate response type.
|
61
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
62
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
63
|
+
ApiResponse.new(
|
64
|
+
_response, data: decoded, errors: _errors
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Creates a digital gift card or registers a physical (plastic) gift card.
|
69
|
+
# You must activate the gift card before
|
70
|
+
# it can be used for payment. For more information, see
|
71
|
+
# [Selling gift
|
72
|
+
# cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
|
73
|
+
# #selling-square-gift-cards).
|
74
|
+
# @param [CreateGiftCardRequest] body Required parameter: An object
|
75
|
+
# containing the fields to POST for the request. See the corresponding
|
76
|
+
# object definition for field details.
|
77
|
+
# @return [CreateGiftCardResponse Hash] response from the API call
|
78
|
+
def create_gift_card(body:)
|
79
|
+
# Prepare query url.
|
80
|
+
_query_builder = config.get_base_uri
|
81
|
+
_query_builder << '/v2/gift-cards'
|
82
|
+
_query_url = APIHelper.clean_url _query_builder
|
83
|
+
|
84
|
+
# Prepare headers.
|
85
|
+
_headers = {
|
86
|
+
'accept' => 'application/json',
|
87
|
+
'content-type' => 'application/json; charset=utf-8'
|
88
|
+
}
|
89
|
+
|
90
|
+
# Prepare and execute HttpRequest.
|
91
|
+
_request = config.http_client.post(
|
92
|
+
_query_url,
|
93
|
+
headers: _headers,
|
94
|
+
parameters: body.to_json
|
95
|
+
)
|
96
|
+
OAuth2.apply(config, _request)
|
97
|
+
_response = execute_request(_request)
|
98
|
+
|
99
|
+
# Return appropriate response type.
|
100
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
101
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
102
|
+
ApiResponse.new(
|
103
|
+
_response, data: decoded, errors: _errors
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Retrieves a gift card using the gift card account number (GAN).
|
108
|
+
# @param [RetrieveGiftCardFromGANRequest] body Required parameter: An object
|
109
|
+
# containing the fields to POST for the request. See the corresponding
|
110
|
+
# object definition for field details.
|
111
|
+
# @return [RetrieveGiftCardFromGANResponse Hash] response from the API call
|
112
|
+
def retrieve_gift_card_from_gan(body:)
|
113
|
+
# Prepare query url.
|
114
|
+
_query_builder = config.get_base_uri
|
115
|
+
_query_builder << '/v2/gift-cards/from-gan'
|
116
|
+
_query_url = APIHelper.clean_url _query_builder
|
117
|
+
|
118
|
+
# Prepare headers.
|
119
|
+
_headers = {
|
120
|
+
'accept' => 'application/json',
|
121
|
+
'content-type' => 'application/json; charset=utf-8'
|
122
|
+
}
|
123
|
+
|
124
|
+
# Prepare and execute HttpRequest.
|
125
|
+
_request = config.http_client.post(
|
126
|
+
_query_url,
|
127
|
+
headers: _headers,
|
128
|
+
parameters: body.to_json
|
129
|
+
)
|
130
|
+
OAuth2.apply(config, _request)
|
131
|
+
_response = execute_request(_request)
|
132
|
+
|
133
|
+
# Return appropriate response type.
|
134
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
135
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
136
|
+
ApiResponse.new(
|
137
|
+
_response, data: decoded, errors: _errors
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Retrieves a gift card using a nonce (a secure token) that represents the
|
142
|
+
# gift card.
|
143
|
+
# @param [RetrieveGiftCardFromNonceRequest] body Required parameter: An
|
144
|
+
# object containing the fields to POST for the request. See the
|
145
|
+
# corresponding object definition for field details.
|
146
|
+
# @return [RetrieveGiftCardFromNonceResponse Hash] response from the API call
|
147
|
+
def retrieve_gift_card_from_nonce(body:)
|
148
|
+
# Prepare query url.
|
149
|
+
_query_builder = config.get_base_uri
|
150
|
+
_query_builder << '/v2/gift-cards/from-nonce'
|
151
|
+
_query_url = APIHelper.clean_url _query_builder
|
152
|
+
|
153
|
+
# Prepare headers.
|
154
|
+
_headers = {
|
155
|
+
'accept' => 'application/json',
|
156
|
+
'content-type' => 'application/json; charset=utf-8'
|
157
|
+
}
|
158
|
+
|
159
|
+
# Prepare and execute HttpRequest.
|
160
|
+
_request = config.http_client.post(
|
161
|
+
_query_url,
|
162
|
+
headers: _headers,
|
163
|
+
parameters: body.to_json
|
164
|
+
)
|
165
|
+
OAuth2.apply(config, _request)
|
166
|
+
_response = execute_request(_request)
|
167
|
+
|
168
|
+
# Return appropriate response type.
|
169
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
170
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
171
|
+
ApiResponse.new(
|
172
|
+
_response, data: decoded, errors: _errors
|
173
|
+
)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Links a customer to a gift card
|
177
|
+
# @param [String] gift_card_id Required parameter: The ID of the gift card
|
178
|
+
# to link.
|
179
|
+
# @param [LinkCustomerToGiftCardRequest] body Required parameter: An object
|
180
|
+
# containing the fields to POST for the request. See the corresponding
|
181
|
+
# object definition for field details.
|
182
|
+
# @return [LinkCustomerToGiftCardResponse Hash] response from the API call
|
183
|
+
def link_customer_to_gift_card(gift_card_id:,
|
184
|
+
body:)
|
185
|
+
# Prepare query url.
|
186
|
+
_query_builder = config.get_base_uri
|
187
|
+
_query_builder << '/v2/gift-cards/{gift_card_id}/link-customer'
|
188
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
189
|
+
_query_builder,
|
190
|
+
'gift_card_id' => { 'value' => gift_card_id, 'encode' => true }
|
191
|
+
)
|
192
|
+
_query_url = APIHelper.clean_url _query_builder
|
193
|
+
|
194
|
+
# Prepare headers.
|
195
|
+
_headers = {
|
196
|
+
'accept' => 'application/json',
|
197
|
+
'content-type' => 'application/json; charset=utf-8'
|
198
|
+
}
|
199
|
+
|
200
|
+
# Prepare and execute HttpRequest.
|
201
|
+
_request = config.http_client.post(
|
202
|
+
_query_url,
|
203
|
+
headers: _headers,
|
204
|
+
parameters: body.to_json
|
205
|
+
)
|
206
|
+
OAuth2.apply(config, _request)
|
207
|
+
_response = execute_request(_request)
|
208
|
+
|
209
|
+
# Return appropriate response type.
|
210
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
211
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
212
|
+
ApiResponse.new(
|
213
|
+
_response, data: decoded, errors: _errors
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
217
|
+
# Unlinks a customer from a gift card
|
218
|
+
# @param [String] gift_card_id Required parameter: Example:
|
219
|
+
# @param [UnlinkCustomerFromGiftCardRequest] body Required parameter: An
|
220
|
+
# object containing the fields to POST for the request. See the
|
221
|
+
# corresponding object definition for field details.
|
222
|
+
# @return [UnlinkCustomerFromGiftCardResponse Hash] response from the API call
|
223
|
+
def unlink_customer_from_gift_card(gift_card_id:,
|
224
|
+
body:)
|
225
|
+
# Prepare query url.
|
226
|
+
_query_builder = config.get_base_uri
|
227
|
+
_query_builder << '/v2/gift-cards/{gift_card_id}/unlink-customer'
|
228
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
229
|
+
_query_builder,
|
230
|
+
'gift_card_id' => { 'value' => gift_card_id, '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; charset=utf-8'
|
238
|
+
}
|
239
|
+
|
240
|
+
# Prepare and execute HttpRequest.
|
241
|
+
_request = config.http_client.post(
|
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
|
+
# Retrieves a gift card using its ID.
|
258
|
+
# @param [String] id Required parameter: The ID of the gift card to
|
259
|
+
# retrieve.
|
260
|
+
# @return [RetrieveGiftCardResponse Hash] response from the API call
|
261
|
+
def retrieve_gift_card(id:)
|
262
|
+
# Prepare query url.
|
263
|
+
_query_builder = config.get_base_uri
|
264
|
+
_query_builder << '/v2/gift-cards/{id}'
|
265
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
266
|
+
_query_builder,
|
267
|
+
'id' => { 'value' => id, 'encode' => true }
|
268
|
+
)
|
269
|
+
_query_url = APIHelper.clean_url _query_builder
|
270
|
+
|
271
|
+
# Prepare headers.
|
272
|
+
_headers = {
|
273
|
+
'accept' => 'application/json'
|
274
|
+
}
|
275
|
+
|
276
|
+
# Prepare and execute HttpRequest.
|
277
|
+
_request = config.http_client.get(
|
278
|
+
_query_url,
|
279
|
+
headers: _headers
|
280
|
+
)
|
281
|
+
OAuth2.apply(config, _request)
|
282
|
+
_response = execute_request(_request)
|
283
|
+
|
284
|
+
# Return appropriate response type.
|
285
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
286
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
287
|
+
ApiResponse.new(
|
288
|
+
_response, data: decoded, errors: _errors
|
289
|
+
)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|