ok
Direktori : /home2/selectio/www/fms-worksuite/vendor/square/square/src/Apis/ |
Current File : /home2/selectio/www/fms-worksuite/vendor/square/square/src/Apis/InventoryApi.php |
<?php declare(strict_types=1); namespace Square\Apis; use Square\Exceptions\ApiException; use Square\ApiHelper; use Square\ConfigurationInterface; use Square\Http\ApiResponse; use Square\Http\HttpRequest; use Square\Http\HttpResponse; use Square\Http\HttpMethod; use Square\Http\HttpContext; use Square\Http\HttpCallBack; use Unirest\Request; class InventoryApi extends BaseApi { public function __construct(ConfigurationInterface $config, array $authManagers, ?HttpCallBack $httpCallBack) { parent::__construct($config, $authManagers, $httpCallBack); } /** * Deprecated version of [RetrieveInventoryAdjustment]($e/Inventory/RetrieveInventoryAdjustment) after * the endpoint URL * is updated to conform to the standard convention. * * @deprecated * * @param string $adjustmentId ID of the [InventoryAdjustment]($m/InventoryAdjustment) to * retrieve. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function deprecatedRetrieveInventoryAdjustment(string $adjustmentId): ApiResponse { trigger_error('Method ' . __METHOD__ . ' is deprecated.', E_USER_DEPRECATED); //prepare query string for API call $_queryBuilder = '/v2/inventory/adjustment/{adjustment_id}'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'adjustment_id' => $adjustmentId, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\RetrieveInventoryAdjustmentResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Returns the [InventoryAdjustment]($m/InventoryAdjustment) object * with the provided `adjustment_id`. * * @param string $adjustmentId ID of the [InventoryAdjustment]($m/InventoryAdjustment) to * retrieve. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function retrieveInventoryAdjustment(string $adjustmentId): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/adjustments/{adjustment_id}'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'adjustment_id' => $adjustmentId, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\RetrieveInventoryAdjustmentResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Deprecated version of [BatchChangeInventory]($e/Inventory/BatchChangeInventory) after the endpoint * URL * is updated to conform to the standard convention. * * @deprecated * * @param \Square\Models\BatchChangeInventoryRequest $body An object containing the fields to * POST for the request. * * See the corresponding object definition for field details. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function deprecatedBatchChangeInventory(\Square\Models\BatchChangeInventoryRequest $body): ApiResponse { trigger_error('Method ' . __METHOD__ . ' is deprecated.', E_USER_DEPRECATED); //prepare query string for API call $_queryBuilder = '/v2/inventory/batch-change'; //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion(), 'Content-Type' => 'application/json' ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); //json encode body $_bodyJson = Request\Body::Json($body); $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::post($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders(), $_bodyJson); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass($response->body, 'Square\\Models\\BatchChangeInventoryResponse'); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Deprecated version of [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges) * after the endpoint URL * is updated to conform to the standard convention. * * @deprecated * * @param \Square\Models\BatchRetrieveInventoryChangesRequest $body An object containing the * fields to POST for the request. * * See the corresponding object definition for field details. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function deprecatedBatchRetrieveInventoryChanges( \Square\Models\BatchRetrieveInventoryChangesRequest $body ): ApiResponse { trigger_error('Method ' . __METHOD__ . ' is deprecated.', E_USER_DEPRECATED); //prepare query string for API call $_queryBuilder = '/v2/inventory/batch-retrieve-changes'; //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion(), 'Content-Type' => 'application/json' ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); //json encode body $_bodyJson = Request\Body::Json($body); $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::post($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders(), $_bodyJson); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\BatchRetrieveInventoryChangesResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Deprecated version of [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCounts) * after the endpoint URL * is updated to conform to the standard convention. * * @deprecated * * @param \Square\Models\BatchRetrieveInventoryCountsRequest $body An object containing the * fields to POST for the request. * * See the corresponding object definition for field details. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function deprecatedBatchRetrieveInventoryCounts( \Square\Models\BatchRetrieveInventoryCountsRequest $body ): ApiResponse { trigger_error('Method ' . __METHOD__ . ' is deprecated.', E_USER_DEPRECATED); //prepare query string for API call $_queryBuilder = '/v2/inventory/batch-retrieve-counts'; //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion(), 'Content-Type' => 'application/json' ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); //json encode body $_bodyJson = Request\Body::Json($body); $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::post($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders(), $_bodyJson); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\BatchRetrieveInventoryCountsResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * 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. * * @param \Square\Models\BatchChangeInventoryRequest $body An object containing the fields to * POST for the request. * * See the corresponding object definition for field details. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function batchChangeInventory(\Square\Models\BatchChangeInventoryRequest $body): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/changes/batch-create'; //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion(), 'Content-Type' => 'application/json' ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); //json encode body $_bodyJson = Request\Body::Json($body); $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::post($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders(), $_bodyJson); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass($response->body, 'Square\\Models\\BatchChangeInventoryResponse'); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * 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. * * @param \Square\Models\BatchRetrieveInventoryChangesRequest $body An object containing the * fields to POST for the request. * * See the corresponding object definition for field details. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function batchRetrieveInventoryChanges( \Square\Models\BatchRetrieveInventoryChangesRequest $body ): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/changes/batch-retrieve'; //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion(), 'Content-Type' => 'application/json' ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); //json encode body $_bodyJson = Request\Body::Json($body); $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::post($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders(), $_bodyJson); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\BatchRetrieveInventoryChangesResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * 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. * * @param \Square\Models\BatchRetrieveInventoryCountsRequest $body An object containing the * fields to POST for the request. * * See the corresponding object definition for field details. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function batchRetrieveInventoryCounts(\Square\Models\BatchRetrieveInventoryCountsRequest $body): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/counts/batch-retrieve'; //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion(), 'Content-Type' => 'application/json' ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); //json encode body $_bodyJson = Request\Body::Json($body); $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::post($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders(), $_bodyJson); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\BatchRetrieveInventoryCountsResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Deprecated version of [RetrieveInventoryPhysicalCount]($e/Inventory/RetrieveInventoryPhysicalCount) * after the endpoint URL * is updated to conform to the standard convention. * * @deprecated * * @param string $physicalCountId ID of the [InventoryPhysicalCount]($m/InventoryPhysicalCount) * to retrieve. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function deprecatedRetrieveInventoryPhysicalCount(string $physicalCountId): ApiResponse { trigger_error('Method ' . __METHOD__ . ' is deprecated.', E_USER_DEPRECATED); //prepare query string for API call $_queryBuilder = '/v2/inventory/physical-count/{physical_count_id}'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'physical_count_id' => $physicalCountId, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\RetrieveInventoryPhysicalCountResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount) * object with the provided `physical_count_id`. * * @param string $physicalCountId ID of the [InventoryPhysicalCount]($m/InventoryPhysicalCount) * to retrieve. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function retrieveInventoryPhysicalCount(string $physicalCountId): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/physical-counts/{physical_count_id}'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'physical_count_id' => $physicalCountId, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass( $response->body, 'Square\\Models\\RetrieveInventoryPhysicalCountResponse' ); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * Returns the [InventoryTransfer]($m/InventoryTransfer) object * with the provided `transfer_id`. * * @param string $transferId ID of the [InventoryTransfer]($m/InventoryTransfer) to retrieve. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function retrieveInventoryTransfer(string $transferId): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/transfers/{transfer_id}'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'transfer_id' => $transferId, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass($response->body, 'Square\\Models\\RetrieveInventoryTransferResponse'); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * 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. * * @param string $catalogObjectId ID of the [CatalogObject]($m/CatalogObject) to retrieve. * @param string|null $locationIds The [Location]($m/Location) IDs to look up as a * comma-separated * list. An empty list queries all locations. * @param string|null $cursor 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](https://developer.squareup.com/docs/working-with- * apis/pagination) guide for more information. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function retrieveInventoryCount( string $catalogObjectId, ?string $locationIds = null, ?string $cursor = null ): ApiResponse { //prepare query string for API call $_queryBuilder = '/v2/inventory/{catalog_object_id}'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'catalog_object_id' => $catalogObjectId, ]); //process optional query parameters ApiHelper::appendUrlWithQueryParameters($_queryBuilder, [ 'location_ids' => $locationIds, 'cursor' => $cursor, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass($response->body, 'Square\\Models\\RetrieveInventoryCountResponse'); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } /** * 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. * * @deprecated * * @param string $catalogObjectId ID of the [CatalogObject]($m/CatalogObject) to retrieve. * @param string|null $locationIds The [Location]($m/Location) IDs to look up as a * comma-separated * list. An empty list queries all locations. * @param string|null $cursor 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](https://developer.squareup.com/docs/working-with- * apis/pagination) guide for more information. * * @return ApiResponse Response from the API call * * @throws ApiException Thrown if API call fails */ public function retrieveInventoryChanges( string $catalogObjectId, ?string $locationIds = null, ?string $cursor = null ): ApiResponse { trigger_error('Method ' . __METHOD__ . ' is deprecated.', E_USER_DEPRECATED); //prepare query string for API call $_queryBuilder = '/v2/inventory/{catalog_object_id}/changes'; //process optional query parameters $_queryBuilder = ApiHelper::appendUrlWithTemplateParameters($_queryBuilder, [ 'catalog_object_id' => $catalogObjectId, ]); //process optional query parameters ApiHelper::appendUrlWithQueryParameters($_queryBuilder, [ 'location_ids' => $locationIds, 'cursor' => $cursor, ]); //validate and preprocess url $_queryUrl = ApiHelper::cleanUrl($this->config->getBaseUri() . $_queryBuilder); //prepare headers $_headers = [ 'user-agent' => BaseApi::USER_AGENT, 'Accept' => 'application/json', 'Square-Version' => $this->config->getSquareVersion() ]; $_headers = ApiHelper::mergeHeaders($_headers, $this->config->getAdditionalHeaders()); $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); // Apply authorization to request $this->getAuthManager('global')->apply($_httpRequest); //call on-before Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } // and invoke the API call request to fetch the response try { $response = Request::get($_httpRequest->getQueryUrl(), $_httpRequest->getHeaders()); } catch (\Unirest\Exception $ex) { throw new ApiException($ex->getMessage(), $_httpRequest); } $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); //call on-after Http callback if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnAfterRequest($_httpContext); } if (!$this->isValidResponse($_httpResponse)) { return ApiResponse::createFromContext($response->body, null, $_httpContext); } $mapper = $this->getJsonMapper(); $deserializedResponse = $mapper->mapClass($response->body, 'Square\\Models\\RetrieveInventoryChangesResponse'); return ApiResponse::createFromContext($response->body, $deserializedResponse, $_httpContext); } }