$inventoryApi = $client->getInventoryApi();InventoryApi
- Retrieve Inventory Adjustment
- Batch Change Inventory
- Batch Retrieve Inventory Changes
- Batch Retrieve Inventory Counts
- Retrieve Inventory Physical Count
- Retrieve Inventory Count
- Retrieve Inventory Changes
Returns the InventoryAdjustment object
with the provided adjustment_id.
function retrieveInventoryAdjustment(string $adjustmentId): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
adjustmentId |
string |
Template, Required | ID of the InventoryAdjustment to retrieve. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type RetrieveInventoryAdjustmentResponse.
$adjustmentId = 'adjustment_id0';
$apiResponse = $inventoryApi->retrieveInventoryAdjustment($adjustmentId);
if ($apiResponse->isSuccess()) {
$retrieveInventoryAdjustmentResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();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.
function batchChangeInventory(BatchChangeInventoryRequest $body): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
body |
BatchChangeInventoryRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type BatchChangeInventoryResponse.
$body = new Models\BatchChangeInventoryRequest;
$body->setIdempotencyKey('8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe');
$body_changes = [];
$body_changes[0] = new Models\InventoryChange;
$body_changes[0]->setType(Models\InventoryChangeType::PHYSICAL_COUNT);
$body_changes[0]->setPhysicalCount(new Models\InventoryPhysicalCount);
$body_changes[0]->getPhysicalCount()->setId('id0');
$body_changes[0]->getPhysicalCount()->setReferenceId('1536bfbf-efed-48bf-b17d-a197141b2a92');
$body_changes[0]->getPhysicalCount()->setCatalogObjectId('W62UWFY35CWMYGVWK6TWJDNI');
$body_changes[0]->getPhysicalCount()->setCatalogObjectType('catalog_object_type4');
$body_changes[0]->getPhysicalCount()->setState(Models\InventoryState::IN_STOCK);
$body_changes[0]->getPhysicalCount()->setLocationId('C6W5YS5QM06F5');
$body_changes[0]->getPhysicalCount()->setQuantity('53');
$body_changes[0]->getPhysicalCount()->setEmployeeId('LRK57NSQ5X7PUD05');
$body_changes[0]->getPhysicalCount()->setOccurredAt('2016-11-16T22:25:24.878Z');
$body_changes[0]->setAdjustment(new Models\InventoryAdjustment);
$body_changes[0]->getAdjustment()->setId('id6');
$body_changes[0]->getAdjustment()->setReferenceId('reference_id4');
$body_changes[0]->getAdjustment()->setFromState(Models\InventoryState::SOLD);
$body_changes[0]->getAdjustment()->setToState(Models\InventoryState::IN_TRANSIT_TO);
$body_changes[0]->getAdjustment()->setLocationId('location_id0');
$body_changes[0]->setTransfer(new Models\InventoryTransfer);
$body_changes[0]->getTransfer()->setId('id0');
$body_changes[0]->getTransfer()->setReferenceId('reference_id8');
$body_changes[0]->getTransfer()->setState(Models\InventoryState::SOLD);
$body_changes[0]->getTransfer()->setFromLocationId('from_location_id2');
$body_changes[0]->getTransfer()->setToLocationId('to_location_id2');
$body->setChanges($body_changes);
$body->setIgnoreUnchangedCounts(true);
$apiResponse = $inventoryApi->batchChangeInventory($body);
if ($apiResponse->isSuccess()) {
$batchChangeInventoryResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();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.
function batchRetrieveInventoryChanges(BatchRetrieveInventoryChangesRequest $body): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
body |
BatchRetrieveInventoryChangesRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type BatchRetrieveInventoryChangesResponse.
$body = new Models\BatchRetrieveInventoryChangesRequest;
$body->setCatalogObjectIds(['W62UWFY35CWMYGVWK6TWJDNI']);
$body->setLocationIds(['C6W5YS5QM06F5']);
$body->setTypes([Models\InventoryChangeType::PHYSICAL_COUNT]);
$body->setStates([Models\InventoryState::IN_STOCK]);
$body->setUpdatedAfter('2016-11-01T00:00:00.000Z');
$body->setUpdatedBefore('2016-12-01T00:00:00.000Z');
$apiResponse = $inventoryApi->batchRetrieveInventoryChanges($body);
if ($apiResponse->isSuccess()) {
$batchRetrieveInventoryChangesResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();Returns current counts for the provided CatalogObjects at the requested Locations.
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.
function batchRetrieveInventoryCounts(BatchRetrieveInventoryCountsRequest $body): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
body |
BatchRetrieveInventoryCountsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type BatchRetrieveInventoryCountsResponse.
$body = new Models\BatchRetrieveInventoryCountsRequest;
$body->setCatalogObjectIds(['W62UWFY35CWMYGVWK6TWJDNI']);
$body->setLocationIds(['59TNP9SA8VGDA']);
$body->setUpdatedAfter('2016-11-16T00:00:00.000Z');
$body->setCursor('cursor0');
$body->setStates([Models\InventoryState::IN_TRANSIT_TO]);
$apiResponse = $inventoryApi->batchRetrieveInventoryCounts($body);
if ($apiResponse->isSuccess()) {
$batchRetrieveInventoryCountsResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();Returns the InventoryPhysicalCount
object with the provided physical_count_id.
function retrieveInventoryPhysicalCount(string $physicalCountId): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
physicalCountId |
string |
Template, Required | ID of the InventoryPhysicalCount to retrieve. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type RetrieveInventoryPhysicalCountResponse.
$physicalCountId = 'physical_count_id2';
$apiResponse = $inventoryApi->retrieveInventoryPhysicalCount($physicalCountId);
if ($apiResponse->isSuccess()) {
$retrieveInventoryPhysicalCountResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();Retrieves the current calculated stock count for a given CatalogObject at a given set of Locations. Responses are paginated and unsorted. For more sophisticated queries, use a batch endpoint.
function retrieveInventoryCount(
string $catalogObjectId,
?string $locationIds = null,
?string $cursor = null
): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
catalogObjectId |
string |
Template, Required | ID of the CatalogObject to retrieve. |
locationIds |
?string |
Query, Optional | The Location IDs to look up as a comma-separated list. An empty list queries all locations. |
cursor |
?string |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See the Pagination guide for more information. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type RetrieveInventoryCountResponse.
$catalogObjectId = 'catalog_object_id6';
$locationIds = 'location_ids0';
$cursor = 'cursor6';
$apiResponse = $inventoryApi->retrieveInventoryCount($catalogObjectId, $locationIds, $cursor);
if ($apiResponse->isSuccess()) {
$retrieveInventoryCountResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();Returns a set of physical counts and inventory adjustments for the provided CatalogObject at the requested Locations.
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.
function retrieveInventoryChanges(
string $catalogObjectId,
?string $locationIds = null,
?string $cursor = null
): ApiResponse| Parameter | Type | Tags | Description |
|---|---|---|---|
catalogObjectId |
string |
Template, Required | ID of the CatalogObject to retrieve. |
locationIds |
?string |
Query, Optional | The Location IDs to look up as a comma-separated list. An empty list queries all locations. |
cursor |
?string |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See the Pagination guide for more information. |
This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type RetrieveInventoryChangesResponse.
$catalogObjectId = 'catalog_object_id6';
$locationIds = 'location_ids0';
$cursor = 'cursor6';
$apiResponse = $inventoryApi->retrieveInventoryChanges($catalogObjectId, $locationIds, $cursor);
if ($apiResponse->isSuccess()) {
$retrieveInventoryChangesResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Get more response info...
// $statusCode = $apiResponse->getStatusCode();
// $headers = $apiResponse->getHeaders();