o
    tBhp                     @   sP   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 G dd deZ
dS )	    )
deprecated)	APIHelper)ApiResponse)BaseApi)OAuth2c                       s   e Zd ZdZd fdd	Ze dd Zdd Ze d	d
 Ze dd Z	e dd Z
dd Zdd Zdd Ze dd Zdd Zdd Z		d ddZe 		d ddZ  ZS )!InventoryApiz3A Controller to access Endpoints in the square API.Nc                    s   t t| || d S N)superr   __init__)selfconfig	call_back	__class__ o/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/inventory_api.pyr
      s   zInventoryApi.__init__c                 C      d}t |d|ddi}| j }||7 }t |}ddi}| jjj||d}t| j| | 	|}t 
|j}t|tu rF|d}	nd	}	t|||	d
}
|
S )aX  Does a GET request to /v2/inventory/adjustment/{adjustment_id}.

        Deprecated version of
        [RetrieveInventoryAdjustment]($e/Inventory/RetrieveInventoryAdjustment)
        after the endpoint URL 
        is updated to conform to the standard convention.

        Args:
            adjustment_id (string): ID of the
                [InventoryAdjustment]($m/InventoryAdjustment) to retrieve.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z(/v2/inventory/adjustment/{adjustment_id}adjustment_idTvalueencodeacceptapplication/jsonheaderserrorsNbodyr   r   #append_url_with_template_parametersr   get_base_uri	clean_urlhttp_clientgetr   applyexecute_requestjson_deserializetexttypedictr   r   r   	_url_path_query_builder
_query_url_headers_request	_responsedecoded_errors_resultr   r   r   (deprecated_retrieve_inventory_adjustment   s$   



z5InventoryApi.deprecated_retrieve_inventory_adjustmentc                 C   r   )a  Does a GET request to /v2/inventory/adjustments/{adjustment_id}.

        Returns the [InventoryAdjustment]($m/InventoryAdjustment) object
        with the provided `adjustment_id`.

        Args:
            adjustment_id (string): ID of the
                [InventoryAdjustment]($m/InventoryAdjustment) to retrieve.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z)/v2/inventory/adjustments/{adjustment_id}r   Tr   r   r   r   r   Nr   r   r*   r   r   r   retrieve_inventory_adjustmentF   $   



z*InventoryApi.retrieve_inventory_adjustmentc                 C      d}| j  }||7 }t|}ddd}| j jj||t|d}t| j | | 	|}t
|j}t|tu r@|d}	nd}	t|||	d}
|
S )a  Does a POST request to /v2/inventory/batch-change.

        Deprecated version of
        [BatchChangeInventory]($e/Inventory/BatchChangeInventory) after the
        endpoint URL 
        is updated to conform to the standard convention.

        Args:
            body (BatchChangeInventoryRequest): An object containing the
                fields to POST for the request.  See the corresponding object
                definition for field details.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z/v2/inventory/batch-changer   r   zContent-Typer   
parametersr   Nr   r   r    r   r!   r"   postjson_serializer   r$   r%   r&   r'   r(   r)   r#   r   r   r   r+   r,   r-   r.   r/   r0   r1   r2   r3   r   r   r   !deprecated_batch_change_inventoryx       


z.InventoryApi.deprecated_batch_change_inventoryc                 C   r7   )a  Does a POST request to /v2/inventory/batch-retrieve-changes.

        Deprecated version of
        [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChan
        ges) after the endpoint URL 
        is updated to conform to the standard convention.

        Args:
            body (BatchRetrieveInventoryChangesRequest): An object containing
                the fields to POST for the request.  See the corresponding
                object definition for field details.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z$/v2/inventory/batch-retrieve-changesr   r8   r9   r   Nr   r;   r>   r   r   r   +deprecated_batch_retrieve_inventory_changes   r@   z8InventoryApi.deprecated_batch_retrieve_inventory_changesc                 C   r7   )a  Does a POST request to /v2/inventory/batch-retrieve-counts.

        Deprecated version of
        [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCount
        s) after the endpoint URL 
        is updated to conform to the standard convention.

        Args:
            body (BatchRetrieveInventoryCountsRequest): An object containing
                the fields to POST for the request.  See the corresponding
                object definition for field details.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z#/v2/inventory/batch-retrieve-countsr   r8   r9   r   Nr   r;   r>   r   r   r   *deprecated_batch_retrieve_inventory_counts   r@   z7InventoryApi.deprecated_batch_retrieve_inventory_countsc                 C   r7   )a  Does a POST request to /v2/inventory/changes/batch-create.

        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.

        Args:
            body (BatchChangeInventoryRequest): An object containing the
                fields to POST for the request.  See the corresponding object
                definition for field details.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z"/v2/inventory/changes/batch-creater   r8   r9   r   Nr   r;   r>   r   r   r   batch_change_inventory  s    


z#InventoryApi.batch_change_inventoryc                 C   r7   )a\  Does a POST request to /v2/inventory/changes/batch-retrieve.

        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.

        Args:
            body (BatchRetrieveInventoryChangesRequest): An object containing
                the fields to POST for the request.  See the corresponding
                object definition for field details.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z$/v2/inventory/changes/batch-retriever   r8   r9   r   Nr   r;   r>   r   r   r    batch_retrieve_inventory_changesG  s    


