square.rb 6.3.0.20200826 → 17.1.0.20220120

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +86 -51
  4. data/lib/square/api/apple_pay_api.rb +12 -9
  5. data/lib/square/api/bank_accounts_api.rb +21 -24
  6. data/lib/square/api/base_api.rb +20 -9
  7. data/lib/square/api/bookings_api.rb +391 -0
  8. data/lib/square/api/cards_api.rb +170 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +195 -85
  11. data/lib/square/api/checkout_api.rb +7 -5
  12. data/lib/square/api/customer_groups_api.rb +34 -16
  13. data/lib/square/api/customer_segments_api.rb +21 -9
  14. data/lib/square/api/customers_api.rb +102 -55
  15. data/lib/square/api/devices_api.rb +20 -8
  16. data/lib/square/api/disputes_api.rb +156 -144
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/gift_card_activities_api.rb +133 -0
  19. data/lib/square/api/gift_cards_api.rb +297 -0
  20. data/lib/square/api/inventory_api.rb +290 -37
  21. data/lib/square/api/invoices_api.rb +61 -57
  22. data/lib/square/api/labor_api.rb +127 -93
  23. data/lib/square/api/locations_api.rb +36 -25
  24. data/lib/square/api/loyalty_api.rb +134 -87
  25. data/lib/square/api/merchants_api.rb +8 -4
  26. data/lib/square/api/mobile_authorization_api.rb +9 -7
  27. data/lib/square/api/o_auth_api.rb +41 -32
  28. data/lib/square/api/orders_api.rb +132 -54
  29. data/lib/square/api/payments_api.rb +133 -75
  30. data/lib/square/api/refunds_api.rb +51 -30
  31. data/lib/square/api/sites_api.rb +43 -0
  32. data/lib/square/api/snippets_api.rb +146 -0
  33. data/lib/square/api/subscriptions_api.rb +216 -26
  34. data/lib/square/api/team_api.rb +81 -65
  35. data/lib/square/api/terminal_api.rb +166 -16
  36. data/lib/square/api/transactions_api.rb +32 -194
  37. data/lib/square/api/v1_transactions_api.rb +53 -103
  38. data/lib/square/api_helper.rb +38 -43
  39. data/lib/square/client.rb +54 -24
  40. data/lib/square/configuration.rb +61 -21
  41. data/lib/square/http/api_response.rb +3 -1
  42. data/lib/square/http/faraday_client.rb +34 -5
  43. data/lib/square/utilities/date_time_helper.rb +151 -0
  44. data/lib/square/utilities/file_wrapper.rb +1 -2
  45. data/lib/square.rb +65 -61
  46. data/spec/user_journey_spec.rb +2 -5
  47. data/test/api/api_test_base.rb +1 -6
  48. data/test/api/test_catalog_api.rb +1 -4
  49. data/test/api/test_customers_api.rb +1 -4
  50. data/test/api/test_employees_api.rb +1 -4
  51. data/test/api/test_labor_api.rb +2 -6
  52. data/test/api/test_locations_api.rb +21 -35
  53. data/test/api/test_merchants_api.rb +1 -4
  54. data/test/api/test_payments_api.rb +3 -6
  55. data/test/api/test_refunds_api.rb +3 -6
  56. data/test/http_response_catcher.rb +0 -5
  57. data/test/test_helper.rb +1 -6
  58. metadata +40 -18
  59. data/lib/square/api/v1_employees_api.rb +0 -723
  60. data/lib/square/api/v1_items_api.rb +0 -1686
  61. data/lib/square/api/v1_locations_api.rb +0 -65
@@ -7,18 +7,26 @@ 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 set of
11
- # results for your original query. See the [Pagination
12
- # guide](https://developer.squareup.com/docs/working-with-apis/pagination)
13
- # for more information.
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
+ # @param [Integer] limit Optional parameter: The maximum number of results
15
+ # to return in a single page. This limit is advisory. The response might
16
+ # contain more or fewer results. The limit is ignored if it is less than 1
17
+ # or greater than 50. The default value is 50. For more information, see
18
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
+ # ion).
14
20
  # @return [ListCustomerGroupsResponse Hash] response from the API call
