# This file was auto-generated by Fern from our API Definition.

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.bad_request_error import BadRequestError
from ..errors.internal_server_error import InternalServerError
from ..errors.service_unavailable_error import ServiceUnavailableError
from ..errors.unauthorized_error import UnauthorizedError
from ..types.additional_data import AdditionalData
from ..types.address_addtl_nullable import AddressAddtlNullable
from ..types.address_nullable import AddressNullable
from ..types.billing_data import BillingData
from ..types.contacts_field import ContactsField
from ..types.email import Email
from ..types.location_code import LocationCode
from ..types.mcc import Mcc
from ..types.payabli_api_response import PayabliApiResponse
from ..types.payabli_api_response_vendors import PayabliApiResponseVendors
from ..types.payee_name import PayeeName
from ..types.remit_email import RemitEmail
from ..types.remitaddress_1 import Remitaddress1
from ..types.remitaddress_2 import Remitaddress2
from ..types.remitcity import Remitcity
from ..types.remitcountry import Remitcountry
from ..types.remitstate import Remitstate
from ..types.remitzip import Remitzip
from ..types.vendor_ein import VendorEin
from ..types.vendor_name_1 import VendorName1
from ..types.vendor_name_2 import VendorName2
from ..types.vendor_number import VendorNumber
from ..types.vendor_payment_method_string import VendorPaymentMethodString
from ..types.vendor_phone import VendorPhone
from ..types.vendor_query_record import VendorQueryRecord
from ..types.vendorstatus import Vendorstatus

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class RawVendorClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def add_vendor(
        self,
        entry: str,
        *,
        vendor_number: typing.Optional[VendorNumber] = OMIT,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        address_1: typing.Optional[AddressNullable] = OMIT,
        address_2: typing.Optional[AddressAddtlNullable] = OMIT,
        billing_data: typing.Optional[BillingData] = OMIT,
        city: typing.Optional[str] = OMIT,
        contacts: typing.Optional[ContactsField] = OMIT,
        country: typing.Optional[str] = OMIT,
        custom_field_1: typing.Optional[str] = OMIT,
        custom_field_2: typing.Optional[str] = OMIT,
        customer_vendor_account: typing.Optional[str] = OMIT,
        ein: typing.Optional[VendorEin] = OMIT,
        email: typing.Optional[Email] = OMIT,
        internal_reference_id: typing.Optional[int] = OMIT,
        location_code: typing.Optional[LocationCode] = OMIT,
        mcc: typing.Optional[Mcc] = OMIT,
        name_1: typing.Optional[VendorName1] = OMIT,
        name_2: typing.Optional[VendorName2] = OMIT,
        payee_name_1: typing.Optional[PayeeName] = OMIT,
        payee_name_2: typing.Optional[PayeeName] = OMIT,
        payment_method: typing.Optional[VendorPaymentMethodString] = OMIT,
        phone: typing.Optional[VendorPhone] = OMIT,
        remit_address_1: typing.Optional[Remitaddress1] = OMIT,
        remit_address_2: typing.Optional[Remitaddress2] = OMIT,
        remit_city: typing.Optional[Remitcity] = OMIT,
        remit_country: typing.Optional[Remitcountry] = OMIT,
        remit_email: typing.Optional[RemitEmail] = OMIT,
        remit_state: typing.Optional[Remitstate] = OMIT,
        remit_zip: typing.Optional[Remitzip] = OMIT,
        state: typing.Optional[str] = OMIT,
        vendor_status: typing.Optional[Vendorstatus] = OMIT,
        zip: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PayabliApiResponseVendors]:
        """
        Creates a vendor in an entrypoint.

        Parameters
        ----------
        entry : str
            Entrypoint identifier.

        vendor_number : typing.Optional[VendorNumber]

        additional_data : typing.Optional[AdditionalData]

        address_1 : typing.Optional[AddressNullable]
            Vendor's address

        address_2 : typing.Optional[AddressAddtlNullable]
            Additional line for vendor's address.

        billing_data : typing.Optional[BillingData]
            Object containing vendor's bank information.

        city : typing.Optional[str]
            Vendor's city.

        contacts : typing.Optional[ContactsField]
            Array of objects describing the vendor's contacts.

        country : typing.Optional[str]
            Vendor's country.

        custom_field_1 : typing.Optional[str]
            Custom field 1 for vendor

        custom_field_2 : typing.Optional[str]
            Custom field 2 for vendor

        customer_vendor_account : typing.Optional[str]
            Account number of paypoint in the vendor side.

        ein : typing.Optional[VendorEin]

        email : typing.Optional[Email]
            Vendor's email address. Required for vCard.

        internal_reference_id : typing.Optional[int]
            Internal identifier for global vendor account.

        location_code : typing.Optional[LocationCode]

        mcc : typing.Optional[Mcc]

        name_1 : typing.Optional[VendorName1]

        name_2 : typing.Optional[VendorName2]

        payee_name_1 : typing.Optional[PayeeName]

        payee_name_2 : typing.Optional[PayeeName]

        payment_method : typing.Optional[VendorPaymentMethodString]

        phone : typing.Optional[VendorPhone]

        remit_address_1 : typing.Optional[Remitaddress1]

        remit_address_2 : typing.Optional[Remitaddress2]

        remit_city : typing.Optional[Remitcity]

        remit_country : typing.Optional[Remitcountry]

        remit_email : typing.Optional[RemitEmail]

        remit_state : typing.Optional[Remitstate]

        remit_zip : typing.Optional[Remitzip]

        state : typing.Optional[str]
            Vendor's state. Must be a 2 character state code.

        vendor_status : typing.Optional[Vendorstatus]

        zip : typing.Optional[str]
            Vendor's zip code.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[PayabliApiResponseVendors]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Vendor/single/{jsonable_encoder(entry)}",
            method="POST",
            json={
                "vendorNumber": vendor_number,
                "AdditionalData": additional_data,
                "address1": address_1,
                "address2": address_2,
                "billingData": convert_and_respect_annotation_metadata(
                    object_=billing_data, annotation=BillingData, direction="write"
                ),
                "city": city,
                "contacts": convert_and_respect_annotation_metadata(
                    object_=contacts, annotation=ContactsField, direction="write"
                ),
                "country": country,
                "customField1": custom_field_1,
                "customField2": custom_field_2,
                "customerVendorAccount": customer_vendor_account,
                "ein": ein,
                "email": email,
                "internalReferenceId": internal_reference_id,
                "locationCode": location_code,
                "mcc": mcc,
                "name1": name_1,
                "name2": name_2,
                "payeeName1": payee_name_1,
                "payeeName2": payee_name_2,
                "paymentMethod": payment_method,
                "phone": phone,
                "remitAddress1": remit_address_1,
                "remitAddress2": remit_address_2,
                "remitCity": remit_city,
                "remitCountry": remit_country,
                "remitEmail": remit_email,
                "remitState": remit_state,
                "remitZip": remit_zip,
                "state": state,
                "vendorStatus": vendor_status,
                "zip": zip,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponseVendors,
                    parse_obj_as(
                        type_=PayabliApiResponseVendors,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete_vendor(
        self, id_vendor: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[PayabliApiResponseVendors]:
        """
        Delete a vendor.

        Parameters
        ----------
        id_vendor : int
            Vendor ID.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[PayabliApiResponseVendors]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Vendor/{jsonable_encoder(id_vendor)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponseVendors,
                    parse_obj_as(
                        type_=PayabliApiResponseVendors,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def edit_vendor(
        self,
        id_vendor: int,
        *,
        vendor_number: typing.Optional[VendorNumber] = OMIT,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        address_1: typing.Optional[AddressNullable] = OMIT,
        address_2: typing.Optional[AddressAddtlNullable] = OMIT,
        billing_data: typing.Optional[BillingData] = OMIT,
        city: typing.Optional[str] = OMIT,
        contacts: typing.Optional[ContactsField] = OMIT,
        country: typing.Optional[str] = OMIT,
        custom_field_1: typing.Optional[str] = OMIT,
        custom_field_2: typing.Optional[str] = OMIT,
        customer_vendor_account: typing.Optional[str] = OMIT,
        ein: typing.Optional[VendorEin] = OMIT,
        email: typing.Optional[Email] = OMIT,
        internal_reference_id: typing.Optional[int] = OMIT,
        location_code: typing.Optional[LocationCode] = OMIT,
        mcc: typing.Optional[Mcc] = OMIT,
        name_1: typing.Optional[VendorName1] = OMIT,
        name_2: typing.Optional[VendorName2] = OMIT,
        payee_name_1: typing.Optional[PayeeName] = OMIT,
        payee_name_2: typing.Optional[PayeeName] = OMIT,
        payment_method: typing.Optional[VendorPaymentMethodString] = OMIT,
        phone: typing.Optional[VendorPhone] = OMIT,
        remit_address_1: typing.Optional[Remitaddress1] = OMIT,
        remit_address_2: typing.Optional[Remitaddress2] = OMIT,
        remit_city: typing.Optional[Remitcity] = OMIT,
        remit_country: typing.Optional[Remitcountry] = OMIT,
        remit_email: typing.Optional[RemitEmail] = OMIT,
        remit_state: typing.Optional[Remitstate] = OMIT,
        remit_zip: typing.Optional[Remitzip] = OMIT,
        state: typing.Optional[str] = OMIT,
        vendor_status: typing.Optional[Vendorstatus] = OMIT,
        zip: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PayabliApiResponseVendors]:
        """
        Updates a vendor's information. Send only the fields you need to update.

        Parameters
        ----------
        id_vendor : int
            Vendor ID.

        vendor_number : typing.Optional[VendorNumber]

        additional_data : typing.Optional[AdditionalData]

        address_1 : typing.Optional[AddressNullable]
            Vendor's address

        address_2 : typing.Optional[AddressAddtlNullable]
            Additional line for vendor's address.

        billing_data : typing.Optional[BillingData]
            Object containing vendor's bank information.

        city : typing.Optional[str]
            Vendor's city.

        contacts : typing.Optional[ContactsField]
            Array of objects describing the vendor's contacts.

        country : typing.Optional[str]
            Vendor's country.

        custom_field_1 : typing.Optional[str]
            Custom field 1 for vendor

        custom_field_2 : typing.Optional[str]
            Custom field 2 for vendor

        customer_vendor_account : typing.Optional[str]
            Account number of paypoint in the vendor side.

        ein : typing.Optional[VendorEin]

        email : typing.Optional[Email]
            Vendor's email address. Required for vCard.

        internal_reference_id : typing.Optional[int]
            Internal identifier for global vendor account.

        location_code : typing.Optional[LocationCode]

        mcc : typing.Optional[Mcc]

        name_1 : typing.Optional[VendorName1]

        name_2 : typing.Optional[VendorName2]

        payee_name_1 : typing.Optional[PayeeName]

        payee_name_2 : typing.Optional[PayeeName]

        payment_method : typing.Optional[VendorPaymentMethodString]

        phone : typing.Optional[VendorPhone]

        remit_address_1 : typing.Optional[Remitaddress1]

        remit_address_2 : typing.Optional[Remitaddress2]

        remit_city : typing.Optional[Remitcity]

        remit_country : typing.Optional[Remitcountry]

        remit_email : typing.Optional[RemitEmail]

        remit_state : typing.Optional[Remitstate]

        remit_zip : typing.Optional[Remitzip]

        state : typing.Optional[str]
            Vendor's state. Must be a 2 character state code.

        vendor_status : typing.Optional[Vendorstatus]

        zip : typing.Optional[str]
            Vendor's zip code.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[PayabliApiResponseVendors]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Vendor/{jsonable_encoder(id_vendor)}",
            method="PUT",
            json={
                "vendorNumber": vendor_number,
                "AdditionalData": additional_data,
                "address1": address_1,
                "address2": address_2,
                "billingData": convert_and_respect_annotation_metadata(
                    object_=billing_data, annotation=BillingData, direction="write"
                ),
                "city": city,
                "contacts": convert_and_respect_annotation_metadata(
                    object_=contacts, annotation=ContactsField, direction="write"
                ),
                "country": country,
                "customField1": custom_field_1,
                "customField2": custom_field_2,
                "customerVendorAccount": customer_vendor_account,
                "ein": ein,
                "email": email,
                "internalReferenceId": internal_reference_id,
                "locationCode": location_code,
                "mcc": mcc,
                "name1": name_1,
                "name2": name_2,
                "payeeName1": payee_name_1,
                "payeeName2": payee_name_2,
                "paymentMethod": payment_method,
                "phone": phone,
                "remitAddress1": remit_address_1,
                "remitAddress2": remit_address_2,
                "remitCity": remit_city,
                "remitCountry": remit_country,
                "remitEmail": remit_email,
                "remitState": remit_state,
                "remitZip": remit_zip,
                "state": state,
                "vendorStatus": vendor_status,
                "zip": zip,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponseVendors,
                    parse_obj_as(
                        type_=PayabliApiResponseVendors,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_vendor(
        self, id_vendor: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VendorQueryRecord]:
        """
        Retrieves a vendor's details.

        Parameters
        ----------
        id_vendor : int
            Vendor ID.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[VendorQueryRecord]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Vendor/{jsonable_encoder(id_vendor)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VendorQueryRecord,
                    parse_obj_as(
                        type_=VendorQueryRecord,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawVendorClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def add_vendor(
        self,
        entry: str,
        *,
        vendor_number: typing.Optional[VendorNumber] = OMIT,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        address_1: typing.Optional[AddressNullable] = OMIT,
        address_2: typing.Optional[AddressAddtlNullable] = OMIT,
        billing_data: typing.Optional[BillingData] = OMIT,
        city: typing.Optional[str] = OMIT,
        contacts: typing.Optional[ContactsField] = OMIT,
        country: typing.Optional[str] = OMIT,
        custom_field_1: typing.Optional[str] = OMIT,
        custom_field_2: typing.Optional[str] = OMIT,
        customer_vendor_account: typing.Optional[str] = OMIT,
        ein: typing.Optional[VendorEin] = OMIT,
        email: typing.Optional[Email] = OMIT,
        internal_reference_id: typing.Optional[int] = OMIT,
        location_code: typing.Optional[LocationCode] = OMIT,
        mcc: typing.Optional[Mcc] = OMIT,
        name_1: typing.Optional[VendorName1] = OMIT,
        name_2: typing.Optional[VendorName2] = OMIT,
        payee_name_1: typing.Optional[PayeeName] = OMIT,
        payee_name_2: typing.Optional[PayeeName] = OMIT,
        payment_method: typing.Optional[VendorPaymentMethodString] = OMIT,
        phone: typing.Optional[VendorPhone] = OMIT,
        remit_address_1: typing.Optional[Remitaddress1] = OMIT,
        remit_address_2: typing.Optional[Remitaddress2] = OMIT,
        remit_city: typing.Optional[Remitcity] = OMIT,
        remit_country: typing.Optional[Remitcountry] = OMIT,
        remit_email: typing.Optional[RemitEmail] = OMIT,
        remit_state: typing.Optional[Remitstate] = OMIT,
        remit_zip: typing.Optional[Remitzip] = OMIT,
        state: typing.Optional[str] = OMIT,
        vendor_status: typing.Optional[Vendorstatus] = OMIT,
        zip: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PayabliApiResponseVendors]:
        """
        Creates a vendor in an entrypoint.

        Parameters
        ----------
        entry : str
            Entrypoint identifier.

        vendor_number : typing.Optional[VendorNumber]

        additional_data : typing.Optional[AdditionalData]

        address_1 : typing.Optional[AddressNullable]
            Vendor's address

        address_2 : typing.Optional[AddressAddtlNullable]
            Additional line for vendor's address.

        billing_data : typing.Optional[BillingData]
            Object containing vendor's bank information.

        city : typing.Optional[str]
            Vendor's city.

        contacts : typing.Optional[ContactsField]
            Array of objects describing the vendor's contacts.

        country : typing.Optional[str]
            Vendor's country.

        custom_field_1 : typing.Optional[str]
            Custom field 1 for vendor

        custom_field_2 : typing.Optional[str]
            Custom field 2 for vendor

        customer_vendor_account : typing.Optional[str]
            Account number of paypoint in the vendor side.

        ein : typing.Optional[VendorEin]

        email : typing.Optional[Email]
            Vendor's email address. Required for vCard.

        internal_reference_id : typing.Optional[int]
            Internal identifier for global vendor account.

        location_code : typing.Optional[LocationCode]

        mcc : typing.Optional[Mcc]

        name_1 : typing.Optional[VendorName1]

        name_2 : typing.Optional[VendorName2]

        payee_name_1 : typing.Optional[PayeeName]

        payee_name_2 : typing.Optional[PayeeName]

        payment_method : typing.Optional[VendorPaymentMethodString]

        phone : typing.Optional[VendorPhone]

        remit_address_1 : typing.Optional[Remitaddress1]

        remit_address_2 : typing.Optional[Remitaddress2]

        remit_city : typing.Optional[Remitcity]

        remit_country : typing.Optional[Remitcountry]

        remit_email : typing.Optional[RemitEmail]

        remit_state : typing.Optional[Remitstate]

        remit_zip : typing.Optional[Remitzip]

        state : typing.Optional[str]
            Vendor's state. Must be a 2 character state code.

        vendor_status : typing.Optional[Vendorstatus]

        zip : typing.Optional[str]
            Vendor's zip code.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[PayabliApiResponseVendors]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Vendor/single/{jsonable_encoder(entry)}",
            method="POST",
            json={
                "vendorNumber": vendor_number,
                "AdditionalData": additional_data,
                "address1": address_1,
                "address2": address_2,
                "billingData": convert_and_respect_annotation_metadata(
                    object_=billing_data, annotation=BillingData, direction="write"
                ),
                "city": city,
                "contacts": convert_and_respect_annotation_metadata(
                    object_=contacts, annotation=ContactsField, direction="write"
                ),
                "country": country,
                "customField1": custom_field_1,
                "customField2": custom_field_2,
                "customerVendorAccount": customer_vendor_account,
                "ein": ein,
                "email": email,
                "internalReferenceId": internal_reference_id,
                "locationCode": location_code,
                "mcc": mcc,
                "name1": name_1,
                "name2": name_2,
                "payeeName1": payee_name_1,
                "payeeName2": payee_name_2,
                "paymentMethod": payment_method,
                "phone": phone,
                "remitAddress1": remit_address_1,
                "remitAddress2": remit_address_2,
                "remitCity": remit_city,
                "remitCountry": remit_country,
                "remitEmail": remit_email,
                "remitState": remit_state,
                "remitZip": remit_zip,
                "state": state,
                "vendorStatus": vendor_status,
                "zip": zip,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponseVendors,
                    parse_obj_as(
                        type_=PayabliApiResponseVendors,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete_vendor(
        self, id_vendor: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[PayabliApiResponseVendors]:
        """
        Delete a vendor.

        Parameters
        ----------
        id_vendor : int
            Vendor ID.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[PayabliApiResponseVendors]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Vendor/{jsonable_encoder(id_vendor)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponseVendors,
                    parse_obj_as(
                        type_=PayabliApiResponseVendors,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def edit_vendor(
        self,
        id_vendor: int,
        *,
        vendor_number: typing.Optional[VendorNumber] = OMIT,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        address_1: typing.Optional[AddressNullable] = OMIT,
        address_2: typing.Optional[AddressAddtlNullable] = OMIT,
        billing_data: typing.Optional[BillingData] = OMIT,
        city: typing.Optional[str] = OMIT,
        contacts: typing.Optional[ContactsField] = OMIT,
        country: typing.Optional[str] = OMIT,
        custom_field_1: typing.Optional[str] = OMIT,
        custom_field_2: typing.Optional[str] = OMIT,
        customer_vendor_account: typing.Optional[str] = OMIT,
        ein: typing.Optional[VendorEin] = OMIT,
        email: typing.Optional[Email] = OMIT,
        internal_reference_id: typing.Optional[int] = OMIT,
        location_code: typing.Optional[LocationCode] = OMIT,
        mcc: typing.Optional[Mcc] = OMIT,
        name_1: typing.Optional[VendorName1] = OMIT,
        name_2: typing.Optional[VendorName2] = OMIT,
        payee_name_1: typing.Optional[PayeeName] = OMIT,
        payee_name_2: typing.Optional[PayeeName] = OMIT,
        payment_method: typing.Optional[VendorPaymentMethodString] = OMIT,
        phone: typing.Optional[VendorPhone] = OMIT,
        remit_address_1: typing.Optional[Remitaddress1] = OMIT,
        remit_address_2: typing.Optional[Remitaddress2] = OMIT,
        remit_city: typing.Optional[Remitcity] = OMIT,
        remit_country: typing.Optional[Remitcountry] = OMIT,
        remit_email: typing.Optional[RemitEmail] = OMIT,
        remit_state: typing.Optional[Remitstate] = OMIT,
        remit_zip: typing.Optional[Remitzip] = OMIT,
        state: typing.Optional[str] = OMIT,
        vendor_status: typing.Optional[Vendorstatus] = OMIT,
        zip: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PayabliApiResponseVendors]:
        """
        Updates a vendor's information. Send only the fields you need to update.

        Parameters
        ----------
        id_vendor : int
            Vendor ID.

        vendor_number : typing.Optional[VendorNumber]

        additional_data : typing.Optional[AdditionalData]

        address_1 : typing.Optional[AddressNullable]
            Vendor's address

        address_2 : typing.Optional[AddressAddtlNullable]
            Additional line for vendor's address.

        billing_data : typing.Optional[BillingData]
            Object containing vendor's bank information.

        city : typing.Optional[str]
            Vendor's city.

        contacts : typing.Optional[ContactsField]
            Array of objects describing the vendor's contacts.

        country : typing.Optional[str]
            Vendor's country.

        custom_field_1 : typing.Optional[str]
            Custom field 1 for vendor

        custom_field_2 : typing.Optional[str]
            Custom field 2 for vendor

        customer_vendor_account : typing.Optional[str]
            Account number of paypoint in the vendor side.

        ein : typing.Optional[VendorEin]

        email : typing.Optional[Email]
            Vendor's email address. Required for vCard.

        internal_reference_id : typing.Optional[int]
            Internal identifier for global vendor account.

        location_code : typing.Optional[LocationCode]

        mcc : typing.Optional[Mcc]

        name_1 : typing.Optional[VendorName1]

        name_2 : typing.Optional[VendorName2]

        payee_name_1 : typing.Optional[PayeeName]

        payee_name_2 : typing.Optional[PayeeName]

        payment_method : typing.Optional[VendorPaymentMethodString]

        phone : typing.Optional[VendorPhone]

        remit_address_1 : typing.Optional[Remitaddress1]

        remit_address_2 : typing.Optional[Remitaddress2]

        remit_city : typing.Optional[Remitcity]

        remit_country : typing.Optional[Remitcountry]

        remit_email : typing.Optional[RemitEmail]

        remit_state : typing.Optional[Remitstate]

        remit_zip : typing.Optional[Remitzip]

        state : typing.Optional[str]
            Vendor's state. Must be a 2 character state code.

        vendor_status : typing.Optional[Vendorstatus]

        zip : typing.Optional[str]
            Vendor's zip code.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[PayabliApiResponseVendors]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Vendor/{jsonable_encoder(id_vendor)}",
            method="PUT",
            json={
                "vendorNumber": vendor_number,
                "AdditionalData": additional_data,
                "address1": address_1,
                "address2": address_2,
                "billingData": convert_and_respect_annotation_metadata(
                    object_=billing_data, annotation=BillingData, direction="write"
                ),
                "city": city,
                "contacts": convert_and_respect_annotation_metadata(
                    object_=contacts, annotation=ContactsField, direction="write"
                ),
                "country": country,
                "customField1": custom_field_1,
                "customField2": custom_field_2,
                "customerVendorAccount": customer_vendor_account,
                "ein": ein,
                "email": email,
                "internalReferenceId": internal_reference_id,
                "locationCode": location_code,
                "mcc": mcc,
                "name1": name_1,
                "name2": name_2,
                "payeeName1": payee_name_1,
                "payeeName2": payee_name_2,
                "paymentMethod": payment_method,
                "phone": phone,
                "remitAddress1": remit_address_1,
                "remitAddress2": remit_address_2,
                "remitCity": remit_city,
                "remitCountry": remit_country,
                "remitEmail": remit_email,
                "remitState": remit_state,
                "remitZip": remit_zip,
                "state": state,
                "vendorStatus": vendor_status,
                "zip": zip,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponseVendors,
                    parse_obj_as(
                        type_=PayabliApiResponseVendors,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_vendor(
        self, id_vendor: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VendorQueryRecord]:
        """
        Retrieves a vendor's details.

        Parameters
        ----------
        id_vendor : int
            Vendor ID.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[VendorQueryRecord]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Vendor/{jsonable_encoder(id_vendor)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VendorQueryRecord,
                    parse_obj_as(
                        type_=VendorQueryRecord,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
