square.rb 3.20190624.0 → 3.20190814.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +10 -28
- data/README.md +281 -17235
- data/lib/square/api/apple_pay_api.rb +55 -54
- data/lib/square/api/base_api.rb +45 -45
- data/lib/square/api/catalog_api.rb +461 -460
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -334
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -298
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +45 -45
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -164
- data/lib/square/api/orders_api.rb +269 -151
- data/lib/square/api/payments_api.rb +282 -0
- data/lib/square/api/refunds_api.rb +149 -0
- data/lib/square/api/reporting_api.rb +143 -139
- data/lib/square/api/transactions_api.rb +379 -360
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_locations_api.rbe +67 -0
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -277
- data/lib/square/client.rb +139 -127
- data/lib/square/configuration.rb +88 -85
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/lib/square.rb +52 -50
- data/spec/user_journey_spec.rb +4 -1
- data/test/api/api_test_base.rb +2 -1
- data/test/api/test_catalog_api.rb +59 -0
- data/test/api/test_employees_api.rb +36 -0
- data/test/api/test_locations_api.rb +35 -0
- data/test/api/test_payments_api.rb +42 -0
- data/test/api/test_refunds_api.rb +41 -0
- metadata +19 -11
@@ -1,334 +1,335 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# CustomersApi
|
8
|
-
class CustomersApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Lists a business's customers.
|
14
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
15
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
16
|
-
# results for your original query. See
|
17
|
-
# [Pagination](/basics/api101/pagination)
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
_query_builder
|
30
|
-
_query_builder
|
31
|
-
|
32
|
-
|
33
|
-
'
|
34
|
-
'
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
# - `
|
64
|
-
# - `
|
65
|
-
# - `
|
66
|
-
# - `
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
_query_builder
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
'
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#
|
100
|
-
#
|
101
|
-
# `
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
_query_builder
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
'
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
_query_builder
|
145
|
-
_query_builder
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
_query_builder
|
178
|
-
_query_builder
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
_query_builder
|
225
|
-
_query_builder
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
'
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
# are
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
_query_builder
|
270
|
-
_query_builder
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
'
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
#
|
302
|
-
#
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
_query_builder
|
308
|
-
_query_builder
|
309
|
-
|
310
|
-
|
311
|
-
'
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# CustomersApi
|
8
|
+
class CustomersApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Lists a business's customers.
|
14
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
15
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
16
|
+
# results for your original query. See
|
17
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
18
|
+
# for more information.
|
19
|
+
# @param [CustomerSortField] sort_field Optional parameter: Indicates how
|
20
|
+
# Customers should be sorted. Default: `DEFAULT`.
|
21
|
+
# @param [SortOrder] sort_order Optional parameter: Indicates whether
|
22
|
+
# Customers should be sorted in ascending (`ASC`) or descending (`DESC`)
|
23
|
+
# order. Default: `ASC`.
|
24
|
+
# @return [ListCustomersResponse Hash] response from the API call
|
25
|
+
def list_customers(cursor: nil,
|
26
|
+
sort_field: nil,
|
27
|
+
sort_order: nil)
|
28
|
+
# Prepare query url.
|
29
|
+
_query_builder = config.get_base_uri
|
30
|
+
_query_builder << '/v2/customers'
|
31
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
32
|
+
_query_builder,
|
33
|
+
'cursor' => cursor,
|
34
|
+
'sort_field' => sort_field,
|
35
|
+
'sort_order' => sort_order
|
36
|
+
)
|
37
|
+
_query_url = APIHelper.clean_url _query_builder
|
38
|
+
|
39
|
+
# Prepare headers.
|
40
|
+
_headers = {
|
41
|
+
'accept' => 'application/json'
|
42
|
+
}
|
43
|
+
|
44
|
+
# Prepare and execute HttpRequest.
|
45
|
+
_request = config.http_client.get(
|
46
|
+
_query_url,
|
47
|
+
headers: _headers
|
48
|
+
)
|
49
|
+
OAuth2.apply(config, _request)
|
50
|
+
_response = execute_request(_request)
|
51
|
+
|
52
|
+
# Return appropriate response type.
|
53
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
54
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
55
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Creates a new customer for a business, which can have associated cards on
|
59
|
+
# file.
|
60
|
+
# You must provide __at least one__ of the following values in your request
|
61
|
+
# to this
|
62
|
+
# endpoint:
|
63
|
+
# - `given_name`
|
64
|
+
# - `family_name`
|
65
|
+
# - `company_name`
|
66
|
+
# - `email_address`
|
67
|
+
# - `phone_number`
|
68
|
+
# @param [CreateCustomerRequest] body Required parameter: An object
|
69
|
+
# containing the fields to POST for the request. See the corresponding
|
70
|
+
# object definition for field details.
|
71
|
+
# @return [CreateCustomerResponse Hash] response from the API call
|
72
|
+
def create_customer(body:)
|
73
|
+
# Prepare query url.
|
74
|
+
_query_builder = config.get_base_uri
|
75
|
+
_query_builder << '/v2/customers'
|
76
|
+
_query_url = APIHelper.clean_url _query_builder
|
77
|
+
|
78
|
+
# Prepare headers.
|
79
|
+
_headers = {
|
80
|
+
'accept' => 'application/json',
|
81
|
+
'content-type' => 'application/json; charset=utf-8'
|
82
|
+
}
|
83
|
+
|
84
|
+
# Prepare and execute HttpRequest.
|
85
|
+
_request = config.http_client.post(
|
86
|
+
_query_url,
|
87
|
+
headers: _headers,
|
88
|
+
parameters: body.to_json
|
89
|
+
)
|
90
|
+
OAuth2.apply(config, _request)
|
91
|
+
_response = execute_request(_request)
|
92
|
+
|
93
|
+
# Return appropriate response type.
|
94
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
95
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
96
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Searches the customer profiles associated with a Square account.
|
100
|
+
# Calling SearchCustomers without an explicit query parameter returns all
|
101
|
+
# customer profiles ordered alphabetically based on `given_name` and
|
102
|
+
# `family_name`.
|
103
|
+
# @param [SearchCustomersRequest] body Required parameter: An object
|
104
|
+
# containing the fields to POST for the request. See the corresponding
|
105
|
+
# object definition for field details.
|
106
|
+
# @return [SearchCustomersResponse Hash] response from the API call
|
107
|
+
def search_customers(body:)
|
108
|
+
# Prepare query url.
|
109
|
+
_query_builder = config.get_base_uri
|
110
|
+
_query_builder << '/v2/customers/search'
|
111
|
+
_query_url = APIHelper.clean_url _query_builder
|
112
|
+
|
113
|
+
# Prepare headers.
|
114
|
+
_headers = {
|
115
|
+
'accept' => 'application/json',
|
116
|
+
'content-type' => 'application/json; charset=utf-8'
|
117
|
+
}
|
118
|
+
|
119
|
+
# Prepare and execute HttpRequest.
|
120
|
+
_request = config.http_client.post(
|
121
|
+
_query_url,
|
122
|
+
headers: _headers,
|
123
|
+
parameters: body.to_json
|
124
|
+
)
|
125
|
+
OAuth2.apply(config, _request)
|
126
|
+
_response = execute_request(_request)
|
127
|
+
|
128
|
+
# Return appropriate response type.
|
129
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
130
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
131
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Deletes a customer from a business, along with any linked cards on file.
|
135
|
+
# When two profiles
|
136
|
+
# are merged into a single profile, that profile is assigned a new
|
137
|
+
# `customer_id`. You must use the
|
138
|
+
# new `customer_id` to delete merged profiles.
|
139
|
+
# @param [String] customer_id Required parameter: The ID of the customer to
|
140
|
+
# delete.
|
141
|
+
# @return [DeleteCustomerResponse Hash] response from the API call
|
142
|
+
def delete_customer(customer_id:)
|
143
|
+
# Prepare query url.
|
144
|
+
_query_builder = config.get_base_uri
|
145
|
+
_query_builder << '/v2/customers/{customer_id}'
|
146
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
147
|
+
_query_builder,
|
148
|
+
'customer_id' => customer_id
|
149
|
+
)
|
150
|
+
_query_url = APIHelper.clean_url _query_builder
|
151
|
+
|
152
|
+
# Prepare headers.
|
153
|
+
_headers = {
|
154
|
+
'accept' => 'application/json'
|
155
|
+
}
|
156
|
+
|
157
|
+
# Prepare and execute HttpRequest.
|
158
|
+
_request = config.http_client.delete(
|
159
|
+
_query_url,
|
160
|
+
headers: _headers
|
161
|
+
)
|
162
|
+
OAuth2.apply(config, _request)
|
163
|
+
_response = execute_request(_request)
|
164
|
+
|
165
|
+
# Return appropriate response type.
|
166
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
167
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
168
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns details for a single customer.
|
172
|
+
# @param [String] customer_id Required parameter: The ID of the customer to
|
173
|
+
# retrieve.
|
174
|
+
# @return [RetrieveCustomerResponse Hash] response from the API call
|
175
|
+
def retrieve_customer(customer_id:)
|
176
|
+
# Prepare query url.
|
177
|
+
_query_builder = config.get_base_uri
|
178
|
+
_query_builder << '/v2/customers/{customer_id}'
|
179
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
180
|
+
_query_builder,
|
181
|
+
'customer_id' => customer_id
|
182
|
+
)
|
183
|
+
_query_url = APIHelper.clean_url _query_builder
|
184
|
+
|
185
|
+
# Prepare headers.
|
186
|
+
_headers = {
|
187
|
+
'accept' => 'application/json'
|
188
|
+
}
|
189
|
+
|
190
|
+
# Prepare and execute HttpRequest.
|
191
|
+
_request = config.http_client.get(
|
192
|
+
_query_url,
|
193
|
+
headers: _headers
|
194
|
+
)
|
195
|
+
OAuth2.apply(config, _request)
|
196
|
+
_response = execute_request(_request)
|
197
|
+
|
198
|
+
# Return appropriate response type.
|
199
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
200
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
201
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
202
|
+
end
|
203
|
+
|
204
|
+
# Updates the details of an existing customer. When two profiles are merged
|
205
|
+
# into a single profile, that profile is assigned a new `customer_id`. You
|
206
|
+
# must use
|
207
|
+
# the new `customer_id` to update merged profiles.
|
208
|
+
# You cannot edit a customer's cards on file with this endpoint. To make
|
209
|
+
# changes
|
210
|
+
# to a card on file, you must delete the existing card on file with the
|
211
|
+
# [DeleteCustomerCard](#endpoint-customers-deletecustomercard) endpoint,
|
212
|
+
# then
|
213
|
+
# create a new one with the
|
214
|
+
# [CreateCustomerCard](#endpoint-customers-createcustomercard) endpoint.
|
215
|
+
# @param [String] customer_id Required parameter: The ID of the customer to
|
216
|
+
# update.
|
217
|
+
# @param [UpdateCustomerRequest] body Required parameter: An object
|
218
|
+
# containing the fields to POST for the request. See the corresponding
|
219
|
+
# object definition for field details.
|
220
|
+
# @return [UpdateCustomerResponse Hash] response from the API call
|
221
|
+
def update_customer(customer_id:,
|
222
|
+
body:)
|
223
|
+
# Prepare query url.
|
224
|
+
_query_builder = config.get_base_uri
|
225
|
+
_query_builder << '/v2/customers/{customer_id}'
|
226
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
227
|
+
_query_builder,
|
228
|
+
'customer_id' => customer_id
|
229
|
+
)
|
230
|
+
_query_url = APIHelper.clean_url _query_builder
|
231
|
+
|
232
|
+
# Prepare headers.
|
233
|
+
_headers = {
|
234
|
+
'accept' => 'application/json',
|
235
|
+
'content-type' => 'application/json; charset=utf-8'
|
236
|
+
}
|
237
|
+
|
238
|
+
# Prepare and execute HttpRequest.
|
239
|
+
_request = config.http_client.put(
|
240
|
+
_query_url,
|
241
|
+
headers: _headers,
|
242
|
+
parameters: body.to_json
|
243
|
+
)
|
244
|
+
OAuth2.apply(config, _request)
|
245
|
+
_response = execute_request(_request)
|
246
|
+
|
247
|
+
# Return appropriate response type.
|
248
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
249
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
250
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
251
|
+
end
|
252
|
+
|
253
|
+
# Adds a card on file to an existing customer.
|
254
|
+
# As with charges, calls to `CreateCustomerCard` are idempotent. Multiple
|
255
|
+
# calls with the same card nonce return the same card record that was
|
256
|
+
# created
|
257
|
+
# with the provided nonce during the _first_ call.
|
258
|
+
# Cards on file are automatically updated on a monthly basis to confirm they
|
259
|
+
# are still valid and can be charged.
|
260
|
+
# @param [String] customer_id Required parameter: The Square ID of the
|
261
|
+
# customer profile the card is linked to.
|
262
|
+
# @param [CreateCustomerCardRequest] body Required parameter: An object
|
263
|
+
# containing the fields to POST for the request. See the corresponding
|
264
|
+
# object definition for field details.
|
265
|
+
# @return [CreateCustomerCardResponse Hash] response from the API call
|
266
|
+
def create_customer_card(customer_id:,
|
267
|
+
body:)
|
268
|
+
# Prepare query url.
|
269
|
+
_query_builder = config.get_base_uri
|
270
|
+
_query_builder << '/v2/customers/{customer_id}/cards'
|
271
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
272
|
+
_query_builder,
|
273
|
+
'customer_id' => customer_id
|
274
|
+
)
|
275
|
+
_query_url = APIHelper.clean_url _query_builder
|
276
|
+
|
277
|
+
# Prepare headers.
|
278
|
+
_headers = {
|
279
|
+
'accept' => 'application/json',
|
280
|
+
'content-type' => 'application/json; charset=utf-8'
|
281
|
+
}
|
282
|
+
|
283
|
+
# Prepare and execute HttpRequest.
|
284
|
+
_request = config.http_client.post(
|
285
|
+
_query_url,
|
286
|
+
headers: _headers,
|
287
|
+
parameters: body.to_json
|
288
|
+
)
|
289
|
+
OAuth2.apply(config, _request)
|
290
|
+
_response = execute_request(_request)
|
291
|
+
|
292
|
+
# Return appropriate response type.
|
293
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
294
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
295
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
296
|
+
end
|
297
|
+
|
298
|
+
# Removes a card on file from a customer.
|
299
|
+
# @param [String] customer_id Required parameter: The ID of the customer
|
300
|
+
# that the card on file belongs to.
|
301
|
+
# @param [String] card_id Required parameter: The ID of the card on file to
|
302
|
+
# delete.
|
303
|
+
# @return [DeleteCustomerCardResponse Hash] response from the API call
|
304
|
+
def delete_customer_card(customer_id:,
|
305
|
+
card_id:)
|
306
|
+
# Prepare query url.
|
307
|
+
_query_builder = config.get_base_uri
|
308
|
+
_query_builder << '/v2/customers/{customer_id}/cards/{card_id}'
|
309
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
310
|
+
_query_builder,
|
311
|
+
'customer_id' => customer_id,
|
312
|
+
'card_id' => card_id
|
313
|
+
)
|
314
|
+
_query_url = APIHelper.clean_url _query_builder
|
315
|
+
|
316
|
+
# Prepare headers.
|
317
|
+
_headers = {
|
318
|
+
'accept' => 'application/json'
|
319
|
+
}
|
320
|
+
|
321
|
+
# Prepare and execute HttpRequest.
|
322
|
+
_request = config.http_client.delete(
|
323
|
+
_query_url,
|
324
|
+
headers: _headers
|
325
|
+
)
|
326
|
+
OAuth2.apply(config, _request)
|
327
|
+
_response = execute_request(_request)
|
328
|
+
|
329
|
+
# Return appropriate response type.
|
330
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
331
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
332
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|