15
- def list_customer_groups(cursor: nil)
21
+ def list_customer_groups(cursor: nil,
22
+ limit: nil)
16
23
  # Prepare query url.
17
24
  _query_builder = config.get_base_uri
18
25
  _query_builder << '/v2/customers/groups'
19
26
  _query_builder = APIHelper.append_url_with_query_parameters(
20
27
  _query_builder,
21
- 'cursor' => cursor
28
+ 'cursor' => cursor,
29
+ 'limit' => limit
22
30
  )
23
31
  _query_url = APIHelper.clean_url _query_builder
24
32
 
@@ -38,7 +46,9 @@ module Square
38
46
  # Return appropriate response type.
39
47
  decoded = APIHelper.json_deserialize(_response.raw_body)
40
48
  _errors = APIHelper.map_response(decoded, ['errors'])
41
- ApiResponse.new(_response, data: decoded, errors: _errors)
49
+ ApiResponse.new(
50
+ _response, data: decoded, errors: _errors
51
+ )
42
52
  end
43
53
 
44
54
  # Creates a new customer group for a business.
@@ -56,7 +66,7 @@ module Square
56
66
  # Prepare headers.
57
67
  _headers = {
58
68
  'accept' => 'application/json',
59
- 'content-type' => 'application/json; charset=utf-8'
69
+ 'Content-Type' => 'application/json'
60
70
  }
61
71
 
62
72
  # Prepare and execute HttpRequest.
@@ -71,7 +81,9 @@ module Square
71
81
  # Return appropriate response type.
72
82
  decoded = APIHelper.json_deserialize(_response.raw_body)
73
83
  _errors = APIHelper.map_response(decoded, ['errors'])
74
- ApiResponse.new(_response, data: decoded, errors: _errors)
84
+ ApiResponse.new(
85
+ _response, data: decoded, errors: _errors
86
+ )
75
87
  end
76
88
 
77
89
  # Deletes a customer group as identified by the `group_id` value.
@@ -84,7 +96,7 @@ module Square
84
96
  _query_builder << '/v2/customers/groups/{group_id}'
85
97
  _query_builder = APIHelper.append_url_with_template_parameters(
86
98
  _query_builder,
87
- 'group_id' => group_id
99
+ 'group_id' => { 'value' => group_id, 'encode' => true }
88
100
  )
89
101
  _query_url = APIHelper.clean_url _query_builder
90
102
 
@@ -104,7 +116,9 @@ module Square
104
116
  # Return appropriate response type.
105
117
  decoded = APIHelper.json_deserialize(_response.raw_body)
106
118
  _errors = APIHelper.map_response(decoded, ['errors'])
107
- ApiResponse.new(_response, data: decoded, errors: _errors)
119
+ ApiResponse.new(
120
+ _response, data: decoded, errors: _errors
121
+ )
108
122
  end
109
123
 
110
124
  # Retrieves a specific customer group as identified by the `group_id` value.
@@ -117,7 +131,7 @@ module Square
117
131
  _query_builder << '/v2/customers/groups/{group_id}'
118
132
  _query_builder = APIHelper.append_url_with_template_parameters(
119
133
  _query_builder,
120
- 'group_id' => group_id
134
+ 'group_id' => { 'value' => group_id, 'encode' => true }
121
135
  )
122
136
  _query_url = APIHelper.clean_url _query_builder
123
137
 
@@ -137,7 +151,9 @@ module Square
137
151
  # Return appropriate response type.
138
152
  decoded = APIHelper.json_deserialize(_response.raw_body)
139
153
  _errors = APIHelper.map_response(decoded, ['errors'])
140
- ApiResponse.new(_response, data: decoded, errors: _errors)
154
+ ApiResponse.new(
155
+ _response, data: decoded, errors: _errors
156
+ )
141
157
  end
