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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +10 -28
  3. data/README.md +281 -17235
  4. data/lib/square/api/apple_pay_api.rb +55 -54
  5. data/lib/square/api/base_api.rb +45 -45
  6. data/lib/square/api/catalog_api.rb +461 -460
  7. data/lib/square/api/checkout_api.rb +54 -54
  8. data/lib/square/api/customers_api.rb +335 -334
  9. data/lib/square/api/employees_api.rb +91 -91
  10. data/lib/square/api/inventory_api.rb +300 -298
  11. data/lib/square/api/labor_api.rb +558 -558
  12. data/lib/square/api/locations_api.rb +45 -45
  13. data/lib/square/api/mobile_authorization_api.rb +56 -56
  14. data/lib/square/api/o_auth_api.rb +168 -164
  15. data/lib/square/api/orders_api.rb +269 -151
  16. data/lib/square/api/payments_api.rb +282 -0
  17. data/lib/square/api/refunds_api.rb +149 -0
  18. data/lib/square/api/reporting_api.rb +143 -139
  19. data/lib/square/api/transactions_api.rb +379 -360
  20. data/lib/square/api/v1_employees_api.rb +720 -720
  21. data/lib/square/api/v1_items_api.rb +1651 -1651
  22. data/lib/square/api/v1_locations_api.rb +67 -67
  23. data/lib/square/api/v1_locations_api.rbe +67 -0
  24. data/lib/square/api/v1_transactions_api.rb +574 -574
  25. data/lib/square/api_helper.rb +281 -277
  26. data/lib/square/client.rb +139 -127
  27. data/lib/square/configuration.rb +88 -85
  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/lib/square.rb +52 -50
  38. data/spec/user_journey_spec.rb +4 -1
  39. data/test/api/api_test_base.rb +2 -1
  40. data/test/api/test_catalog_api.rb +59 -0
  41. data/test/api/test_employees_api.rb +36 -0
  42. data/test/api/test_locations_api.rb +35 -0
  43. data/test/api/test_payments_api.rb +42 -0
  44. data/test/api/test_refunds_api.rb +41 -0
  45. metadata +19 -11
