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
@@ -0,0 +1,391 @@
1
+ module Square
2
+ # BookingsApi
3
+ class BookingsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Retrieve a collection of bookings.
9
+ # To call this endpoint with buyer-level permissions, set
10
+ # `APPOINTMENTS_READ` for the OAuth scope.
11
+ # To call this endpoint with seller-level permissions, set
12
+ # `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
13
+ # @param [Integer] limit Optional parameter: The maximum number of results
14
+ # per page to return in a paged response.
15
+ # @param [String] cursor Optional parameter: The pagination cursor from the
16
+ # preceding response to return the next page of the results. Do not set this
17
+ # when retrieving the first page of the results.
18
+ # @param [String] team_member_id Optional parameter: The team member for
19
+ # whom to retrieve bookings. If this is not set, bookings of all members are
20
+ # retrieved.
21
+ # @param [String] location_id Optional parameter: The location for which to
22
+ # retrieve bookings. If this is not set, all locations' bookings are
23
+ # retrieved.
24
+ # @param [String] start_at_min Optional parameter: The RFC 3339 timestamp
25
+ # specifying the earliest of the start time. If this is not set, the current
26
+ # time is used.
27
+ # @param [String] start_at_max Optional parameter: The RFC 3339 timestamp
28
+ # specifying the latest of the start time. If this is not set, the time of
29
+ # 31 days after `start_at_min` is used.
30
+ # @return [ListBookingsResponse Hash] response from the API call
31
+ def list_bookings(limit: nil,
32
+ cursor: nil,
33
+ team_member_id: nil,
34
+ location_id: nil,
35
+ start_at_min: nil,
36
+ start_at_max: nil)
37
+ # Prepare query url.
38
+ _query_builder = config.get_base_uri
39
+ _query_builder << '/v2/bookings'
40
+ _query_builder = APIHelper.append_url_with_query_parameters(
41
+ _query_builder,
42
+ 'limit' => limit,
43
+ 'cursor' => cursor,
44
+ 'team_member_id' => team_member_id,
45
+ 'location_id' => location_id,
46
+ 'start_at_min' => start_at_min,
47
+ 'start_at_max' => start_at_max
48
+ )
49
+ _query_url = APIHelper.clean_url _query_builder
50
+
51
+ # Prepare headers.
52
+ _headers = {
53
+ 'accept' => 'application/json'
54
+ }
55
+
56
+ # Prepare and execute HttpRequest.
57
+ _request = config.http_client.get(
58
+ _query_url,
59
+ headers: _headers
60
+ )
61
+ OAuth2.apply(config, _request)
62
+ _response = execute_request(_request)
63
+
64
+ # Return appropriate response type.
65
+ decoded = APIHelper.json_deserialize(_response.raw_body)
66
+ _errors = APIHelper.map_response(decoded, ['errors'])
67
+ ApiResponse.new(
68
+ _response, data: decoded, errors: _errors
69
+ )
70
+ end
71
+
72
+ # Creates a booking.
73
+ # To call this endpoint with buyer-level permissions, set
74
+ # `APPOINTMENTS_WRITE` for the OAuth scope.
75
+ # To call this endpoint with seller-level permissions, set
76
+ # `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
77
+ # @param [CreateBookingRequest] body Required parameter: An object
78
+ # containing the fields to POST for the request. See the corresponding
79
+ # object definition for field details.
80
+ # @return [CreateBookingResponse Hash] response from the API call
81
+ def create_booking(body:)
82
+ # Prepare query url.
83
+ _query_builder = config.get_base_uri
84
+ _query_builder << '/v2/bookings'
85
+ _query_url = APIHelper.clean_url _query_builder
86
+
87
+ # Prepare headers.
88
+ _headers = {
89
+ 'accept' => 'application/json',
90
+ 'Content-Type' => 'application/json'
91
+ }
92
+
93
+ # Prepare and execute HttpRequest.
94
+ _request = config.http_client.post(
95
+ _query_url,
96
+ headers: _headers,
97
+ parameters: body.to_json
98
+ )
99
+ OAuth2.apply(config, _request)
100
+ _response = execute_request(_request)
101
+
102
+ # Return appropriate response type.
103
+ decoded = APIHelper.json_deserialize(_response.raw_body)
104
+ _errors = APIHelper.map_response(decoded, ['errors'])
105
+ ApiResponse.new(
106
+ _response, data: decoded, errors: _errors
107
+ )
108
+ end
109
+
110
+ # Searches for availabilities for booking.
111
+ # To call this endpoint with buyer-level permissions, set
112
+ # `APPOINTMENTS_READ` for the OAuth scope.
113
+ # To call this endpoint with seller-level permissions, set
114
+ # `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
115
+ # @param [SearchAvailabilityRequest] body Required parameter: An object
116
+ # containing the fields to POST for the request. See the corresponding
117
+ # object definition for field details.
118
+ # @return [SearchAvailabilityResponse Hash] response from the API call
119
+ def search_availability(body:)
120
+ # Prepare query url.
121
+ _query_builder = config.get_base_uri
122
+ _query_builder << '/v2/bookings/availability/search'
123
+ _query_url = APIHelper.clean_url _query_builder
124
+
125
+ # Prepare headers.
126
+ _headers = {
127
+ 'accept' => 'application/json',
128
+ 'Content-Type' => 'application/json'
129
+ }
130
+
131
+ # Prepare and execute HttpRequest.
132
+ _request = config.http_client.post(
133
+ _query_url,
134
+ headers: _headers,
135
+ parameters: body.to_json
136
+ )
137
+ OAuth2.apply(config, _request)
138
+ _response = execute_request(_request)
139
+
140
+ # Return appropriate response type.
141
+ decoded = APIHelper.json_deserialize(_response.raw_body)
142
+ _errors = APIHelper.map_response(decoded, ['errors'])
143
+ ApiResponse.new(
144
+ _response, data: decoded, errors: _errors
145
+ )
146
+ end
147
+
148
+ # Retrieves a seller's booking profile.
149
+ # @return [RetrieveBusinessBookingProfileResponse Hash] response from the API call
150
+ def retrieve_business_booking_profile
151
+ # Prepare query url.
152
+ _query_builder = config.get_base_uri
153
+ _query_builder << '/v2/bookings/business-booking-profile'
154
+ _query_url = APIHelper.clean_url _query_builder
155
+
156
+ # Prepare headers.
157
+ _headers = {
158
+ 'accept' => 'application/json'
159
+ }
160
+
161
+ # Prepare and execute HttpRequest.
162
+ _request = config.http_client.get(
163
+ _query_url,
164
+ headers: _headers
165
+ )
166
+ OAuth2.apply(config, _request)
167
+ _response = execute_request(_request)
168
+
169
+ # Return appropriate response type.
170
+ decoded = APIHelper.json_deserialize(_response.raw_body)
171
+ _errors = APIHelper.map_response(decoded, ['errors'])
172
+ ApiResponse.new(
173
+ _response, data: decoded, errors: _errors
174
+ )
175
+ end
176
+
177
+ # Lists booking profiles for team members.
178
+ # @param [Boolean] bookable_only Optional parameter: Indicates whether to
179
+ # include only bookable team members in the returned result (`true`) or not
180
+ # (`false`).
181
+ # @param [Integer] limit Optional parameter: The maximum number of results
182
+ # to return in a paged response.
183
+ # @param [String] cursor Optional parameter: The pagination cursor from the
184
+ # preceding response to return the next page of the results. Do not set this
185
+ # when retrieving the first page of the results.
186
+ # @param [String] location_id Optional parameter: Indicates whether to
187
+ # include only team members enabled at the given location in the returned
188
+ # result.
189
+ # @return [ListTeamMemberBookingProfilesResponse Hash] response from the API call
190
+ def list_team_member_booking_profiles(bookable_only: false,
191
+ limit: nil,
192
+ cursor: nil,
193
+ location_id: nil)
194
+ # Prepare query url.
195
+ _query_builder = config.get_base_uri
196
+ _query_builder << '/v2/bookings/team-member-booking-profiles'
197
+ _query_builder = APIHelper.append_url_with_query_parameters(
198
+ _query_builder,
199
+ 'bookable_only' => bookable_only,
200
+ 'limit' => limit,
201
+ 'cursor' => cursor,
202
+ 'location_id' => location_id
203
+ )
204
+ _query_url = APIHelper.clean_url _query_builder
205
+
206
+ # Prepare headers.
207
+ _headers = {
208
+ 'accept' => 'application/json'
209
+ }
210
+
211
+ # Prepare and execute HttpRequest.
212
+ _request = config.http_client.get(
213
+ _query_url,
214
+ headers: _headers
215
+ )
216
+ OAuth2.apply(config, _request)
217
+ _response = execute_request(_request)
218
+
219
+ # Return appropriate response type.
220
+ decoded = APIHelper.json_deserialize(_response.raw_body)
221
+ _errors = APIHelper.map_response(decoded, ['errors'])
222
+ ApiResponse.new(
223
+ _response, data: decoded, errors: _errors
224
+ )
225
+ end
226
+
227
+ # Retrieves a team member's booking profile.
228
+ # @param [String] team_member_id Required parameter: The ID of the team
229
+ # member to retrieve.
230
+ # @return [RetrieveTeamMemberBookingProfileResponse Hash] response from the API call
231
+ def retrieve_team_member_booking_profile(team_member_id:)
232
+ # Prepare query url.
233
+ _query_builder = config.get_base_uri
234
+ _query_builder << '/v2/bookings/team-member-booking-profiles/{team_member_id}'
235
+ _query_builder = APIHelper.append_url_with_template_parameters(
236
+ _query_builder,
237
+ 'team_member_id' => { 'value' => team_member_id, 'encode' => true }
238
+ )
239
+ _query_url = APIHelper.clean_url _query_builder
240
+
241
+ # Prepare headers.
242
+ _headers = {
243
+ 'accept' => 'application/json'
244
+ }
245
+
246
+ # Prepare and execute HttpRequest.
247
+ _request = config.http_client.get(
248
+ _query_url,
249
+ headers: _headers
250
+ )
251
+ OAuth2.apply(config, _request)
252
+ _response = execute_request(_request)
253
+
254
+ # Return appropriate response type.
255
+ decoded = APIHelper.json_deserialize(_response.raw_body)
256
+ _errors = APIHelper.map_response(decoded, ['errors'])
257
+ ApiResponse.new(
258
+ _response, data: decoded, errors: _errors
259
+ )
260
+ end
261
+
262
+ # Retrieves a booking.
263
+ # To call this endpoint with buyer-level permissions, set
264
+ # `APPOINTMENTS_READ` for the OAuth scope.
265
+ # To call this endpoint with seller-level permissions, set
266
+ # `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
267
+ # @param [String] booking_id Required parameter: The ID of the
268
+ # [Booking]($m/Booking) object representing the to-be-retrieved booking.
269
+ # @return [RetrieveBookingResponse Hash] response from the API call
270
+ def retrieve_booking(booking_id:)
271
+ # Prepare query url.
272
+ _query_builder = config.get_base_uri
273
+ _query_builder << '/v2/bookings/{booking_id}'
274
+ _query_builder = APIHelper.append_url_with_template_parameters(
275
+ _query_builder,
276
+ 'booking_id' => { 'value' => booking_id, 'encode' => true }
277
+ )
278
+ _query_url = APIHelper.clean_url _query_builder
279
+
280
+ # Prepare headers.
281
+ _headers = {
282
+ 'accept' => 'application/json'
283
+ }
284
+
285
+ # Prepare and execute HttpRequest.
286
+ _request = config.http_client.get(
287
+ _query_url,
288
+ headers: _headers
289
+ )
290
+ OAuth2.apply(config, _request)
291
+ _response = execute_request(_request)
292
+
293
+ # Return appropriate response type.
294
+ decoded = APIHelper.json_deserialize(_response.raw_body)
295
+ _errors = APIHelper.map_response(decoded, ['errors'])
296
+ ApiResponse.new(
297
+ _response, data: decoded, errors: _errors
298
+ )
299
+ end
300
+
301
+ # Updates a booking.
302
+ # To call this endpoint with buyer-level permissions, set
303
+ # `APPOINTMENTS_WRITE` for the OAuth scope.
304
+ # To call this endpoint with seller-level permissions, set
305
+ # `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
306
+ # @param [String] booking_id Required parameter: The ID of the
307
+ # [Booking]($m/Booking) object representing the to-be-updated booking.
308
+ # @param [UpdateBookingRequest] body Required parameter: An object
309
+ # containing the fields to POST for the request. See the corresponding
310
+ # object definition for field details.
311
+ # @return [UpdateBookingResponse Hash] response from the API call
312
+ def update_booking(booking_id:,
313
+ body:)
314
+ # Prepare query url.
315
+ _query_builder = config.get_base_uri
316
+ _query_builder << '/v2/bookings/{booking_id}'
317
+ _query_builder = APIHelper.append_url_with_template_parameters(
318
+ _query_builder,
319
+ 'booking_id' => { 'value' => booking_id, 'encode' => true }
320
+ )
321
+ _query_url = APIHelper.clean_url _query_builder
322
+
323
+ # Prepare headers.
324
+ _headers = {
325
+ 'accept' => 'application/json',
326
+ 'Content-Type' => 'application/json'
327
+ }
328
+
329
+ # Prepare and execute HttpRequest.
330
+ _request = config.http_client.put(
331
+ _query_url,
332
+ headers: _headers,
333
+ parameters: body.to_json
334
+ )
335
+ OAuth2.apply(config, _request)
336
+ _response = execute_request(_request)
337
+
338
+ # Return appropriate response type.
339
+ decoded = APIHelper.json_deserialize(_response.raw_body)
340
+ _errors = APIHelper.map_response(decoded, ['errors'])
341
+ ApiResponse.new(
342
+ _response, data: decoded, errors: _errors
343
+ )
344
+ end
345
+
346
+ # Cancels an existing booking.
347
+ # To call this endpoint with buyer-level permissions, set
348
+ # `APPOINTMENTS_WRITE` for the OAuth scope.
349
+ # To call this endpoint with seller-level permissions, set
350
+ # `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
351
+ # @param [String] booking_id Required parameter: The ID of the
352
+ # [Booking]($m/Booking) object representing the to-be-cancelled booking.
353
+ # @param [CancelBookingRequest] body Required parameter: An object
354
+ # containing the fields to POST for the request. See the corresponding
355
+ # object definition for field details.
356
+ # @return [CancelBookingResponse Hash] response from the API call
357
+ def cancel_booking(booking_id:,
358
+ body:)
359
+ # Prepare query url.
360
+ _query_builder = config.get_base_uri
361
+ _query_builder << '/v2/bookings/{booking_id}/cancel'
362
+ _query_builder = APIHelper.append_url_with_template_parameters(
363
+ _query_builder,
364
+ 'booking_id' => { 'value' => booking_id, 'encode' => true }
365
+ )
366
+ _query_url = APIHelper.clean_url _query_builder
367
+
368
+ # Prepare headers.
369
+ _headers = {
370
+ 'accept' => 'application/json',
371
+ 'Content-Type' => 'application/json'
372
+ }
373
+
374
+ # Prepare and execute HttpRequest.
375
+ _request = config.http_client.post(
376
+ _query_url,
377
+ headers: _headers,
378
+ parameters: body.to_json
379
+ )
380
+ OAuth2.apply(config, _request)
381
+ _response = execute_request(_request)
382
+
383
+ # Return appropriate response type.
384
+ decoded = APIHelper.json_deserialize(_response.raw_body)
385
+ _errors = APIHelper.map_response(decoded, ['errors'])
386
+ ApiResponse.new(
387
+ _response, data: decoded, errors: _errors
388
+ )
389
+ end
390
+ end
391
+ end
@@ -0,0 +1,170 @@
1
+ module Square
2
+ # CardsApi
3
+ class CardsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Retrieves a list of cards owned by the account making the request.
9
+ # A max of 25 cards will be returned.
10
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
11
+ # a previous call to this endpoint. Provide this to retrieve the next set of
12
+ # results for your original query. See
13
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
14
+ # for more information.
15
+ # @param [String] customer_id Optional parameter: Limit results to cards
16
+ # associated with the customer supplied. By default, all cards owned by the
17
+ # merchant are returned.
18
+ # @param [Boolean] include_disabled Optional parameter: Includes disabled
19
+ # cards. By default, all enabled cards owned by the merchant are returned.
20
+ # @param [String] reference_id Optional parameter: Limit results to cards
21
+ # associated with the reference_id supplied.
22
+ # @param [SortOrder] sort_order Optional parameter: Sorts the returned list
23
+ # by when the card was created with the specified order. This field defaults
24
+ # to ASC.
25
+ # @return [ListCardsResponse Hash] response from the API call
26
+ def list_cards(cursor: nil,
27
+ customer_id: nil,
28
+ include_disabled: false,
29
+ reference_id: nil,
30
+ sort_order: nil)
31
+ # Prepare query url.
32
+ _query_builder = config.get_base_uri
33
+ _query_builder << '/v2/cards'
34
+ _query_builder = APIHelper.append_url_with_query_parameters(
35
+ _query_builder,
36
+ 'cursor' => cursor,
37
+ 'customer_id' => customer_id,
38
+ 'include_disabled' => include_disabled,
39
+ 'reference_id' => reference_id,
40
+ 'sort_order' => sort_order
41
+ )
42
+ _query_url = APIHelper.clean_url _query_builder
43
+
44
+ # Prepare headers.
45
+ _headers = {
46
+ 'accept' => 'application/json'
47
+ }
48
+
49
+ # Prepare and execute HttpRequest.
50
+ _request = config.http_client.get(
51
+ _query_url,
52
+ headers: _headers
53
+ )
54
+ OAuth2.apply(config, _request)
55
+ _response = execute_request(_request)
56
+
57
+ # Return appropriate response type.
58
+ decoded = APIHelper.json_deserialize(_response.raw_body)
59
+ _errors = APIHelper.map_response(decoded, ['errors'])
60
+ ApiResponse.new(
61
+ _response, data: decoded, errors: _errors
62
+ )
63
+ end
64
+
65
+ # Adds a card on file to an existing merchant.
66
+ # @param [CreateCardRequest] body Required parameter: An object containing
67
+ # the fields to POST for the request. See the corresponding object
68
+ # definition for field details.
69
+ # @return [CreateCardResponse Hash] response from the API call
70
+ def create_card(body:)
71
+ # Prepare query url.
72
+ _query_builder = config.get_base_uri
73
+ _query_builder << '/v2/cards'
74
+ _query_url = APIHelper.clean_url _query_builder
75
+
76
+ # Prepare headers.
77
+ _headers = {
78
+ 'accept' => 'application/json',
79
+ 'Content-Type' => 'application/json'
80
+ }
81
+
82
+ # Prepare and execute HttpRequest.
83
+ _request = config.http_client.post(
84
+ _query_url,
85
+ headers: _headers,
86
+ parameters: body.to_json
87
+ )
88
+ OAuth2.apply(config, _request)
89
+ _response = execute_request(_request)
90
+
91
+ # Return appropriate response type.
92
+ decoded = APIHelper.json_deserialize(_response.raw_body)
93
+ _errors = APIHelper.map_response(decoded, ['errors'])
94
+ ApiResponse.new(
95
+ _response, data: decoded, errors: _errors
96
+ )
97
+ end
98
+
99
+ # Retrieves details for a specific Card.
100
+ # @param [String] card_id Required parameter: Unique ID for the desired
101
+ # Card.
102
+ # @return [RetrieveCardResponse Hash] response from the API call
103
+ def retrieve_card(card_id:)
104
+ # Prepare query url.
105
+ _query_builder = config.get_base_uri
106
+ _query_builder << '/v2/cards/{card_id}'
107
+ _query_builder = APIHelper.append_url_with_template_parameters(
108
+ _query_builder,
109
+ 'card_id' => { 'value' => card_id, 'encode' => true }
110
+ )
111
+ _query_url = APIHelper.clean_url _query_builder
112
+
113
+ # Prepare headers.
114
+ _headers = {
115
+ 'accept' => 'application/json'
116
+ }
117
+
118
+ # Prepare and execute HttpRequest.
119
+ _request = config.http_client.get(
120
+ _query_url,
121
+ headers: _headers
122
+ )
123
+ OAuth2.apply(config, _request)
124
+ _response = execute_request(_request)
125
+
126
+ # Return appropriate response type.
127
+ decoded = APIHelper.json_deserialize(_response.raw_body)
128
+ _errors = APIHelper.map_response(decoded, ['errors'])
129
+ ApiResponse.new(
130
+ _response, data: decoded, errors: _errors
131
+ )
132
+ end
133
+
134
+ # Disables the card, preventing any further updates or charges.
135
+ # Disabling an already disabled card is allowed but has no effect.
136
+ # @param [String] card_id Required parameter: Unique ID for the desired
137
+ # Card.
138
+ # @return [DisableCardResponse Hash] response from the API call
139
+ def disable_card(card_id:)
140
+ # Prepare query url.
141
+ _query_builder = config.get_base_uri
142
+ _query_builder << '/v2/cards/{card_id}/disable'
143
+ _query_builder = APIHelper.append_url_with_template_parameters(
144
+ _query_builder,
145
+ 'card_id' => { 'value' => card_id, 'encode' => true }
146
+ )
147
+ _query_url = APIHelper.clean_url _query_builder
148
+
149
+ # Prepare headers.
150
+ _headers = {
151
+ 'accept' => 'application/json'
152
+ }
153
+
154
+ # Prepare and execute HttpRequest.
155
+ _request = config.http_client.post(
156
+ _query_url,
157
+ headers: _headers
158
+ )
159
+ OAuth2.apply(config, _request)
160
+ _response = execute_request(_request)
161
+
162
+ # Return appropriate response type.
163
+ decoded = APIHelper.json_deserialize(_response.raw_body)
164
+ _errors = APIHelper.map_response(decoded, ['errors'])
165
+ ApiResponse.new(
166
+ _response, data: decoded, errors: _errors
167
+ )
168
+ end
169
+ end
170
+ end
@@ -57,11 +57,14 @@ module Square
57
57
  # Return appropriate response type.