142
158
 
143
159
  # Updates a customer group as identified by the `group_id` value.
@@ -154,14 +170,14 @@ module Square
154
170
  _query_builder << '/v2/customers/groups/{group_id}'
155
171
  _query_builder = APIHelper.append_url_with_template_parameters(
156
172
  _query_builder,
157
- 'group_id' => group_id
173
+ 'group_id' => { 'value' => group_id, 'encode' => true }
158
174
  )
159
175
  _query_url = APIHelper.clean_url _query_builder
160
176
 
161
177
  # Prepare headers.
162
178
  _headers = {
163
179
  'accept' => 'application/json',
164
- 'content-type' => 'application/json; charset=utf-8'
180
+ 'Content-Type' => 'application/json'
165
181
  }
166
182
 
167
183
  # Prepare and execute HttpRequest.
@@ -176,7 +192,9 @@ module Square
176
192
  # Return appropriate response type.
177
193
  decoded = APIHelper.json_deserialize(_response.raw_body)
178
194
  _errors = APIHelper.map_response(decoded, ['errors'])
179
- ApiResponse.new(_response, data: decoded, errors: _errors)
195
+ ApiResponse.new(
196
+ _response, data: decoded, errors: _errors
197
+ )
180
198
  end
181
199
  end
182
200
  end
@@ -7,18 +7,26 @@ 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 __ListCustomerSegments__. Used to retrieve the next set
11
- # of query results. See the [Pagination
12
- # guide](https://developer.squareup.com/docs/docs/working-with-apis/paginati
13
- # on) for more information.
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
+ # @param [Integer] limit Optional parameter: The maximum number of results
15
+ # to return in a single page. This limit is advisory. The response might
16
+ # contain more or fewer results. The limit is ignored if it is less than 1
17
+ # or greater than 50. The default value is 50. For more information, see
18
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
+ # ion).
14
20
  # @return [ListCustomerSegmentsResponse Hash] response from the API call
15
- def list_customer_segments(cursor: nil)
21
+ def list_customer_segments(cursor: nil,
22
+ limit: nil)
16
23
  # Prepare query url.
17
24
  _query_builder = config.get_base_uri
18
25
  _query_builder << '/v2/customers/segments'
19
26
  _query_builder = APIHelper.append_url_with_query_parameters(
20
27
  _query_builder,
21
- 'cursor' => cursor
28
+ 'cursor' => cursor,
29
+ 'limit' => limit
22
30
  )
23
31
  _query_url = APIHelper.clean_url _query_builder
24
32
 
@@ -38,7 +46,9 @@ module Square
38
46
  # Return appropriate response type.
39
47
  decoded = APIHelper.json_deserialize(_response.raw_body)
40
48
  _errors = APIHelper.map_response(decoded, ['errors'])
41
- ApiResponse.new(_response, data: decoded, errors: _errors)
49
+ ApiResponse.new(
50
+ _response, data: decoded, errors: _errors
51
+ )
42
52
  end
43
53
 
44
54
  # Retrieves a specific customer segment as identified by the `segment_id`
@@ -52,7 +62,7 @@ module Square
52
62
  _query_builder << '/v2/customers/segments/{segment_id}'
53
63
  _query_builder = APIHelper.append_url_with_template_parameters(
54
64
  _query_builder,
55
- 'segment_id' => segment_id
65
+ 'segment_id' => { 'value' => segment_id, 'encode' => true }
56
66
  )
57
67
  _query_url = APIHelper.clean_url _query_builder
58
68
 
@@ -72,7 +82,9 @@ module Square
72
82
  # Return appropriate response type.
73
83
  decoded = APIHelper.json_deserialize(_response.raw_body)
74
84
  _errors = APIHelper.map_response(decoded, ['errors'])
75
- ApiResponse.new(_response, data: decoded, errors: _errors)
85
+ ApiResponse.new(
86
+ _response, data: decoded, errors: _errors
87
+ )
76
88
  end
