o
    tBh
                     @   sD   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 )    )	APIHelper)ApiResponse)BaseApi)OAuth2c                       sD   e Zd ZdZd	 fdd	Z								d
ddZdd Z  ZS )GiftCardActivitiesApiz3A Controller to access Endpoints in the square API.Nc                    s   t t| || d S N)superr   __init__)selfconfig	call_back	__class__ z/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/gift_card_activities_api.pyr	      s   zGiftCardActivitiesApi.__init__c	              	   C   s   d}	| j  }
|
|	7 }
||||||||d}t|
|}
t|
}ddi}| j jj||d}t| j | | 	|}t
|j}t|tu rL|d}nd}t|||d}|S )	a  Does a GET request to /v2/gift-cards/activities.

        Lists gift card activities. By default, you get gift card activities
        for all
        gift cards in the seller's account. You can optionally specify query
        parameters to
        filter the list. For example, you can get a list of gift card
        activities for a gift card,
        for all gift cards in a specific region, or for activities within a
        time window.

        Args:
            gift_card_id (string, optional): If a gift card ID is provided,
                the endpoint returns activities related  to the specified gift
                card. Otherwise, the endpoint returns all gift card activities
                for  the seller.
            mtype (string, optional): If a [type]($m/GiftCardActivityType) is
                provided, the endpoint returns gift card activities of the
                specified type.  Otherwise, the endpoint returns all types of
                gift card activities.
            location_id (string, optional): If a location ID is provided, the
                endpoint returns gift card activities for the specified
                location.  Otherwise, the endpoint returns gift card
                activities for all locations.
            begin_time (string, optional): The timestamp for the beginning of
                the reporting period, in RFC 3339 format. This start time is
                inclusive. The default value is the current time minus one
                year.
            end_time (string, optional): The timestamp for the end of the
                reporting period, in RFC 3339 format. This end time is
                inclusive. The default value is the current time.
            limit (int, optional): If a limit is provided, the endpoint
                returns the specified number  of results (or fewer) per page.
                The maximum value is 100. The default value is 50. For more
                information, see
                [Pagination](https://developer.squareup.com/docs/working-with-a
                pis/pagination).
            cursor (string, optional): A pagination cursor returned by a
                previous call to this endpoint. Provide this cursor to
                retrieve the next set of results for the original query. If a
                cursor is not provided, the endpoint returns the first page of
                the results. For more information, see
                [Pagination](https://developer.squareup.com/docs/working-with-a
                pis/pagination).
            sort_order (string, optional): The order in which the endpoint
                returns the activities, based on `created_at`. - `ASC` -
                Oldest to newest. - `DESC` - Newest to oldest (default).

        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.

        /v2/gift-cards/activities)gift_card_idtypelocation_id
begin_timeend_timelimitcursor
sort_orderacceptapplication/json)headerserrorsNbodyr   )r   get_base_urir    append_url_with_query_parameters	clean_urlhttp_clientgetr   applyexecute_requestjson_deserializetextr   dictr   )r
   r   mtyper   r   r   r   r   r   	_url_path_query_builder_query_parameters
_query_url_headers_request	_responsedecoded_errors_resultr   r   r   list_gift_card_activities   s8   F



z/GiftCardActivitiesApi.list_gift_card_activitiesc                 C   s   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/gift-cards/activities.

        Creates a gift card activity. For more information, see 
        [GiftCardActivity](https://developer.squareup.com/docs/gift-cards/using
        -gift-cards-api#giftcardactivity) and 
        [Using activated gift
        cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-
        api#using-activated-gift-cards).

        Args:
            body (CreateGiftCardActivityRequest): 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.

        r   r   )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/   r0   r1   r2   r3   r4   r   r   r   create_gift_card_activity{   s    


z/GiftCardActivitiesApi.create_gift_card_activityr   )NNNNNNNN)__name__
__module____qualname____doc__r	   r5   r9   __classcell__r   r   r   r   r   	   s    
kr   N)	square.api_helperr   square.http.api_responser   square.api.base_apir   square.http.auth.o_auth_2r   r   r   r   r   r   <module>   s
   