z-InventoryApi.batch_retrieve_inventory_changesc                 C   r7   )a2  Does a POST request to /v2/inventory/counts/batch-retrieve.

        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.

        Args:
            body (BatchRetrieveInventoryCountsRequest): An object containing
                the fields to POST for the request.  See the corresponding
                object definition for field details.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z#/v2/inventory/counts/batch-retriever   r8   r9   r   Nr   r;   r>   r   r   r   batch_retrieve_inventory_counts}  s    #


z,InventoryApi.batch_retrieve_inventory_countsc                 C   r   )a  Does a GET request to /v2/inventory/physical-count/{physical_count_id}.

        Deprecated version of
        [RetrieveInventoryPhysicalCount]($e/Inventory/RetrieveInventoryPhysical
        Count) after the endpoint URL 
        is updated to conform to the standard convention.

        Args:
            physical_count_id (string): ID of the
                [InventoryPhysicalCount]($m/InventoryPhysicalCount) to
                retrieve.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z0/v2/inventory/physical-count/{physical_count_id}physical_count_idTr   r   r   r   r   Nr   r   r   rF   r+   r,   r-   r.   r/   r0   r1   r2   r3   r   r   r   ,deprecated_retrieve_inventory_physical_count  s$   



z9InventoryApi.deprecated_retrieve_inventory_physical_countc                 C   r   )a1  Does a GET request to /v2/inventory/physical-counts/{physical_count_id}.

        Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount)
        object with the provided `physical_count_id`.

        Args:
            physical_count_id (string): ID of the
                [InventoryPhysicalCount]($m/InventoryPhysicalCount) to
                retrieve.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z1/v2/inventory/physical-counts/{physical_count_id}rF   Tr   r   r   r   r   Nr   r   rG   r   r   r   !retrieve_inventory_physical_count  s$   



z.InventoryApi.retrieve_inventory_physical_countc                 C   r   )a  Does a GET request to /v2/inventory/transfers/{transfer_id}.

        Returns the [InventoryTransfer]($m/InventoryTransfer) object
        with the provided `transfer_id`.

        Args:
            transfer_id (string): ID of the
                [InventoryTransfer]($m/InventoryTransfer) to retrieve.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z%/v2/inventory/transfers/{transfer_id}transfer_idTr   r   r   r   r   Nr   r   )r   rJ   r+   r,   r-   r.   r/   r0   r1   r2   r3   r   r   r   retrieve_inventory_transfer!  r6   z(InventoryApi.retrieve_inventory_transferc                 C      d}t |d|ddi}| j }||7 }||d}t ||}t |}ddi}| jjj||d}	t	| j|	 | 
|	}
t |
j}t|tu rQ|d	}nd
}t|
||d}|S )a  Does a GET request to /v2/inventory/{catalog_object_id}.

        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.

        Args:
            catalog_object_id (string): ID of the
                [CatalogObject]($m/CatalogObject) to retrieve.
            location_ids (string, optional): The [Location]($m/Location) IDs
                to look up as a comma-separated list. An empty list queries
                all locations.
            cursor (string, 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](https://developer.squareup.com/docs/working-with-a
                pis/pagination) guide for more information.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z!/v2/inventory/{catalog_object_id}catalog_object_idTr   location_idscursorr   r   r   r   Nr   r   r   r   r     append_url_with_query_parametersr!   r"   r#   r   r$   r%   r&   r'   r(   r)   r   r   rM   rO   rP   r+   r,   _query_parametersr-   r.   r/   r0   r1   r2   r3   r   r   r   retrieve_inventory_countS  s2   $



z%InventoryApi.retrieve_inventory_countc                 C   rL   )a  Does a GET request to /v2/inventory/{catalog_object_id}/changes.

        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/BatchRetrieveInventoryChan
        ges) 
        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.

        Args:
            catalog_object_id (string): ID of the
                [CatalogObject]($m/CatalogObject) to retrieve.
            location_ids (string, optional): The [Location]($m/Location) IDs
                to look up as a comma-separated list. An empty list queries
                all locations.
            cursor (string, 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](https://developer.squareup.com/docs/working-with-a
                pis/pagination) guide for more information.

        Returns:
            ApiResponse: An object with the response value as well as other
                useful information such as status codes and headers. Success

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        z)/v2/inventory/{catalog_object_id}/changesrM   Tr   rN   r   r   r   r   Nr   rQ   rS   r   r   r   retrieve_inventory_changes  s2   0



z'InventoryApi.retrieve_inventory_changesr   )NN)__name__
__module____qualname____doc__r
   r   r4   r5   r?   rA   rB   rC   rD   rE   rH   rI   rK   rU   rV   __classcell__r   r   r   r   r   
   s4    
42
3
3
336;
534
Fr   N)deprecationr   square.api_helperr   square.http.api_responser   square.api.base_apir   square.http.auth.o_auth_2r   r   r   r   r   r   <module>   s   