77
89
  end
78
90
  end
@@ -10,20 +10,27 @@ module Square
10
10
  # profiles become available
11
11
  # for the listing operation in well under 30 seconds. Occasionally,
12
12
  # propagation of the new or updated
13
- # profiles can take closer to one minute or longer, espeically during
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 set of
17
- # results for your original query. See the [Pagination
18
- # guide](https://developer.squareup.com/docs/working-with-apis/pagination)
19
- # for more information.
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
+ # @param [Integer] limit Optional parameter: The maximum number of results
21
+ # to return in a single page. This limit is advisory. The response might
22
+ # contain more or fewer results. The limit is ignored if it is less than 1
23
+ # or greater than 100. The default value is 100. For more information, see
24
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
25
+ # ion).
20
26
  # @param [CustomerSortField] sort_field Optional parameter: Indicates how
21
- # Customers should be sorted. Default: `DEFAULT`.
27
+ # customers should be sorted. The default value is `DEFAULT`.
22
28
  # @param [SortOrder] sort_order Optional parameter: Indicates whether
23
- # Customers should be sorted in ascending (`ASC`) or descending (`DESC`)
24
- # order. Default: `ASC`.
29
+ # customers should be sorted in ascending (`ASC`) or descending (`DESC`)
30
+ # order. The default value is `ASC`.
25
31
  # @return [ListCustomersResponse Hash] response from the API call
26
32
  def list_customers(cursor: nil,
33
+ limit: nil,
27
34
  sort_field: nil,
28
35
  sort_order: nil)
29
36
  # Prepare query url.
@@ -32,6 +39,7 @@ module Square
32
39
  _query_builder = APIHelper.append_url_with_query_parameters(
33
40
  _query_builder,
34
41
  'cursor' => cursor,
42
+ 'limit' => limit,
35
43
  'sort_field' => sort_field,
36
44
  'sort_order' => sort_order
37
45
  )
@@ -53,13 +61,14 @@ module Square
53
61
  # Return appropriate response type.
54
62
  decoded = APIHelper.json_deserialize(_response.raw_body)
55
63
  _errors = APIHelper.map_response(decoded, ['errors'])
56
- ApiResponse.new(_response, data: decoded, errors: _errors)
64
+ ApiResponse.new(
65
+ _response, data: decoded, errors: _errors
66
+ )
57
67
  end
58
68
 
59
- # Creates a new customer for a business, which can have associated cards on
60
- # file.
61
- # You must provide __at least one__ of the following values in your request
62
- # to this
69
+ # Creates a new customer for a business.
70
+ # You must provide at least one of the following values in your request to
71
+ # this
63
72
  # endpoint:
64
73
  # - `given_name`
65
74
  # - `family_name`
@@ -79,7 +88,7 @@ module Square
79
88
  # Prepare headers.
80
89
  _headers = {
81
90
  'accept' => 'application/json',
82
- 'content-type' => 'application/json; charset=utf-8'
91
+ 'Content-Type' => 'application/json'
83
92
  }
84
93
 
85
94
  # Prepare and execute HttpRequest.
@@ -94,11 +103,13 @@ module Square
94
103
  # Return appropriate response type.
95
104
  decoded = APIHelper.json_deserialize(_response.raw_body)
96
105
  _errors = APIHelper.map_response(decoded, ['errors'])
97
- ApiResponse.new(_response, data: decoded, errors: _errors)
106
+ ApiResponse.new(
107
+ _response, data: decoded, errors: _errors
108
+ )
98
109
  end
99
110
 
100
- # Searches the customer profiles associated with a Square account using
101
- # one or more supported query filters.
111
+ # Searches the customer profiles associated with a Square account using a
112
+ # supported query filter.
102
113
  # Calling `SearchCustomers` without any explicit query filter returns all
103
114
  # customer profiles ordered alphabetically based on `given_name` and
104
115
  # `family_name`.
