o
    tBhH                     @   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                       s   e Zd ZdZd fdd	Z						dddZdd Zd	d
 Zdd Z				dddZ	dd Z
dd Zdd Zdd Z  ZS )BookingsApiz3A Controller to access Endpoints in the square API.Nc                    s   t t| || d S N)superr   __init__)selfconfig	call_back	__class__ n/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/square/api/bookings_api.pyr	      s   zBookingsApi.__init__c                 C   s   d}| j  }||7 }||||||d}	t||	}t|}
ddi}| j jj|
|d}t| j | | 	|}t
|j}t|tu rJ|d}nd}t|||d}|S )	a|  Does a GET request to /v2/bookings.

        Retrieve a collection of bookings.

        Args:
            limit (int, optional): The maximum number of results per page to
                return in a paged response.
            cursor (string, optional): The pagination cursor from the
                preceding response to return the next page of the results. Do
                not set this when retrieving the first page of the results.
            team_member_id (string, optional): The team member for whom to
                retrieve bookings. If this is not set, bookings of all members
                are retrieved.
            location_id (string, optional): The location for which to retrieve
                bookings. If this is not set, all locations' bookings are
                retrieved.
            start_at_min (string, optional): The RFC 3339 timestamp specifying
                the earliest of the start time. If this is not set, the
                current time is used.
            start_at_max (string, optional): The RFC 3339 timestamp specifying
                the latest of the start time. If this is not set, the time of
                31 days after `start_at_min` is used.

        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/bookings)limitcursorteam_member_idlocation_idstart_at_minstart_at_max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texttypedictr   )r
   r   r   r   r   r   r   	_url_path_query_builder_query_parameters
_query_url_headers_request	_responsedecoded_errors_resultr   r   r   list_bookings   s4   +


zBookingsApi.list_bookingsc                 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/bookings.

        Creates a booking.

        Args:
            body (CreateBookingRequest): 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_booking^       


zBookingsApi.create_bookingc                 C   r6   )a  Does a POST request to /v2/bookings/availability/search.

        Searches for availabilities for booking.

        Args:
            body (SearchAvailabilityRequest): 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/bookings/availability/searchr   r7   r8   r   Nr   r:   r=   r   r   r   search_availability   r?   zBookingsApi.search_availabilityc           
      C   s   d}| j  }||7 }t|}ddi}| j jj||d}t| j | | |}t	|j
}t|tu r;|d}nd}t|||d}	|	S )a3  Does a GET request to /v2/bookings/business-booking-profile.

        Retrieves a seller's booking profile.

        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/bookings/business-booking-profiler   r   r   r   Nr   )r   r    r   r"   r#   r$   r   r%   r&   r'   r(   r)   r*   r   )
r
   r+   r,   r.   r/   r0   r1   r2   r3   r4   r   r   r   !retrieve_business_booking_profile   s   


z-BookingsApi.retrieve_business_booking_profileFc                 C   s   d}| j  }||7 }||||d}t||}t|}ddi}	| j jj||	d}
t| j |
 | 	|
}t
|j}t|tu rH|d}nd}t|||d}|S )	ab  Does a GET request to /v2/bookings/team-member-booking-profiles.

        Lists booking profiles for team members.

        Args:
            bookable_only (bool, optional): Indicates whether to include only
                bookable team members in the returned result (`true`) or not
                (`false`).
            limit (int, optional): The maximum number of results to return.
            cursor (string, optional): The cursor for paginating through the
                results.
            location_id (string, optional): Indicates whether to include only
                team members enabled at the given location in the returned
                result.

        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/bookings/team-member-booking-profiles)bookable_onlyr   r   r   r   r   r   r   Nr   r   )r
   rB   r   r   r   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r   r   r   !list_team_member_booking_profiles   s0   !


z-BookingsApi.list_team_member_booking_profilesc                 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 )a  Does a GET request to /v2/bookings/team-member-booking-profiles/{team_member_id}.

        Retrieves a team member's booking profile.

        Args:
            team_member_id (string): The ID of the team member 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/bookings/team-member-booking-profiles/{team_member_id}r   Tvalueencoder   r   r   r   Nr   r   #append_url_with_template_parametersr   r    r"   r#   r$   r   r%   r&   r'   r(   r)   r*   r   )r
   r   r+   r,   r.   r/   r0   r1   r2   r3   r4   r   r   r   $retrieve_team_member_booking_profile)  s$   



z0BookingsApi.retrieve_team_member_booking_profilec                 C   rD   )a  Does a GET request to /v2/bookings/{booking_id}.

        Retrieves a booking.

        Args:
            booking_id (string): The ID of the [Booking]($m/Booking) object
                representing the to-be-retrieved booking.

        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/bookings/{booking_id}
booking_idTrE   r   r   r   r   Nr   rH   )r
   rL   r+   r,   r.   r/   r0   r1   r2   r3   r4   r   r   r   retrieve_bookingY  s$   



zBookingsApi.retrieve_bookingc                 C      d}t |d|ddi}| j }||7 }t |}ddd}| jjj||t |d}t	| j| | 
|}t |j}	t|	tu rK|	d}
nd	}
t||	|
d
}|S )ae  Does a PUT request to /v2/bookings/{booking_id}.

        Updates a booking.

        Args:
            booking_id (string): The ID of the [Booking]($m/Booking) object
                representing the to-be-updated booking.
            body (UpdateBookingRequest): 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.

        rK   rL   TrE   r   r7   r8   r   Nr   )r   rI   r   r    r"   r#   putr<   r   r%   r&   r'   r(   r)   r*   r$   r   r
   rL   r   r+   r,   r.   r/   r0   r1   r2   r3   r4   r   r   r   update_booking  &   



zBookingsApi.update_bookingc                 C   rN   )ay  Does a POST request to /v2/bookings/{booking_id}/cancel.

        Cancels an existing booking.

        Args:
            booking_id (string): The ID of the [Booking]($m/Booking) object
                representing the to-be-cancelled booking.
            body (CancelBookingRequest): 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/bookings/{booking_id}/cancelrL   TrE   r   r7   r8   r   Nr   )r   rI   r   r    r"   r#   r;   r<   r   r%   r&   r'   r(   r)   r*   r$   r   rP   r   r   r   cancel_booking  rR   zBookingsApi.cancel_bookingr   )NNNNNN)FNNN)__name__
__module____qualname____doc__r	   r5   r>   r@   rA   rC   rJ   rM   rQ   rS   __classcell__r   r   r   r   r   	   s,    
N00*
B016r   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
   