@@ -1,298 +1,300 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # InventoryApi
8
- class InventoryApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Returns the [InventoryAdjustment](#type-inventoryadjustment) object
14
- # with the provided `adjustment_id`.
15
- # @param [String] adjustment_id Required parameter: ID of the
16
- # [InventoryAdjustment](#type-inventoryadjustment) to retrieve.
17
- # @return [RetrieveInventoryAdjustmentResponse Hash] response from the API call
18
- def retrieve_inventory_adjustment(adjustment_id:)
19
- # Prepare query url.
20
- _query_builder = config.get_base_uri
21
- _query_builder << '/v2/inventory/adjustment/{adjustment_id}'
22
- _query_builder = APIHelper.append_url_with_template_parameters(
23
- _query_builder,
24
- 'adjustment_id' => adjustment_id
25
- )
26
- _query_url = APIHelper.clean_url _query_builder
27
-
28
- # Prepare headers.
29
- _headers = {
30
- 'accept' => 'application/json'
31
- }
32
-
33
- # Prepare and execute HttpRequest.
34
- _request = config.http_client.get(
35
- _query_url,
36
- headers: _headers
37
- )
38
- OAuth2.apply(config, _request)
39
- _response = execute_request(_request)
40
-
41
- # Return appropriate response type.
42
- decoded = APIHelper.json_deserialize(_response.raw_body)
43
- _errors = APIHelper.map_response(decoded, ['errors'])
44
- ApiResponse.new(_response, data: decoded, errors: _errors)
45
- end
46
-
47
- # Applies adjustments and counts to the provided item quantities.
48
- # On success: returns the current calculated counts for all objects
49
- # referenced in the request.
50
- # On failure: returns a list of related errors.
51
- # @param [BatchChangeInventoryRequest] body Required parameter: An object
52
- # containing the fields to POST for the request. See the corresponding
53
- # object definition for field details.
54
- # @return [BatchChangeInventoryResponse Hash] response from the API call
55
- def batch_change_inventory(body:)
56
- # Prepare query url.
57
- _query_builder = config.get_base_uri
58
- _query_builder << '/v2/inventory/batch-change'
59
- _query_url = APIHelper.clean_url _query_builder
60
-
61
- # Prepare headers.
62
- _headers = {
63
- 'accept' => 'application/json',
64
- 'content-type' => 'application/json; charset=utf-8'
65
- }
66
-
67
- # Prepare and execute HttpRequest.
68
- _request = config.http_client.post(
69
- _query_url,
70
- headers: _headers,
71
- parameters: body.to_json
72
- )
73
- OAuth2.apply(config, _request)
74
- _response = execute_request(_request)
75
-
76
- # Return appropriate response type.
77
- decoded = APIHelper.json_deserialize(_response.raw_body)
78
- _errors = APIHelper.map_response(decoded, ['errors'])
79
- ApiResponse.new(_response, data: decoded, errors: _errors)
80
- end
81
-
82
- # Returns historical physical counts and adjustments based on the
83
- # provided filter criteria.
84
- # Results are paginated and sorted in ascending order according their
85
- # `occurred_at` timestamp (oldest first).
86
- # BatchRetrieveInventoryChanges is a catch-all query endpoint for queries
87
- # that cannot be handled by other, simpler endpoints.
88
- # @param [BatchRetrieveInventoryChangesRequest] body Required parameter: An
89
- # object containing the fields to POST for the request. See the
90
- # corresponding object definition for field details.
91
- # @return [BatchRetrieveInventoryChangesResponse Hash] response from the API call
92
- def batch_retrieve_inventory_changes(body:)
93
- # Prepare query url.
94
- _query_builder = config.get_base_uri
95
- _query_builder << '/v2/inventory/batch-retrieve-changes'
96
- _query_url = APIHelper.clean_url _query_builder
97
-
98
- # Prepare headers.
99
- _headers = {
100
- 'accept' => 'application/json',
101
- 'content-type' => 'application/json; charset=utf-8'
102
- }
103
-
104
- # Prepare and execute HttpRequest.
105
- _request = config.http_client.post(
106
- _query_url,
107
- headers: _headers,
108
- parameters: body.to_json
109
- )
110
- OAuth2.apply(config, _request)
111
- _response = execute_request(_request)
112
-
113
- # Return appropriate response type.
114
- decoded = APIHelper.json_deserialize(_response.raw_body)
115
- _errors = APIHelper.map_response(decoded, ['errors'])
116
- ApiResponse.new(_response, data: decoded, errors: _errors)
117
- end
118
-
119
- # Returns current counts for the provided
120
- # [CatalogObject](#type-catalogobject)s at the requested
121
- # [Location](#type-location)s.
122
- # Results are paginated and sorted in descending order according to their
123
- # `calculated_at` timestamp (newest first).
124
- # When `updated_after` is specified, only counts that have changed since
125
- # that
126
- # time (based on the server timestamp for the most recent change) are
127
- # returned. This allows clients to perform a "sync" operation, for example
128
- # in response to receiving a Webhook notification.
129
- # @param [BatchRetrieveInventoryCountsRequest] body Required parameter: An
130
- # object containing the fields to POST for the request. See the
131
- # corresponding object definition for field details.
132
- # @return [BatchRetrieveInventoryCountsResponse Hash] response from the API call
133
- def batch_retrieve_inventory_counts(body:)
134
- # Prepare query url.
135
- _query_builder = config.get_base_uri
136
- _query_builder << '/v2/inventory/batch-retrieve-counts'
137
- _query_url = APIHelper.clean_url _query_builder
138
-
139
- # Prepare headers.
140
- _headers = {
141
- 'accept' => 'application/json',
142
- 'content-type' => 'application/json; charset=utf-8'
143
- }
144
-
145
- # Prepare and execute HttpRequest.
146
- _request = config.http_client.post(
147
- _query_url,
148
- headers: _headers,
149
- parameters: body.to_json
150
- )
151
- OAuth2.apply(config, _request)
152
- _response = execute_request(_request)
153
-
154
- # Return appropriate response type.
155
- decoded = APIHelper.json_deserialize(_response.raw_body)
156
- _errors = APIHelper.map_response(decoded, ['errors'])
157
- ApiResponse.new(_response, data: decoded, errors: _errors)
158
- end
159
-
160
- # Returns the [InventoryPhysicalCount](#type-inventoryphysicalcount)
161
- # object with the provided `physical_count_id`.
162
- # @param [String] physical_count_id Required parameter: ID of the
163
- # [InventoryPhysicalCount](#type-inventoryphysicalcount) to retrieve.
164
- # @return [RetrieveInventoryPhysicalCountResponse Hash] response from the API call
165
- def retrieve_inventory_physical_count(physical_count_id:)
166
- # Prepare query url.
167
- _query_builder = config.get_base_uri
168
- _query_builder << '/v2/inventory/physical-count/{physical_count_id}'
169
- _query_builder = APIHelper.append_url_with_template_parameters(
170
- _query_builder,
171
- 'physical_count_id' => physical_count_id
172
- )
173
- _query_url = APIHelper.clean_url _query_builder
174
-
175
- # Prepare headers.
176
- _headers = {
177
- 'accept' => 'application/json'
178
- }
179
-
180
- # Prepare and execute HttpRequest.
181
- _request = config.http_client.get(
182
- _query_url,
183
- headers: _headers
184
- )
185
- OAuth2.apply(config, _request)
186
- _response = execute_request(_request)
187
-
188
- # Return appropriate response type.
189
- decoded = APIHelper.json_deserialize(_response.raw_body)
190
- _errors = APIHelper.map_response(decoded, ['errors'])
191
- ApiResponse.new(_response, data: decoded, errors: _errors)
192
- end
193
-
194
- # Retrieves the current calculated stock count for a given
195
- # [CatalogObject](#type-catalogobject) at a given set of
196
- # [Location](#type-location)s. Responses are paginated and unsorted.
197
- # For more sophisticated queries, use a batch endpoint.
198
- # @param [String] catalog_object_id Required parameter: ID of the
199
- # [CatalogObject](#type-catalogobject) to retrieve.
200
- # @param [String] location_ids Optional parameter: The
201
- # [Location](#type-location) IDs to look up as a comma-separated list. An
202
- # empty list queries all locations.
203
- # @param [String] cursor Optional parameter: A pagination cursor returned by
204
- # a previous call to this endpoint. Provide this to retrieve the next set of
205
- # results for the original query. See
206
- # [Pagination](/basics/api101/pagination) for more information.
207
- # @return [RetrieveInventoryCountResponse Hash] response from the API call
208
- def retrieve_inventory_count(catalog_object_id:,
209
- location_ids: nil,
210
- cursor: nil)
211
- # Prepare query url.
212
- _query_builder = config.get_base_uri
213
- _query_builder << '/v2/inventory/{catalog_object_id}'
214
- _query_builder = APIHelper.append_url_with_template_parameters(
215
- _query_builder,
216
- 'catalog_object_id' => catalog_object_id
217
- )
218
- _query_builder = APIHelper.append_url_with_query_parameters(
219
- _query_builder,
220
- 'location_ids' => location_ids,
221
- 'cursor' => cursor
222
- )
223
- _query_url = APIHelper.clean_url _query_builder
224
-
225
- # Prepare headers.
226
- _headers = {
227
- 'accept' => 'application/json'
228
- }
229
-
230
- # Prepare and execute HttpRequest.
231
- _request = config.http_client.get(
232
- _query_url,
233
- headers: _headers
234
- )
235
- OAuth2.apply(config, _request)
236
- _response = execute_request(_request)
237
-
238
- # Return appropriate response type.
239
- decoded = APIHelper.json_deserialize(_response.raw_body)
240
- _errors = APIHelper.map_response(decoded, ['errors'])
241
- ApiResponse.new(_response, data: decoded, errors: _errors)
242
- end
243
-
244
- # Returns a set of physical counts and inventory adjustments for the
245
- # provided [CatalogObject](#type-catalogobject) at the requested
246
- # [Location](#type-location)s.
247
- # Results are paginated and sorted in descending order according to their
248
- # `occurred_at` timestamp (newest first).
249
- # There are no limits on how far back the caller can page. This endpoint is
250
- # useful when displaying recent changes for a specific item. For more
251
- # sophisticated queries, use a batch endpoint.
252
- # @param [String] catalog_object_id Required parameter: ID of the
253
- # [CatalogObject](#type-catalogobject) to retrieve.
254
- # @param [String] location_ids Optional parameter: The
255
- # [Location](#type-location) IDs to look up as a comma-separated list. An
256
- # empty list queries all locations.
257
- # @param [String] cursor Optional parameter: A pagination cursor returned by
258
- # a previous call to this endpoint. Provide this to retrieve the next set of
259
- # results for the original query. See
260
- # [Pagination](/basics/api101/pagination) for more information.
261
- # @return [RetrieveInventoryChangesResponse Hash] response from the API call
262
- def retrieve_inventory_changes(catalog_object_id:,
263
- location_ids: nil,
264
- cursor: nil)
265
- # Prepare query url.
266
- _query_builder = config.get_base_uri
267
- _query_builder << '/v2/inventory/{catalog_object_id}/changes'
268
- _query_builder = APIHelper.append_url_with_template_parameters(
269
- _query_builder,
270
- 'catalog_object_id' => catalog_object_id
271
- )
272
- _query_builder = APIHelper.append_url_with_query_parameters(
273
- _query_builder,
274
- 'location_ids' => location_ids,
275
- 'cursor' => cursor
276
- )
277
- _query_url = APIHelper.clean_url _query_builder
278
-
279
- # Prepare headers.
280
- _headers = {
281
- 'accept' => 'application/json'
282
- }
283
-
284
- # Prepare and execute HttpRequest.
285
- _request = config.http_client.get(
286
- _query_url,
287
- headers: _headers
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
- end
298
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # InventoryApi
8
+ class InventoryApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Returns the [InventoryAdjustment](#type-inventoryadjustment) object
14
+ # with the provided `adjustment_id`.
15
+ # @param [String] adjustment_id Required parameter: ID of the
16
+ # [InventoryAdjustment](#type-inventoryadjustment) to retrieve.
17
+ # @return [RetrieveInventoryAdjustmentResponse Hash] response from the API call
18
+ def retrieve_inventory_adjustment(adjustment_id:)
19
+ # Prepare query url.
20
+ _query_builder = config.get_base_uri
21
+ _query_builder << '/v2/inventory/adjustment/{adjustment_id}'
22
+ _query_builder = APIHelper.append_url_with_template_parameters(
23
+ _query_builder,
24
+ 'adjustment_id' => adjustment_id
25
+ )
26
+ _query_url = APIHelper.clean_url _query_builder
27
+
28
+ # Prepare headers.
29
+ _headers = {
30
+ 'accept' => 'application/json'
31
+ }
32
+
33
+ # Prepare and execute HttpRequest.
34
+ _request = config.http_client.get(
35
+ _query_url,
36
+ headers: _headers
37
+ )
38
+ OAuth2.apply(config, _request)
39
+ _response = execute_request(_request)
40
+
41
+ # Return appropriate response type.
42
+ decoded = APIHelper.json_deserialize(_response.raw_body)
43
+ _errors = APIHelper.map_response(decoded, ['errors'])
44
+ ApiResponse.new(_response, data: decoded, errors: _errors)
45
+ end
46
+
47
+ # Applies adjustments and counts to the provided item quantities.
48
+ # On success: returns the current calculated counts for all objects
49
+ # referenced in the request.
50
+ # On failure: returns a list of related errors.
51
+ # @param [BatchChangeInventoryRequest] body Required parameter: An object
52
+ # containing the fields to POST for the request. See the corresponding
53
+ # object definition for field details.
54
+ # @return [BatchChangeInventoryResponse Hash] response from the API call
55
+ def batch_change_inventory(body:)
56
+ # Prepare query url.
57
+ _query_builder = config.get_base_uri
58
+ _query_builder << '/v2/inventory/batch-change'
59
+ _query_url = APIHelper.clean_url _query_builder
60
+
61
+ # Prepare headers.
62
+ _headers = {
63
+ 'accept' => 'application/json',
64
+ 'content-type' => 'application/json; charset=utf-8'
65
+ }
66
+
67
+ # Prepare and execute HttpRequest.
68
+ _request = config.http_client.post(
69
+ _query_url,
70
+ headers: _headers,
71
+ parameters: body.to_json
72
+ )
73
+ OAuth2.apply(config, _request)
74
+ _response = execute_request(_request)
75
+
76
+ # Return appropriate response type.
77
+ decoded = APIHelper.json_deserialize(_response.raw_body)
78
+ _errors = APIHelper.map_response(decoded, ['errors'])
79
+ ApiResponse.new(_response, data: decoded, errors: _errors)
80
+ end
81
+
82
+ # Returns historical physical counts and adjustments based on the
83
+ # provided filter criteria.
84
+ # Results are paginated and sorted in ascending order according their
85
+ # `occurred_at` timestamp (oldest first).
86
+ # BatchRetrieveInventoryChanges is a catch-all query endpoint for queries
87
+ # that cannot be handled by other, simpler endpoints.
88
+ # @param [BatchRetrieveInventoryChangesRequest] body Required parameter: An
89
+ # object containing the fields to POST for the request. See the
90
+ # corresponding object definition for field details.
91
+ # @return [BatchRetrieveInventoryChangesResponse Hash] response from the API call
92
+ def batch_retrieve_inventory_changes(body:)
93
+ # Prepare query url.
94
+ _query_builder = config.get_base_uri
95
+ _query_builder << '/v2/inventory/batch-retrieve-changes'
96
+ _query_url = APIHelper.clean_url _query_builder
97
+
98
+ # Prepare headers.
99
+ _headers = {
100
+ 'accept' => 'application/json',
101
+ 'content-type' => 'application/json; charset=utf-8'
102
+ }
103
+
104
+ # Prepare and execute HttpRequest.
105
+ _request = config.http_client.post(
106
+ _query_url,
107
+ headers: _headers,
108
+ parameters: body.to_json
109
+ )
110
+ OAuth2.apply(config, _request)
111
+ _response = execute_request(_request)
112
+
113
+ # Return appropriate response type.
114
+ decoded = APIHelper.json_deserialize(_response.raw_body)
115
+ _errors = APIHelper.map_response(decoded, ['errors'])
116
+ ApiResponse.new(_response, data: decoded, errors: _errors)
117
+ end
118
+
119
+ # Returns current counts for the provided
120
+ # [CatalogObject](#type-catalogobject)s at the requested
121
+ # [Location](#type-location)s.
122
+ # Results are paginated and sorted in descending order according to their
123
+ # `calculated_at` timestamp (newest first).
124
+ # When `updated_after` is specified, only counts that have changed since
125
+ # that
126
+ # time (based on the server timestamp for the most recent change) are
127
+ # returned. This allows clients to perform a "sync" operation, for example
128
+ # in response to receiving a Webhook notification.
129
+ # @param [BatchRetrieveInventoryCountsRequest] body Required parameter: An
130
+ # object containing the fields to POST for the request. See the
131
+ # corresponding object definition for field details.
132
+ # @return [BatchRetrieveInventoryCountsResponse Hash] response from the API call
133
+ def batch_retrieve_inventory_counts(body:)
134
+ # Prepare query url.
135
+ _query_builder = config.get_base_uri
136
+ _query_builder << '/v2/inventory/batch-retrieve-counts'
137
+ _query_url = APIHelper.clean_url _query_builder
138
+
139
+ # Prepare headers.
140
+ _headers = {
141
+ 'accept' => 'application/json',
142
+ 'content-type' => 'application/json; charset=utf-8'
143
+ }
144
+
145
+ # Prepare and execute HttpRequest.
146
+ _request = config.http_client.post(
147
+ _query_url,
148
+ headers: _headers,
149
+ parameters: body.to_json
150
+ )
151
+ OAuth2.apply(config, _request)
152
+ _response = execute_request(_request)
153
+
154
+ # Return appropriate response type.
155
+ decoded = APIHelper.json_deserialize(_response.raw_body)
156
+ _errors = APIHelper.map_response(decoded, ['errors'])
157
+ ApiResponse.new(_response, data: decoded, errors: _errors)
158
+ end
159
+
160
+ # Returns the [InventoryPhysicalCount](#type-inventoryphysicalcount)
161
+ # object with the provided `physical_count_id`.
162
+ # @param [String] physical_count_id Required parameter: ID of the
163
+ # [InventoryPhysicalCount](#type-inventoryphysicalcount) to retrieve.
164
+ # @return [RetrieveInventoryPhysicalCountResponse Hash] response from the API call
165
+ def retrieve_inventory_physical_count(physical_count_id:)
166
+ # Prepare query url.
167
+ _query_builder = config.get_base_uri
168
+ _query_builder << '/v2/inventory/physical-count/{physical_count_id}'
169
+ _query_builder = APIHelper.append_url_with_template_parameters(
170
+ _query_builder,
171
+ 'physical_count_id' => physical_count_id
172
+ )
173
+ _query_url = APIHelper.clean_url _query_builder
174
+
175
+ # Prepare headers.
176
+ _headers = {
177
+ 'accept' => 'application/json'
178
+ }
179
+
180
+ # Prepare and execute HttpRequest.
181
+ _request = config.http_client.get(
182
+ _query_url,
183
+ headers: _headers
184
+ )
185
+ OAuth2.apply(config, _request)
186
+ _response = execute_request(_request)
187
+
188
+ # Return appropriate response type.
189
+ decoded = APIHelper.json_deserialize(_response.raw_body)
190
+ _errors = APIHelper.map_response(decoded, ['errors'])
191
+ ApiResponse.new(_response, data: decoded, errors: _errors)
192
+ end
193
+
194
+ # Retrieves the current calculated stock count for a given
195
+ # [CatalogObject](#type-catalogobject) at a given set of
196
+ # [Location](#type-location)s. Responses are paginated and unsorted.
197
+ # For more sophisticated queries, use a batch endpoint.
198
+ # @param [String] catalog_object_id Required parameter: ID of the
199
+ # [CatalogObject](#type-catalogobject) to retrieve.
200
+ # @param [String] location_ids Optional parameter: The
201
+ # [Location](#type-location) IDs to look up as a comma-separated list. An
202
+ # empty list queries all locations.
203
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
204
+ # a previous call to this endpoint. Provide this to retrieve the next set of
205
+ # results for the original query. See
206
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
207
+ # for more information.
208
+ # @return [RetrieveInventoryCountResponse Hash] response from the API call
209
+ def retrieve_inventory_count(catalog_object_id:,
210
+ location_ids: nil,
211
+ cursor: nil)
212
+ # Prepare query url.
213
+ _query_builder = config.get_base_uri
214
+ _query_builder << '/v2/inventory/{catalog_object_id}'
215
+ _query_builder = APIHelper.append_url_with_template_parameters(
216
+ _query_builder,
217
+ 'catalog_object_id' => catalog_object_id
218
+ )
219
+ _query_builder = APIHelper.append_url_with_query_parameters(
220
+ _query_builder,
221
+ 'location_ids' => location_ids,
222
+ 'cursor' => cursor
223
+ )
224
+ _query_url = APIHelper.clean_url _query_builder
225
+
226
+ # Prepare headers.
227
+ _headers = {
228
+ 'accept' => 'application/json'
229
+ }
230
+
231
+ # Prepare and execute HttpRequest.
232
+ _request = config.http_client.get(
233
+ _query_url,
234
+ headers: _headers
235
+ )
236
+ OAuth2.apply(config, _request)
237
+ _response = execute_request(_request)
238
+
239
+ # Return appropriate response type.
240
+ decoded = APIHelper.json_deserialize(_response.raw_body)
241
+ _errors = APIHelper.map_response(decoded, ['errors'])
242
+ ApiResponse.new(_response, data: decoded, errors: _errors)
243
+ end
244
+
245
+ # Returns a set of physical counts and inventory adjustments for the
246
+ # provided [CatalogObject](#type-catalogobject) at the requested
247
+ # [Location](#type-location)s.
248
+ # Results are paginated and sorted in descending order according to their
249
+ # `occurred_at` timestamp (newest first).
250
+ # There are no limits on how far back the caller can page. This endpoint is
251
+ # useful when displaying recent changes for a specific item. For more
252
+ # sophisticated queries, use a batch endpoint.
253
+ # @param [String] catalog_object_id Required parameter: ID of the
254
+ # [CatalogObject](#type-catalogobject) to retrieve.
255
+ # @param [String] location_ids Optional parameter: The
256
+ # [Location](#type-location) IDs to look up as a comma-separated list. An
257
+ # empty list queries all locations.
258
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
259
+ # a previous call to this endpoint. Provide this to retrieve the next set of
260
+ # results for the original query. See
261
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
262
+ # for more information.
263
+ # @return [RetrieveInventoryChangesResponse Hash] response from the API call
264
+ def retrieve_inventory_changes(catalog_object_id:,
265
+ location_ids: nil,
266
+ cursor: nil)
267
+ # Prepare query url.
268
+ _query_builder = config.get_base_uri
269
+ _query_builder << '/v2/inventory/{catalog_object_id}/changes'
270
+ _query_builder = APIHelper.append_url_with_template_parameters(
271
+ _query_builder,
272
+ 'catalog_object_id' => catalog_object_id
273
+ )
274
+ _query_builder = APIHelper.append_url_with_query_parameters(
275
+ _query_builder,
276
+ 'location_ids' => location_ids,
277
+ 'cursor' => cursor
278
+ )
279
+ _query_url = APIHelper.clean_url _query_builder
280
+
281
+ # Prepare headers.
282
+ _headers = {
283
+ 'accept' => 'application/json'
284
+ }
285
+
286
+ # Prepare and execute HttpRequest.
287
+ _request = config.http_client.get(
288
+ _query_url,
289
+ headers: _headers
290
+ )
291
+ OAuth2.apply(config, _request)
292
+ _response = execute_request(_request)
293
+
294
+ # Return appropriate response type.
295
+ decoded = APIHelper.json_deserialize(_response.raw_body)
296
+ _errors = APIHelper.map_response(decoded, ['errors'])
297
+ ApiResponse.new(_response, data: decoded, errors: _errors)
298
+ end
299
+ end
300
+ end