@@ -106,7 +117,7 @@ module Square
106
117
  # profiles become available
107
118
  # for the search operation in well under 30 seconds. Occasionally,
108
119
  # propagation of the new or updated
109
- # profiles can take closer to one minute or longer, espeically during
120
+ # profiles can take closer to one minute or longer, especially during
110
121
  # network incidents and outages.
111
122
  # @param [SearchCustomersRequest] body Required parameter: An object
112
123
  # containing the fields to POST for the request. See the corresponding
@@ -121,7 +132,7 @@ module Square
121
132
  # Prepare headers.
122
133
  _headers = {
123
134
  'accept' => 'application/json',
124
- 'content-type' => 'application/json; charset=utf-8'
135
+ 'Content-Type' => 'application/json'
125
136
  }
126
137
 
127
138
  # Prepare and execute HttpRequest.
@@ -136,24 +147,42 @@ module Square
136
147
  # Return appropriate response type.
137
148
  decoded = APIHelper.json_deserialize(_response.raw_body)
138
149
  _errors = APIHelper.map_response(decoded, ['errors'])
139
- ApiResponse.new(_response, data: decoded, errors: _errors)
150
+ ApiResponse.new(
151
+ _response, data: decoded, errors: _errors
152
+ )
140
153
  end
141
154
 
142
- # Deletes a customer from a business, along with any linked cards on file.
143
- # When two profiles
144
- # are merged into a single profile, that profile is assigned a new
145
- # `customer_id`. You must use the
146
- # new `customer_id` to delete merged profiles.
155
+ # Deletes a customer profile from a business. This operation also unlinks
156
+ # any associated cards on file.
157
+ # As a best practice, you should include the `version` field in the request
158
+ # to enable [optimistic
159
+ # concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
160
+ # tic-concurrency) control. The value must be set to the current version of
161
+ # the customer profile.
162
+ # To delete a customer profile that was created by merging existing
163
+ # profiles, you must use the ID of the newly created profile.
147
164
  # @param [String] customer_id Required parameter: The ID of the customer to
148
165
  # delete.
166
+ # @param [Long] version Optional parameter: The current version of the
167
+ # customer profile. As a best practice, you should include this parameter
168
+ # to enable [optimistic
169
+ # concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
170
+ # tic-concurrency) control. For more information, see [Delete a customer
171
+ # profile](https://developer.squareup.com/docs/customers-api/use-the-api/kee
172
+ # p-records#delete-customer-profile).
149
173
  # @return [DeleteCustomerResponse Hash] response from the API call
150
- def delete_customer(customer_id:)
174
+ def delete_customer(customer_id:,
175
+ version: nil)
151
176
  # Prepare query url.
152
177
  _query_builder = config.get_base_uri
153
178
  _query_builder << '/v2/customers/{customer_id}'
154
179
  _query_builder = APIHelper.append_url_with_template_parameters(
155
180
  _query_builder,
156
- 'customer_id' => customer_id
181
+ 'customer_id' => { 'value' => customer_id, 'encode' => true }
182
+ )
183
+ _query_builder = APIHelper.append_url_with_query_parameters(
184
+ _query_builder,
185
+ 'version' => version
157
186
  )
158
187
  _query_url = APIHelper.clean_url _query_builder
159
188
 
@@ -173,7 +202,9 @@ module Square
173
202
  # Return appropriate response type.
174
203
  decoded = APIHelper.json_deserialize(_response.raw_body)
175
204
  _errors = APIHelper.map_response(decoded, ['errors'])
176
- ApiResponse.new(_response, data: decoded, errors: _errors)
205
+ ApiResponse.new(
206
+ _response, data: decoded, errors: _errors
207
+ )
177
208
  end
178
209
 
179
210
  # Returns details for a single customer.
@@ -186,7 +217,7 @@ module Square
186
217
  _query_builder << '/v2/customers/{customer_id}'
