square.rb 3.20190814.0 → 3.20190925.0

Sign up to get free protection for your applications and to get access to all the features.
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,91 +1,91 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # EmployeesApi
8
- class EmployeesApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Gets a list of `Employee` objects for a business.
14
- # @param [String] location_id Optional parameter: Filter employees returned
15
- # to only those that are associated with the specified location.
16
- # @param [EmployeeStatus] status Optional parameter: Specifies the
17
- # EmployeeStatus to filter the employee by.
18
- # @param [Integer] limit Optional parameter: The number of employees to be
19
- # returned on each page.
20
- # @param [String] cursor Optional parameter: The token required to retrieve
21
- # the specified page of results.
22
- # @return [ListEmployeesResponse Hash] response from the API call
23
- def list_employees(location_id: nil,
24
- status: nil,
25
- limit: nil,
26
- cursor: nil)
27
- # Prepare query url.
28
- _query_builder = config.get_base_uri
29
- _query_builder << '/v2/employees'
30
- _query_builder = APIHelper.append_url_with_query_parameters(
31
- _query_builder,
32
- 'location_id' => location_id,
33
- 'status' => status,
34
- 'limit' => limit,
35
- 'cursor' => cursor
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
- # Gets an `Employee` by Square-assigned employee `ID` (UUID)
59
- # @param [String] id Required parameter: UUID for the employee that was
60
- # requested.
61
- # @return [RetrieveEmployeeResponse Hash] response from the API call
62
- def retrieve_employee(id:)
63
- # Prepare query url.
64
- _query_builder = config.get_base_uri
65
- _query_builder << '/v2/employees/{id}'
66
- _query_builder = APIHelper.append_url_with_template_parameters(
67
- _query_builder,
68
- 'id' => id
69
- )
70
- _query_url = APIHelper.clean_url _query_builder
71
-
72
- # Prepare headers.
73
- _headers = {
74
- 'accept' => 'application/json'
75
- }
76
-
77
- # Prepare and execute HttpRequest.
78
- _request = config.http_client.get(
79
- _query_url,
80
- headers: _headers
81
- )
82
- OAuth2.apply(config, _request)
83
- _response = execute_request(_request)
84
-
85
- # Return appropriate response type.
86
- decoded = APIHelper.json_deserialize(_response.raw_body)
87
- _errors = APIHelper.map_response(decoded, ['errors'])
88
- ApiResponse.new(_response, data: decoded, errors: _errors)
89
- end
90
- end
91
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # EmployeesApi
8
+ class EmployeesApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Gets a list of `Employee` objects for a business.
14
+ # @param [String] location_id Optional parameter: Filter employees returned
15
+ # to only those that are associated with the specified location.
16
+ # @param [EmployeeStatus] status Optional parameter: Specifies the
17
+ # EmployeeStatus to filter the employee by.
18
+ # @param [Integer] limit Optional parameter: The number of employees to be
19
+ # returned on each page.
20
+ # @param [String] cursor Optional parameter: The token required to retrieve
21
+ # the specified page of results.
22
+ # @return [ListEmployeesResponse Hash] response from the API call
23
+ def list_employees(location_id: nil,
24
+ status: nil,
25
+ limit: nil,
26
+ cursor: nil)
27
+ # Prepare query url.
28
+ _query_builder = config.get_base_uri
29
+ _query_builder << '/v2/employees'
30
+ _query_builder = APIHelper.append_url_with_query_parameters(
31
+ _query_builder,
32
+ 'location_id' => location_id,
33
+ 'status' => status,
34
+ 'limit' => limit,
35
+ 'cursor' => cursor
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
+ # Gets an `Employee` by Square-assigned employee `ID` (UUID)
59
+ # @param [String] id Required parameter: UUID for the employee that was
60
+ # requested.
61
+ # @return [RetrieveEmployeeResponse Hash] response from the API call
62
+ def retrieve_employee(id:)
63
+ # Prepare query url.
64
+ _query_builder = config.get_base_uri
65
+ _query_builder << '/v2/employees/{id}'
66
+ _query_builder = APIHelper.append_url_with_template_parameters(
67
+ _query_builder,
68
+ 'id' => id
69
+ )
70
+ _query_url = APIHelper.clean_url _query_builder
71
+
72
+ # Prepare headers.
73
+ _headers = {
74
+ 'accept' => 'application/json'
75
+ }
76
+
77
+ # Prepare and execute HttpRequest.
78
+ _request = config.http_client.get(
79
+ _query_url,
80
+ headers: _headers
81
+ )
82
+ OAuth2.apply(config, _request)
83
+ _response = execute_request(_request)
84
+
85
+ # Return appropriate response type.
86
+ decoded = APIHelper.json_deserialize(_response.raw_body)
87
+ _errors = APIHelper.map_response(decoded, ['errors'])
88
+ ApiResponse.new(_response, data: decoded, errors: _errors)
89
+ end
90
+ end
91
+ end
@@ -1,300 +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](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
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