58
58
  decoded = APIHelper.json_deserialize(_response.raw_body)
59
59
  _errors = APIHelper.map_response(decoded, ['errors'])
60
- ApiResponse.new(_response, data: decoded, errors: _errors)
60
+ ApiResponse.new(
61
+ _response, data: decoded, errors: _errors
62
+ )
61
63
  end
62
64
 
63
65
  # Provides the summary details for a single cash drawer shift. See
64
- # RetrieveCashDrawerShiftEvents for a list of cash drawer shift events.
66
+ # [ListCashDrawerShiftEvents]($e/CashDrawers/ListCashDrawerShiftEvents) for
67
+ # a list of cash drawer shift events.
65
68
  # @param [String] location_id Required parameter: The ID of the location to
66
69
  # retrieve cash drawer shifts from.
67
70
  # @param [String] shift_id Required parameter: The shift ID.
@@ -73,7 +76,7 @@ module Square
73
76
  _query_builder << '/v2/cash-drawers/shifts/{shift_id}'
74
77
  _query_builder = APIHelper.append_url_with_template_parameters(
75
78
  _query_builder,
76
- 'shift_id' => shift_id
79
+ 'shift_id' => { 'value' => shift_id, 'encode' => true }
77
80
  )
78
81
  _query_builder = APIHelper.append_url_with_query_parameters(
79
82
  _query_builder,
@@ -97,7 +100,9 @@ module Square
97
100
  # Return appropriate response type.
98
101
  decoded = APIHelper.json_deserialize(_response.raw_body)
99
102
  _errors = APIHelper.map_response(decoded, ['errors'])
100
- ApiResponse.new(_response, data: decoded, errors: _errors)
103
+ ApiResponse.new(
104
+ _response, data: decoded, errors: _errors
105
+ )
101
106
  end
102
107
 
103
108
  # Provides a paginated list of events for a single cash drawer shift.
@@ -118,7 +123,7 @@ module Square
118
123
  _query_builder << '/v2/cash-drawers/shifts/{shift_id}/events'
119
124
  _query_builder = APIHelper.append_url_with_template_parameters(
120
125
  _query_builder,
121
- 'shift_id' => shift_id
126
+ 'shift_id' => { 'value' => shift_id, 'encode' => true }
122
127
  )
123
128
  _query_builder = APIHelper.append_url_with_query_parameters(
124
129
  _query_builder,
@@ -144,7 +149,9 @@ module Square
144
149
  # Return appropriate response type.
145
150
  decoded = APIHelper.json_deserialize(_response.raw_body)
146
151
  _errors = APIHelper.map_response(decoded, ['errors'])
147
- ApiResponse.new(_response, data: decoded, errors: _errors)
152
+ ApiResponse.new(
153
+ _response, data: decoded, errors: _errors
154
+ )
148
155
  end
149
156
  end
150
157
  end