187
218
  _query_builder = APIHelper.append_url_with_template_parameters(
188
219
  _query_builder,
189
- 'customer_id' => customer_id
220
+ 'customer_id' => { 'value' => customer_id, 'encode' => true }
190
221
  )
191
222
  _query_url = APIHelper.clean_url _query_builder
192
223
 
@@ -206,19 +237,23 @@ module Square
206
237
  # Return appropriate response type.
207
238
  decoded = APIHelper.json_deserialize(_response.raw_body)
208
239
  _errors = APIHelper.map_response(decoded, ['errors'])
209
- ApiResponse.new(_response, data: decoded, errors: _errors)
240
+ ApiResponse.new(
241
+ _response, data: decoded, errors: _errors
242
+ )
210
243
  end
211
244
 
212
- # Updates the details of an existing customer. When two profiles are merged
213
- # into a single profile, that profile is assigned a new `customer_id`. You
214
- # must use
215
- # the new `customer_id` to update merged profiles.
216
- # You cannot edit a customer's cards on file with this endpoint. To make
217
- # changes
218
- # to a card on file, you must delete the existing card on file with the
219
- # [DeleteCustomerCard](#endpoint-deletecustomercard) endpoint, then create a
220
- # new one with the
221
- # [CreateCustomerCard](#endpoint-createcustomercard) endpoint.
245
+ # Updates a customer profile. To change an attribute, specify the new value.
246
+ # To remove an attribute, specify the value as an empty string or empty
247
+ # object.
248
+ # As a best practice, you should include the `version` field in the request
249
+ # to enable [optimistic
250
+ # concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
251
+ # tic-concurrency) control. The value must be set to the current version of
252
+ # the customer profile.
253
+ # To update a customer profile that was created by merging existing
254
+ # profiles, you must use the ID of the newly created profile.
255
+ # You cannot use this endpoint to change cards on file. To make changes, use
256
+ # the [Cards API]($e/Cards) or [Gift Cards API]($e/GiftCards).
222
257
  # @param [String] customer_id Required parameter: The ID of the customer to
223
258
  # update.
224
259
  # @param [UpdateCustomerRequest] body Required parameter: An object
@@ -232,14 +267,14 @@ module Square
232
267
  _query_builder << '/v2/customers/{customer_id}'
233
268
  _query_builder = APIHelper.append_url_with_template_parameters(
234
269
  _query_builder,
235
- 'customer_id' => customer_id
270
+ 'customer_id' => { 'value' => customer_id, 'encode' => true }
236
271
  )
237
272
  _query_url = APIHelper.clean_url _query_builder
238
273
 
239
274
  # Prepare headers.
240
275
  _headers = {
241
276
  'accept' => 'application/json',
242
- 'content-type' => 'application/json; charset=utf-8'
277
+ 'Content-Type' => 'application/json'
243
278
  }
244
279
 
245
280
  # Prepare and execute HttpRequest.
@@ -254,7 +289,9 @@ module Square
254
289
  # Return appropriate response type.
255
290
  decoded = APIHelper.json_deserialize(_response.raw_body)
256
291
  _errors = APIHelper.map_response(decoded, ['errors'])
257
- ApiResponse.new(_response, data: decoded, errors: _errors)
292
+ ApiResponse.new(
293
+ _response, data: decoded, errors: _errors
294
+ )
258
295
  end
259
296
 
260
297
  # Adds a card on file to an existing customer.
@@ -270,19 +307,20 @@ module Square
270
307
  # @return [CreateCustomerCardResponse Hash] response from the API call
271
308
  def create_customer_card(customer_id:,
272
309
  body:)
310
+ warn 'Endpoint create_customer_card in CustomersApi is deprecated'
273
311
  # Prepare query url.
274
312
  _query_builder = config.get_base_uri
275
313
  _query_builder << '/v2/customers/{customer_id}/cards'
276
314
  _query_builder = APIHelper.append_url_with_template_parameters(
277
315
  _query_builder,
278
- 'customer_id' => customer_id
316
+ 'customer_id' => { 'value' => customer_id, 'encode' => true }
279
317
  )
