Class: Square::InventoryApi
- Defined in:
- lib/square/api/inventory_api.rb
Overview
InventoryApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#batch_change_inventory(body:) ⇒ BatchChangeInventoryResponse Hash
Applies adjustments and counts to the provided item quantities.
-
#batch_retrieve_inventory_changes(body:) ⇒ BatchRetrieveInventoryChangesResponse Hash
Returns historical physical counts and adjustments based on the provided filter criteria.
-
#batch_retrieve_inventory_counts(body:) ⇒ BatchRetrieveInventoryCountsResponse Hash
Returns current counts for the provided [CatalogObject]($m/CatalogObject)s at the requested [Location]($m/Location)s.
-
#deprecated_batch_change_inventory(body:) ⇒ BatchChangeInventoryResponse Hash
Deprecated version of [BatchChangeInventory]($e/Inventory/BatchChangeInventory) after the endpoint URL is updated to conform to the standard convention.
-
#deprecated_batch_retrieve_inventory_changes(body:) ⇒ BatchRetrieveInventoryChangesResponse Hash
Deprecated version of [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges ) after the endpoint URL is updated to conform to the standard convention.
-
#deprecated_batch_retrieve_inventory_counts(body:) ⇒ BatchRetrieveInventoryCountsResponse Hash
Deprecated version of [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCounts) after the endpoint URL is updated to conform to the standard convention.
-
#deprecated_retrieve_inventory_adjustment(adjustment_id:) ⇒ RetrieveInventoryAdjustmentResponse Hash
Deprecated version of [RetrieveInventoryAdjustment]($e/Inventory/RetrieveInventoryAdjustment) after the endpoint URL is updated to conform to the standard convention.
-
#deprecated_retrieve_inventory_physical_count(physical_count_id:) ⇒ RetrieveInventoryPhysicalCountResponse Hash
Deprecated version of [RetrieveInventoryPhysicalCount]($e/Inventory/RetrieveInventoryPhysicalCou nt) after the endpoint URL is updated to conform to the standard convention.
-
#initialize(config, http_call_back: nil) ⇒ InventoryApi
constructor
A new instance of InventoryApi.
-
#retrieve_inventory_adjustment(adjustment_id:) ⇒ RetrieveInventoryAdjustmentResponse Hash
Returns the [InventoryAdjustment]($m/InventoryAdjustment) object with the provided ‘adjustment_id`.
-
#retrieve_inventory_changes(catalog_object_id:, location_ids: nil, cursor: nil) ⇒ RetrieveInventoryChangesResponse Hash
Returns a set of physical counts and inventory adjustments for the provided [CatalogObject]($m/CatalogObject) at the requested [Location]($m/Location)s.
-
#retrieve_inventory_count(catalog_object_id:, location_ids: nil, cursor: nil) ⇒ RetrieveInventoryCountResponse Hash
Retrieves the current calculated stock count for a given [CatalogObject]($m/CatalogObject) at a given set of [Location]($m/Location)s.
-
#retrieve_inventory_physical_count(physical_count_id:) ⇒ RetrieveInventoryPhysicalCountResponse Hash
Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount) object with the provided ‘physical_count_id`.
-
#retrieve_inventory_transfer(transfer_id:) ⇒ RetrieveInventoryTransferResponse Hash
Returns the [InventoryTransfer]($m/InventoryTransfer) object with the provided ‘transfer_id`.
Methods inherited from BaseApi
#execute_request, #get_user_agent, #validate_parameters
Constructor Details
#initialize(config, http_call_back: nil) ⇒ InventoryApi
Returns a new instance of InventoryApi.
4 5 6 |
# File 'lib/square/api/inventory_api.rb', line 4 def initialize(config, http_call_back: nil) super(config, http_call_back: http_call_back) end |
Instance Method Details
#batch_change_inventory(body:) ⇒ BatchChangeInventoryResponse Hash
Applies adjustments and counts to the provided item quantities. On success: returns the current calculated counts for all objects referenced in the request. On failure: returns a list of related errors. containing the fields to POST for the request. See the corresponding object definition for field details.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/square/api/inventory_api.rb', line 209 def batch_change_inventory(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/changes/batch-create' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#batch_retrieve_inventory_changes(body:) ⇒ BatchRetrieveInventoryChangesResponse Hash
Returns historical physical counts and adjustments based on the provided filter criteria. Results are paginated and sorted in ascending order according their ‘occurred_at` timestamp (oldest first). BatchRetrieveInventoryChanges is a catch-all query endpoint for queries that cannot be handled by other, simpler endpoints. object containing the fields to POST for the request. See the corresponding object definition for field details.
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/square/api/inventory_api.rb', line 248 def batch_retrieve_inventory_changes(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/changes/batch-retrieve' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#batch_retrieve_inventory_counts(body:) ⇒ BatchRetrieveInventoryCountsResponse Hash
Returns current counts for the provided [CatalogObject]($m/CatalogObject)s at the requested [Location]($m/Location)s. Results are paginated and sorted in descending order according to their ‘calculated_at` timestamp (newest first). When `updated_after` is specified, only counts that have changed since that time (based on the server timestamp for the most recent change) are returned. This allows clients to perform a “sync” operation, for example in response to receiving a Webhook notification. object containing the fields to POST for the request. See the corresponding object definition for field details.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/square/api/inventory_api.rb', line 291 def batch_retrieve_inventory_counts(body:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/counts/batch-retrieve' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#deprecated_batch_change_inventory(body:) ⇒ BatchChangeInventoryResponse Hash
Deprecated version of [BatchChangeInventory]($e/Inventory/BatchChangeInventory) after the endpoint URL is updated to conform to the standard convention. containing the fields to POST for the request. See the corresponding object definition for field details.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/square/api/inventory_api.rb', line 92 def deprecated_batch_change_inventory(body:) warn 'Endpoint deprecated_batch_change_inventory in InventoryApi is depr'\ 'ecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/batch-change' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#deprecated_batch_retrieve_inventory_changes(body:) ⇒ BatchRetrieveInventoryChangesResponse Hash
Deprecated version of [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges ) after the endpoint URL is updated to conform to the standard convention. object containing the fields to POST for the request. See the corresponding object definition for field details.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/square/api/inventory_api.rb', line 131 def deprecated_batch_retrieve_inventory_changes(body:) warn 'Endpoint deprecated_batch_retrieve_inventory_changes in InventoryA'\ 'pi is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/batch-retrieve-changes' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#deprecated_batch_retrieve_inventory_counts(body:) ⇒ BatchRetrieveInventoryCountsResponse Hash
Deprecated version of [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCounts) after the endpoint URL is updated to conform to the standard convention. object containing the fields to POST for the request. See the corresponding object definition for field details.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/square/api/inventory_api.rb', line 170 def deprecated_batch_retrieve_inventory_counts(body:) warn 'Endpoint deprecated_batch_retrieve_inventory_counts in InventoryAp'\ 'i is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/batch-retrieve-counts' _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'Content-Type' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#deprecated_retrieve_inventory_adjustment(adjustment_id:) ⇒ RetrieveInventoryAdjustmentResponse Hash
Deprecated version of [RetrieveInventoryAdjustment]($e/Inventory/RetrieveInventoryAdjustment) after the endpoint URL is updated to conform to the standard convention. [InventoryAdjustment]($m/InventoryAdjustment) to retrieve.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/square/api/inventory_api.rb', line 15 def deprecated_retrieve_inventory_adjustment(adjustment_id:) warn 'Endpoint deprecated_retrieve_inventory_adjustment in InventoryApi '\ 'is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/adjustment/{adjustment_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'adjustment_id' => { 'value' => adjustment_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#deprecated_retrieve_inventory_physical_count(physical_count_id:) ⇒ RetrieveInventoryPhysicalCountResponse Hash
Deprecated version of [RetrieveInventoryPhysicalCount]($e/Inventory/RetrieveInventoryPhysicalCou nt) after the endpoint URL is updated to conform to the standard convention. [InventoryPhysicalCount]($m/InventoryPhysicalCount) to retrieve.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/square/api/inventory_api.rb', line 327 def deprecated_retrieve_inventory_physical_count(physical_count_id:) warn 'Endpoint deprecated_retrieve_inventory_physical_count in Inventory'\ 'Api is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/physical-count/{physical_count_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'physical_count_id' => { 'value' => physical_count_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_inventory_adjustment(adjustment_id:) ⇒ RetrieveInventoryAdjustmentResponse Hash
Returns the [InventoryAdjustment]($m/InventoryAdjustment) object with the provided ‘adjustment_id`. [InventoryAdjustment]($m/InventoryAdjustment) to retrieve.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/square/api/inventory_api.rb', line 53 def retrieve_inventory_adjustment(adjustment_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/adjustments/{adjustment_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'adjustment_id' => { 'value' => adjustment_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_inventory_changes(catalog_object_id:, location_ids: nil, cursor: nil) ⇒ RetrieveInventoryChangesResponse Hash
Returns a set of physical counts and inventory adjustments for the provided [CatalogObject]($m/CatalogObject) at the requested [Location]($m/Location)s. You can achieve the same result by calling [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges ) and having the ‘catalog_object_ids` list contain a single element of the `CatalogObject` ID. Results are paginated and sorted in descending order according to their `occurred_at` timestamp (newest first). There are no limits on how far back the caller can page. This endpoint can be used to display recent changes for a specific item. For more sophisticated queries, use a batch endpoint. [CatalogObject]($m/CatalogObject) to retrieve. [Location]($m/Location) IDs to look up as a comma-separated list. An empty list queries all locations. a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See the [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion) guide for more information.
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/square/api/inventory_api.rb', line 510 def retrieve_inventory_changes(catalog_object_id:, location_ids: nil, cursor: nil) warn 'Endpoint retrieve_inventory_changes in InventoryApi is deprecated' # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/{catalog_object_id}/changes' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'catalog_object_id' => { 'value' => catalog_object_id, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'location_ids' => location_ids, 'cursor' => cursor ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_inventory_count(catalog_object_id:, location_ids: nil, cursor: nil) ⇒ RetrieveInventoryCountResponse Hash
Retrieves the current calculated stock count for a given [CatalogObject]($m/CatalogObject) at a given set of [Location]($m/Location)s. Responses are paginated and unsorted. For more sophisticated queries, use a batch endpoint. [CatalogObject]($m/CatalogObject) to retrieve. [Location]($m/Location) IDs to look up as a comma-separated list. An empty list queries all locations. a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See the [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion) guide for more information.
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/square/api/inventory_api.rb', line 447 def retrieve_inventory_count(catalog_object_id:, location_ids: nil, cursor: nil) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/{catalog_object_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'catalog_object_id' => { 'value' => catalog_object_id, 'encode' => true } ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, 'location_ids' => location_ids, 'cursor' => cursor ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_inventory_physical_count(physical_count_id:) ⇒ RetrieveInventoryPhysicalCountResponse Hash
Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount) object with the provided ‘physical_count_id`. [InventoryPhysicalCount]($m/InventoryPhysicalCount) to retrieve.
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/square/api/inventory_api.rb', line 365 def retrieve_inventory_physical_count(physical_count_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/physical-counts/{physical_count_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'physical_count_id' => { 'value' => physical_count_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |
#retrieve_inventory_transfer(transfer_id:) ⇒ RetrieveInventoryTransferResponse Hash
Returns the [InventoryTransfer]($m/InventoryTransfer) object with the provided ‘transfer_id`. [InventoryTransfer]($m/InventoryTransfer) to retrieve.
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/square/api/inventory_api.rb', line 401 def retrieve_inventory_transfer(transfer_id:) # Prepare query url. _query_builder = config.get_base_uri _query_builder << '/v2/inventory/transfers/{transfer_id}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'transfer_id' => { 'value' => transfer_id, 'encode' => true } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) OAuth2.apply(config, _request) _response = execute_request(_request) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) _errors = APIHelper.map_response(decoded, ['errors']) ApiResponse.new( _response, data: decoded, errors: _errors ) end |