square.rb 3.20190814.0 → 3.20190925.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -2
  3. data/lib/square.rb +53 -52
  4. data/lib/square/api/apple_pay_api.rb +55 -55
  5. data/lib/square/api/base_api.rb +48 -45
  6. data/lib/square/api/catalog_api.rb +461 -461
  7. data/lib/square/api/checkout_api.rb +54 -54
  8. data/lib/square/api/customers_api.rb +335 -335
  9. data/lib/square/api/employees_api.rb +91 -91
  10. data/lib/square/api/inventory_api.rb +300 -300
  11. data/lib/square/api/labor_api.rb +558 -558
  12. data/lib/square/api/locations_api.rb +117 -45
  13. data/lib/square/api/merchants_api.rb +46 -0
  14. data/lib/square/api/mobile_authorization_api.rb +56 -56
  15. data/lib/square/api/o_auth_api.rb +168 -168
  16. data/lib/square/api/orders_api.rb +271 -269
  17. data/lib/square/api/payments_api.rb +282 -282
  18. data/lib/square/api/refunds_api.rb +149 -149
  19. data/lib/square/api/reporting_api.rb +145 -143
  20. data/lib/square/api/transactions_api.rb +379 -379
  21. data/lib/square/api/v1_employees_api.rb +720 -720
  22. data/lib/square/api/v1_items_api.rb +1651 -1651
  23. data/lib/square/api/v1_locations_api.rb +67 -67
  24. data/lib/square/api/v1_transactions_api.rb +574 -574
  25. data/lib/square/api_helper.rb +281 -281
  26. data/lib/square/client.rb +155 -139
  27. data/lib/square/configuration.rb +98 -88
  28. data/lib/square/exceptions/api_exception.rb +20 -20
  29. data/lib/square/http/api_response.rb +50 -50
  30. data/lib/square/http/auth/o_auth2.rb +17 -17
  31. data/lib/square/http/faraday_client.rb +64 -64
  32. data/lib/square/http/http_call_back.rb +24 -24
  33. data/lib/square/http/http_client.rb +104 -104
  34. data/lib/square/http/http_method_enum.rb +13 -13
  35. data/lib/square/http/http_request.rb +50 -50
  36. data/lib/square/http/http_response.rb +29 -29
  37. data/test/api/test_labor_api.rb +74 -0
  38. metadata +4 -3
  39. data/lib/square/api/v1_locations_api.rbe +0 -67
@@ -1,54 +1,54 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # CheckoutApi
8
- class CheckoutApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Links a `checkoutId` to a `checkout_page_url` that customers will
14
- # be directed to in order to provide their payment information using a
15
- # payment processing workflow hosted on connect.squareup.com.
16
- # @param [String] location_id Required parameter: The ID of the business
17
- # location to associate the checkout with.
18
- # @param [CreateCheckoutRequest] body Required parameter: An object
19
- # containing the fields to POST for the request. See the corresponding
20
- # object definition for field details.
21
- # @return [CreateCheckoutResponse Hash] response from the API call
22
- def create_checkout(location_id:,
23
- body:)
24
- # Prepare query url.
25
- _query_builder = config.get_base_uri
26
- _query_builder << '/v2/locations/{location_id}/checkouts'
27
- _query_builder = APIHelper.append_url_with_template_parameters(
28
- _query_builder,
29
- 'location_id' => location_id
30
- )
31
- _query_url = APIHelper.clean_url _query_builder
32
-
33
- # Prepare headers.
34
- _headers = {
35
- 'accept' => 'application/json',
36
- 'content-type' => 'application/json; charset=utf-8'
37
- }
38
-
39
- # Prepare and execute HttpRequest.
40
- _request = config.http_client.post(
41
- _query_url,
42
- headers: _headers,
43
- parameters: body.to_json
44
- )
45
- OAuth2.apply(config, _request)
46
- _response = execute_request(_request)
47
-
48
- # Return appropriate response type.
49
- decoded = APIHelper.json_deserialize(_response.raw_body)
50
- _errors = APIHelper.map_response(decoded, ['errors'])
51
- ApiResponse.new(_response, data: decoded, errors: _errors)
52
- end
53
- end
54
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # CheckoutApi
8
+ class CheckoutApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Links a `checkoutId` to a `checkout_page_url` that customers will
14
+ # be directed to in order to provide their payment information using a
15
+ # payment processing workflow hosted on connect.squareup.com.
16
+ # @param [String] location_id Required parameter: The ID of the business
17
+ # location to associate the checkout with.
18
+ # @param [CreateCheckoutRequest] body Required parameter: An object
19
+ # containing the fields to POST for the request. See the corresponding
20
+ # object definition for field details.
21
+ # @return [CreateCheckoutResponse Hash] response from the API call
22
+ def create_checkout(location_id:,
23
+ body:)
24
+ # Prepare query url.
25
+ _query_builder = config.get_base_uri
26
+ _query_builder << '/v2/locations/{location_id}/checkouts'
27
+ _query_builder = APIHelper.append_url_with_template_parameters(
28
+ _query_builder,
29
+ 'location_id' => location_id
30
+ )
31
+ _query_url = APIHelper.clean_url _query_builder
32
+
33
+ # Prepare headers.
34
+ _headers = {
35
+ 'accept' => 'application/json',
36
+ 'content-type' => 'application/json; charset=utf-8'
37
+ }
38
+
39
+ # Prepare and execute HttpRequest.
40
+ _request = config.http_client.post(
41
+ _query_url,
42
+ headers: _headers,
43
+ parameters: body.to_json
44
+ )
45
+ OAuth2.apply(config, _request)
46
+ _response = execute_request(_request)
47
+
48
+ # Return appropriate response type.
49
+ decoded = APIHelper.json_deserialize(_response.raw_body)
50
+ _errors = APIHelper.map_response(decoded, ['errors'])
51
+ ApiResponse.new(_response, data: decoded, errors: _errors)
52
+ end
53
+ end
54
+ end
@@ -1,335 +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](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
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