280
318
  _query_url = APIHelper.clean_url _query_builder
281
319
 
282
320
  # Prepare headers.
283
321
  _headers = {
284
322
  'accept' => 'application/json',
285
- 'content-type' => 'application/json; charset=utf-8'
323
+ 'Content-Type' => 'application/json'
286
324
  }
287
325
 
288
326
  # Prepare and execute HttpRequest.
@@ -297,7 +335,9 @@ module Square
297
335
  # Return appropriate response type.
298
336
  decoded = APIHelper.json_deserialize(_response.raw_body)
299
337
  _errors = APIHelper.map_response(decoded, ['errors'])
300
- ApiResponse.new(_response, data: decoded, errors: _errors)
338
+ ApiResponse.new(
339
+ _response, data: decoded, errors: _errors
340
+ )
301
341
  end
302
342
 
303
343
  # Removes a card on file from a customer.
@@ -308,13 +348,14 @@ module Square
308
348
  # @return [DeleteCustomerCardResponse Hash] response from the API call
309
349
  def delete_customer_card(customer_id:,
310
350
  card_id:)
351
+ warn 'Endpoint delete_customer_card in CustomersApi is deprecated'
311
352
  # Prepare query url.
312
353
  _query_builder = config.get_base_uri
313
354
  _query_builder << '/v2/customers/{customer_id}/cards/{card_id}'
314
355
  _query_builder = APIHelper.append_url_with_template_parameters(
315
356
  _query_builder,
316
- 'customer_id' => customer_id,
317
- 'card_id' => card_id
357
+ 'customer_id' => { 'value' => customer_id, 'encode' => true },
358
+ 'card_id' => { 'value' => card_id, 'encode' => true }
318
359
  )
319
360
  _query_url = APIHelper.clean_url _query_builder
320
361
 
@@ -334,7 +375,9 @@ module Square
334
375
  # Return appropriate response type.
335
376
  decoded = APIHelper.json_deserialize(_response.raw_body)
336
377
  _errors = APIHelper.map_response(decoded, ['errors'])
337
- ApiResponse.new(_response, data: decoded, errors: _errors)
378
+ ApiResponse.new(
379
+ _response, data: decoded, errors: _errors
380
+ )
338
381
  end
339
382
 
340
383
  # Removes a group membership from a customer.
@@ -352,8 +395,8 @@ module Square
352
395
  _query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
353
396
  _query_builder = APIHelper.append_url_with_template_parameters(
354
397
  _query_builder,
355
- 'customer_id' => customer_id,
356
- 'group_id' => group_id
398
+ 'customer_id' => { 'value' => customer_id, 'encode' => true },
399
+ 'group_id' => { 'value' => group_id, 'encode' => true }
357
400
  )
358
401
  _query_url = APIHelper.clean_url _query_builder
359
402
 
@@ -373,7 +416,9 @@ module Square
373
416
  # Return appropriate response type.
374
417
  decoded = APIHelper.json_deserialize(_response.raw_body)
375
418
  _errors = APIHelper.map_response(decoded, ['errors'])
376
- ApiResponse.new(_response, data: decoded, errors: _errors)
419
+ ApiResponse.new(
420
+ _response, data: decoded, errors: _errors
421
+ )
377
422
  end
378
423
 
379
424
  # Adds a group membership to a customer.
@@ -391,8 +436,8 @@ module Square
391
436
  _query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
392
437
  _query_builder = APIHelper.append_url_with_template_parameters(
393
438
  _query_builder,
394
- 'customer_id' => customer_id,
395
- 'group_id' => group_id
439
+ 'customer_id' => { 'value' => customer_id, 'encode' => true },
440
+ 'group_id' => { 'value' => group_id, 'encode' => true }
396
441
  )
397
442
  _query_url = APIHelper.clean_url _query_builder
398
443
 
@@ -412,7 +457,9 @@ module Square
412
457
  # Return appropriate response type.
413
458
  decoded = APIHelper.json_deserialize(_response.raw_body)
414
459
  _errors = APIHelper.map_response(decoded, ['errors'])
415
- ApiResponse.new(_response, data: decoded, errors: _errors)
460
+ ApiResponse.new(
461
+ _response, data: decoded, errors: _errors
462
+ )
416
463
  end
417
464
  end
418
465
  end
@@ -9,17 +9,22 @@ 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](#paginatingresults) for more information.
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.
16
17
  # @param [ProductType] product_type Optional parameter: If specified, only
17
18
  # returns DeviceCodes targeting the specified product type. Returns
18
19
  # DeviceCodes of all product types if empty.
20
+ # @param [DeviceCodeStatus] status Optional parameter: If specified, returns
21
+ # DeviceCodes with the specified statuses. Returns DeviceCodes of status
22
+ # `PAIRED` and `UNPAIRED` if empty.
19
23
  # @return [ListDeviceCodesResponse Hash] response from the API call
20
24
  def list_device_codes(cursor: nil,
21
25
  location_id: nil,
22
- product_type: nil)
26
+ product_type: nil,
27
+ status: nil)
23
28
  # Prepare query url.
24
29
  _query_builder = config.get_base_uri
25
30
  _query_builder << '/v2/devices/codes'
@@ -27,7 +32,8 @@ module Square
27
32
  _query_builder,
28
33
  'cursor' => cursor,
29
34
  'location_id' => location_id,
30
- 'product_type' => product_type
35
+ 'product_type' => product_type,
36
+ 'status' => status
31
37
  )
32
38
  _query_url = APIHelper.clean_url _query_builder
33
39
 
@@ -47,7 +53,9 @@ module Square
47
53
  # Return appropriate response type.
48
54
  decoded = APIHelper.json_deserialize(_response.raw_body)
49
55
  _errors = APIHelper.map_response(decoded, ['errors'])
50
- ApiResponse.new(_response, data: decoded, errors: _errors)
56
+ ApiResponse.new(
57
+ _response, data: decoded, errors: _errors
58
+ )
51
59
  end
52
60
 
53
61
  # Creates a DeviceCode that can be used to login to a Square Terminal device
@@ -66,7 +74,7 @@ module Square
66
74
  # Prepare headers.
67
75
  _headers = {
68
76
  'accept' => 'application/json',
69
- 'content-type' => 'application/json; charset=utf-8'
77
+ 'Content-Type' => 'application/json'
70
78
  }
71
79
 
72
80
  # Prepare and execute HttpRequest.
@@ -81,7 +89,9 @@ module Square
81
89
  # Return appropriate response type.
82
90
  decoded = APIHelper.json_deserialize(_response.raw_body)
83
91
  _errors = APIHelper.map_response(decoded, ['errors'])
84
- ApiResponse.new(_response, data: decoded, errors: _errors)
92
+ ApiResponse.new(
93
+ _response, data: decoded, errors: _errors
94
+ )
85
95
  end
86
96
 
87
97
  # Retrieves DeviceCode with the associated ID.
@@ -94,7 +104,7 @@ module Square
94
104
  _query_builder << '/v2/devices/codes/{id}'
95
105
  _query_builder = APIHelper.append_url_with_template_parameters(
96
106
  _query_builder,
97
- 'id' => id
107
+ 'id' => { 'value' => id, 'encode' => true }
98
108
  )
99
109
  _query_url = APIHelper.clean_url _query_builder
100
110
 
@@ -114,7 +124,9 @@ module Square
114
124
  # Return appropriate response type.
115
125
  decoded = APIHelper.json_deserialize(_response.raw_body)
116
126
  _errors = APIHelper.map_response(decoded, ['errors'])
117
- ApiResponse.new(_response, data: decoded, errors: _errors)
127
+ ApiResponse.new(
128
+ _response, data: decoded, errors: _errors
129
+ )
118
130
  end
119
131
  end
120
132
  end