# 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.accounting_field import AccountingField
from ..types.additional_data_string import AdditionalDataString
from ..types.attachments import Attachments
from ..types.bill_query_response import BillQueryResponse
from ..types.billitems import Billitems
from ..types.billstatus import Billstatus
from ..types.comments import Comments
from ..types.datenullable import Datenullable
from ..types.export_format import ExportFormat
from ..types.file_content import FileContent
from ..types.frequency import Frequency
from ..types.idempotency_key import IdempotencyKey
from ..types.payabli_api_response import PayabliApiResponse
from ..types.terms import Terms
from ..types.vendor_data import VendorData
from .types.bill_out_data_scheduled_options import BillOutDataScheduledOptions
from .types.bill_response import BillResponse
from .types.edit_bill_response import EditBillResponse
from .types.get_bill_response import GetBillResponse
from .types.modify_approval_bill_response import ModifyApprovalBillResponse
from .types.set_approved_bill_response import SetApprovedBillResponse

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


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

    def add_bill(
        self,
        entry: str,
        *,
        idempotency_key: typing.Optional[IdempotencyKey] = None,
        accounting_field_1: typing.Optional[AccountingField] = OMIT,
        accounting_field_2: typing.Optional[AccountingField] = OMIT,
        additional_data: typing.Optional[AdditionalDataString] = OMIT,
        attachments: typing.Optional[Attachments] = OMIT,
        bill_date: typing.Optional[Datenullable] = OMIT,
        bill_items: typing.Optional[Billitems] = OMIT,
        bill_number: typing.Optional[str] = OMIT,
        comments: typing.Optional[Comments] = OMIT,
        discount: typing.Optional[float] = OMIT,
        due_date: typing.Optional[Datenullable] = OMIT,
        end_date: typing.Optional[Datenullable] = OMIT,
        frequency: typing.Optional[Frequency] = OMIT,
        lot_number: typing.Optional[str] = OMIT,
        mode: typing.Optional[int] = OMIT,
        net_amount: typing.Optional[float] = OMIT,
        scheduled_options: typing.Optional[BillOutDataScheduledOptions] = OMIT,
        status: typing.Optional[Billstatus] = OMIT,
        terms: typing.Optional[Terms] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        vendor: typing.Optional[VendorData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[BillResponse]:
        """
        Creates a bill in an entrypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        idempotency_key : typing.Optional[IdempotencyKey]

        accounting_field_1 : typing.Optional[AccountingField]

        accounting_field_2 : typing.Optional[AccountingField]

        additional_data : typing.Optional[AdditionalDataString]

        attachments : typing.Optional[Attachments]
            An array of bill images. Attachments aren't required, but we strongly recommend including them. Including a bill image can make payouts smoother and prevent delays. You can include either the Base64-encoded file content, or you can include an fURL to a public file. The maximum file size for image uploads is 30 MB.

        bill_date : typing.Optional[Datenullable]
            Date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        bill_items : typing.Optional[Billitems]

        bill_number : typing.Optional[str]
            Unique identifier for the bill. Required when adding a bill.

        comments : typing.Optional[Comments]

        discount : typing.Optional[float]
            Discount amount applied to the bill.

        due_date : typing.Optional[Datenullable]
            Due date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        end_date : typing.Optional[Datenullable]
            End Date for scheduled bills. Applied only in `Mode` = 1. Accepted formats: YYYY-MM-DD, MM/DD/YYYY

        frequency : typing.Optional[Frequency]
            Frequency for scheduled bills. Applied only in `Mode` = 1.

        lot_number : typing.Optional[str]
            Lot number associated with the bill.

        mode : typing.Optional[int]
            Bill mode: value `0` for one-time bills, `1` for scheduled bills.

        net_amount : typing.Optional[float]
            Net Amount owed in bill. Required when adding a bill.

        scheduled_options : typing.Optional[BillOutDataScheduledOptions]
            Options for scheduled bills.

        status : typing.Optional[Billstatus]

        terms : typing.Optional[Terms]

        total_amount : typing.Optional[float]
            Total amount of the bill.

        vendor : typing.Optional[VendorData]
            The vendor associated with the bill. Although you can create a vendor in a create bill request, Payabli recommends creating a vendor separately and passing a valid `vendorNumber` here. At minimum, the `vendorNumber` is required.

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

        Returns
        -------
        HttpResponse[BillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/single/{jsonable_encoder(entry)}",
            method="POST",
            json={
                "accountingField1": accounting_field_1,
                "accountingField2": accounting_field_2,
                "additionalData": additional_data,
                "attachments": convert_and_respect_annotation_metadata(
                    object_=attachments, annotation=Attachments, direction="write"
                ),
                "billDate": bill_date,
                "billItems": convert_and_respect_annotation_metadata(
                    object_=bill_items, annotation=Billitems, direction="write"
                ),
                "billNumber": bill_number,
                "comments": comments,
                "discount": discount,
                "dueDate": due_date,
                "endDate": end_date,
                "frequency": frequency,
                "lotNumber": lot_number,
                "mode": mode,
                "netAmount": net_amount,
                "scheduledOptions": convert_and_respect_annotation_metadata(
                    object_=scheduled_options, annotation=BillOutDataScheduledOptions, direction="write"
                ),
                "status": status,
                "terms": terms,
                "totalAmount": total_amount,
                "vendor": convert_and_respect_annotation_metadata(
                    object_=vendor, annotation=VendorData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
                "idempotencyKey": str(idempotency_key) if idempotency_key is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[BillResponse]:
        """
        Delete a file attached to a bill.

        Parameters
        ----------
        filename : str
            The filename in Payabli. Filename is `zipName` in response to a
            request to `/api/Invoice/{idInvoice}`. Here, the filename is
            `0_Bill.pdf`.

            ```json
              "DocumentsRef": {
                "zipfile": "inva_269.zip",
                "filelist": [
                  {
                    "originalName": "Bill.pdf",
                    "zipName": "0_Bill.pdf",
                    "descriptor": null
                  }
                ]
              }
              ```

        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        return_object : typing.Optional[bool]
            When `true`, the request returns the file content as a Base64-encoded string.

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

        Returns
        -------
        HttpResponse[BillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/attachedFileFromBill/{jsonable_encoder(id_bill)}/{jsonable_encoder(filename)}",
            method="DELETE",
            params={
                "returnObject": return_object,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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_bill(
        self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[BillResponse]:
        """
        Deletes a bill by ID.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

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

        Returns
        -------
        HttpResponse[BillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/{jsonable_encoder(id_bill)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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_bill(
        self,
        id_bill: int,
        *,
        accounting_field_1: typing.Optional[AccountingField] = OMIT,
        accounting_field_2: typing.Optional[AccountingField] = OMIT,
        additional_data: typing.Optional[AdditionalDataString] = OMIT,
        attachments: typing.Optional[Attachments] = OMIT,
        bill_date: typing.Optional[Datenullable] = OMIT,
        bill_items: typing.Optional[Billitems] = OMIT,
        bill_number: typing.Optional[str] = OMIT,
        comments: typing.Optional[Comments] = OMIT,
        discount: typing.Optional[float] = OMIT,
        due_date: typing.Optional[Datenullable] = OMIT,
        end_date: typing.Optional[Datenullable] = OMIT,
        frequency: typing.Optional[Frequency] = OMIT,
        lot_number: typing.Optional[str] = OMIT,
        mode: typing.Optional[int] = OMIT,
        net_amount: typing.Optional[float] = OMIT,
        scheduled_options: typing.Optional[BillOutDataScheduledOptions] = OMIT,
        status: typing.Optional[Billstatus] = OMIT,
        terms: typing.Optional[Terms] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        vendor: typing.Optional[VendorData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[EditBillResponse]:
        """
        Updates a bill by ID.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        accounting_field_1 : typing.Optional[AccountingField]

        accounting_field_2 : typing.Optional[AccountingField]

        additional_data : typing.Optional[AdditionalDataString]

        attachments : typing.Optional[Attachments]
            An array of bill images. Attachments aren't required, but we strongly recommend including them. Including a bill image can make payouts smoother and prevent delays. You can include either the Base64-encoded file content, or you can include an fURL to a public file. The maximum file size for image uploads is 30 MB.

        bill_date : typing.Optional[Datenullable]
            Date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        bill_items : typing.Optional[Billitems]

        bill_number : typing.Optional[str]
            Unique identifier for the bill. Required when adding a bill.

        comments : typing.Optional[Comments]

        discount : typing.Optional[float]
            Discount amount applied to the bill.

        due_date : typing.Optional[Datenullable]
            Due date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        end_date : typing.Optional[Datenullable]
            End Date for scheduled bills. Applied only in `Mode` = 1. Accepted formats: YYYY-MM-DD, MM/DD/YYYY

        frequency : typing.Optional[Frequency]
            Frequency for scheduled bills. Applied only in `Mode` = 1.

        lot_number : typing.Optional[str]
            Lot number associated with the bill.

        mode : typing.Optional[int]
            Bill mode: value `0` for one-time bills, `1` for scheduled bills.

        net_amount : typing.Optional[float]
            Net Amount owed in bill. Required when adding a bill.

        scheduled_options : typing.Optional[BillOutDataScheduledOptions]
            Options for scheduled bills.

        status : typing.Optional[Billstatus]

        terms : typing.Optional[Terms]

        total_amount : typing.Optional[float]
            Total amount of the bill.

        vendor : typing.Optional[VendorData]
            The vendor associated with the bill. Although you can create a vendor in a create bill request, Payabli recommends creating a vendor separately and passing a valid `vendorNumber` here. At minimum, the `vendorNumber` is required.

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

        Returns
        -------
        HttpResponse[EditBillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/{jsonable_encoder(id_bill)}",
            method="PUT",
            json={
                "accountingField1": accounting_field_1,
                "accountingField2": accounting_field_2,
                "additionalData": additional_data,
                "attachments": convert_and_respect_annotation_metadata(
                    object_=attachments, annotation=Attachments, direction="write"
                ),
                "billDate": bill_date,
                "billItems": convert_and_respect_annotation_metadata(
                    object_=bill_items, annotation=Billitems, direction="write"
                ),
                "billNumber": bill_number,
                "comments": comments,
                "discount": discount,
                "dueDate": due_date,
                "endDate": end_date,
                "frequency": frequency,
                "lotNumber": lot_number,
                "mode": mode,
                "netAmount": net_amount,
                "scheduledOptions": convert_and_respect_annotation_metadata(
                    object_=scheduled_options, annotation=BillOutDataScheduledOptions, direction="write"
                ),
                "status": status,
                "terms": terms,
                "totalAmount": total_amount,
                "vendor": convert_and_respect_annotation_metadata(
                    object_=vendor, annotation=VendorData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    EditBillResponse,
                    parse_obj_as(
                        type_=EditBillResponse,  # 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_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[FileContent]:
        """
        Retrieves a file attached to a bill, either as a binary file or as a Base64-encoded string.

        Parameters
        ----------
        filename : str
            The filename in Payabli. Filename is `zipName` in response to a request to `/api/Invoice/{idInvoice}`. Here, the filename is `0_Bill.pdf``.
            "DocumentsRef": {
              "zipfile": "inva_269.zip",
              "filelist": [
                {
                  "originalName": "Bill.pdf",
                  "zipName": "0_Bill.pdf",
                  "descriptor": null
                }
              ]
            }

        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        return_object : typing.Optional[bool]
            When `true`, the request returns the file content as a Base64-encoded string.

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

        Returns
        -------
        HttpResponse[FileContent]
            A successful response returns a binary file when `returnObject` is `false`. When `returnObject` is `true`, the response contains the file content as a Base64-encoded string in an object. Due to technical limitations, only the object response is documented here.
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/attachedFileFromBill/{jsonable_encoder(id_bill)}/{jsonable_encoder(filename)}",
            method="GET",
            params={
                "returnObject": return_object,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileContent,
                    parse_obj_as(
                        type_=FileContent,  # 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_bill(
        self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[GetBillResponse]:
        """
        Retrieves a bill by ID from an entrypoint.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

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

        Returns
        -------
        HttpResponse[GetBillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/{jsonable_encoder(id_bill)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetBillResponse,
                    parse_obj_as(
                        type_=GetBillResponse,  # 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 list_bills(
        self,
        entry: str,
        *,
        export_format: typing.Optional[ExportFormat] = None,
        from_record: typing.Optional[int] = None,
        limit_record: typing.Optional[int] = None,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        sort_by: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[BillQueryResponse]:
        """
        Retrieve a list of bills for an entrypoint. Use filters to limit results. Include the `exportFormat` query parameter to return the results as a file instead of a JSON response.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        export_format : typing.Optional[ExportFormat]

        from_record : typing.Optional[int]
            The number of records to skip before starting to collect the result set.

        limit_record : typing.Optional[int]
            Max number of records to return for the query. Use `0` or negative value to return all records.

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Collection of field names, conditions, and values used to filter the query
            <Info>
              **You must remove `parameters=` from the request before you send it, otherwise Payabli will ignore the filters.**

              Because of a technical limitation, you can't make a request that includes filters from the API console on this page. The response isn't filtered. Instead, copy the request, remove `parameters=` and run the request in a different client.

              For example:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?parameters=totalAmount(gt)=1000&limitRecord=20

              should become:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?totalAmount(gt)=1000&limitRecord=20
            </Info>
            See [Filters and Conditions Reference](/developers/developer-guides/pay-ops-reporting-engine-overview#filters-and-conditions-reference) for help.

            List of field names accepted:
            - `frequency` (`in`, `nin`, `ne`, `eq`)
            - `method` (`in`, `nin`, `eq`, `ne`)
            - `event` (`in`, `nin`, `eq`, `ne`)
            - `target` (`ct`, `nct`, `eq`, `ne`)
            - `status` (`eq`, `ne`)
            - `approvalUserId` (`eq`, `ne`)
            - `parentOrgId` (`ne`, `eq`, `nin`, `in`)
            - `approvalUserEmail` (`eq`, `ne`)
            - `scheduleId` (`ne`, `eq`)

            List of comparison accepted - enclosed between parentheses:
            - `eq` or empty => equal
            - `gt` => greater than
            - `ge` => greater or equal
            - `lt` => less than
            - `le` => less or equal
            - `ne` => not equal
            - `ct` => contains
            - `nct` => not contains
            - `in` => inside array
            - `nin` => not inside array

            List of parameters accepted:
            - `limitRecord` : max number of records for query (default="20", "0" or negative value for all)
            - `fromRecord` : initial record in query
            Example: `totalAmount(gt)=20` returns all records with a `totalAmount` that's greater than 20.00

        sort_by : typing.Optional[str]
            The field name to use for sorting results. Use `desc(field_name)` to sort descending by `field_name`, and use `asc(field_name)` to sort ascending by `field_name`.

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

        Returns
        -------
        HttpResponse[BillQueryResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Query/bills/{jsonable_encoder(entry)}",
            method="GET",
            params={
                "exportFormat": export_format,
                "fromRecord": from_record,
                "limitRecord": limit_record,
                "parameters": parameters,
                "sortBy": sort_by,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillQueryResponse,
                    parse_obj_as(
                        type_=BillQueryResponse,  # 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 list_bills_org(
        self,
        org_id: int,
        *,
        export_format: typing.Optional[ExportFormat] = None,
        from_record: typing.Optional[int] = None,
        limit_record: typing.Optional[int] = None,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        sort_by: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[BillQueryResponse]:
        """
        Retrieve a list of bills for an organization. Use filters to limit results. Include the `exportFormat` query parameter to return the results as a file instead of a JSON response.

        Parameters
        ----------
        org_id : int
            The numeric identifier for organization, assigned by Payabli.

        export_format : typing.Optional[ExportFormat]

        from_record : typing.Optional[int]
            The number of records to skip before starting to collect the result set.

        limit_record : typing.Optional[int]
            Max number of records to return for the query. Use `0` or negative value to return all records.

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Collection of field names, conditions, and values used to filter the query
            <Info>
              **You must remove `parameters=` from the request before you send it, otherwise Payabli will ignore the filters.**

              Because of a technical limitation, you can't make a request that includes filters from the API console on this page. The response isn't filtered. Instead, copy the request, remove `parameters=` and run the request in a different client.

              For example:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?parameters=totalAmount(gt)=1000&limitRecord=20

              should become:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?totalAmount(gt)=1000&limitRecord=20
            </Info>
            See [Filters and Conditions Reference](/developers/developer-guides/pay-ops-reporting-engine-overview#filters-and-conditions-reference) for help.

            List of field names accepted:
            - `frequency` (in, nin, ne, eq)
            - `method` (in, nin, eq, ne)
            - `event` (in, nin, eq, ne)
            - `target` (ct, nct, eq, ne)
            - `status` (eq, ne)
            - `parentOrgId` (ne, eq, nin, in)
            - `approvalUserId` (eq, ne)
            - `approvalUserEmail` (eq, ne)

            List of comparison accepted - enclosed between parentheses:
            - eq or empty => equal
            - gt => greater than
            - ge => greater or equal
            - lt => less than
            - le => less or equal
            - ne => not equal
            - ct => contains
            - nct => not contains
            - in => inside array
            - nin => not inside array

            List of parameters accepted:
            - limitRecord : max number of records for query (default="20", "0" or negative value for all)
            - fromRecord : initial record in query

            Example: totalAmount(gt)=20 return all records with totalAmount greater than 20.00

        sort_by : typing.Optional[str]
            The field name to use for sorting results. Use `desc(field_name)` to sort descending by `field_name`, and use `asc(field_name)` to sort ascending by `field_name`.

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

        Returns
        -------
        HttpResponse[BillQueryResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Query/bills/org/{jsonable_encoder(org_id)}",
            method="GET",
            params={
                "exportFormat": export_format,
                "fromRecord": from_record,
                "limitRecord": limit_record,
                "parameters": parameters,
                "sortBy": sort_by,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillQueryResponse,
                    parse_obj_as(
                        type_=BillQueryResponse,  # 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 modify_approval_bill(
        self, id_bill: int, *, request: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[ModifyApprovalBillResponse]:
        """
        Modify the list of users the bill is sent to for approval.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        request : typing.Sequence[str]

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

        Returns
        -------
        HttpResponse[ModifyApprovalBillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/approval/{jsonable_encoder(id_bill)}",
            method="PUT",
            json=request,
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ModifyApprovalBillResponse,
                    parse_obj_as(
                        type_=ModifyApprovalBillResponse,  # 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 send_to_approval_bill(
        self,
        id_bill: int,
        *,
        request: typing.Sequence[str],
        autocreate_user: typing.Optional[bool] = None,
        idempotency_key: typing.Optional[IdempotencyKey] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[BillResponse]:
        """
        Send a bill to a user or list of users to approve.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        request : typing.Sequence[str]

        autocreate_user : typing.Optional[bool]
            Automatically create the target user for approval if they don't exist.

        idempotency_key : typing.Optional[IdempotencyKey]

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

        Returns
        -------
        HttpResponse[BillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/approval/{jsonable_encoder(id_bill)}",
            method="POST",
            params={
                "autocreateUser": autocreate_user,
            },
            json=request,
            headers={
                "content-type": "application/json",
                "idempotencyKey": str(idempotency_key) if idempotency_key is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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 set_approved_bill(
        self,
        approved: str,
        id_bill: int,
        *,
        email: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[SetApprovedBillResponse]:
        """
        Approve or disapprove a bill by ID.

        Parameters
        ----------
        approved : str
            String representing the approved status. Accepted values: 'true' or 'false'.

        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        email : typing.Optional[str]
            Email or username of user modifying approval status.

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

        Returns
        -------
        HttpResponse[SetApprovedBillResponse]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Bill/approval/{jsonable_encoder(id_bill)}/{jsonable_encoder(approved)}",
            method="GET",
            params={
                "email": email,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    SetApprovedBillResponse,
                    parse_obj_as(
                        type_=SetApprovedBillResponse,  # 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 AsyncRawBillClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def add_bill(
        self,
        entry: str,
        *,
        idempotency_key: typing.Optional[IdempotencyKey] = None,
        accounting_field_1: typing.Optional[AccountingField] = OMIT,
        accounting_field_2: typing.Optional[AccountingField] = OMIT,
        additional_data: typing.Optional[AdditionalDataString] = OMIT,
        attachments: typing.Optional[Attachments] = OMIT,
        bill_date: typing.Optional[Datenullable] = OMIT,
        bill_items: typing.Optional[Billitems] = OMIT,
        bill_number: typing.Optional[str] = OMIT,
        comments: typing.Optional[Comments] = OMIT,
        discount: typing.Optional[float] = OMIT,
        due_date: typing.Optional[Datenullable] = OMIT,
        end_date: typing.Optional[Datenullable] = OMIT,
        frequency: typing.Optional[Frequency] = OMIT,
        lot_number: typing.Optional[str] = OMIT,
        mode: typing.Optional[int] = OMIT,
        net_amount: typing.Optional[float] = OMIT,
        scheduled_options: typing.Optional[BillOutDataScheduledOptions] = OMIT,
        status: typing.Optional[Billstatus] = OMIT,
        terms: typing.Optional[Terms] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        vendor: typing.Optional[VendorData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[BillResponse]:
        """
        Creates a bill in an entrypoint.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        idempotency_key : typing.Optional[IdempotencyKey]

        accounting_field_1 : typing.Optional[AccountingField]

        accounting_field_2 : typing.Optional[AccountingField]

        additional_data : typing.Optional[AdditionalDataString]

        attachments : typing.Optional[Attachments]
            An array of bill images. Attachments aren't required, but we strongly recommend including them. Including a bill image can make payouts smoother and prevent delays. You can include either the Base64-encoded file content, or you can include an fURL to a public file. The maximum file size for image uploads is 30 MB.

        bill_date : typing.Optional[Datenullable]
            Date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        bill_items : typing.Optional[Billitems]

        bill_number : typing.Optional[str]
            Unique identifier for the bill. Required when adding a bill.

        comments : typing.Optional[Comments]

        discount : typing.Optional[float]
            Discount amount applied to the bill.

        due_date : typing.Optional[Datenullable]
            Due date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        end_date : typing.Optional[Datenullable]
            End Date for scheduled bills. Applied only in `Mode` = 1. Accepted formats: YYYY-MM-DD, MM/DD/YYYY

        frequency : typing.Optional[Frequency]
            Frequency for scheduled bills. Applied only in `Mode` = 1.

        lot_number : typing.Optional[str]
            Lot number associated with the bill.

        mode : typing.Optional[int]
            Bill mode: value `0` for one-time bills, `1` for scheduled bills.

        net_amount : typing.Optional[float]
            Net Amount owed in bill. Required when adding a bill.

        scheduled_options : typing.Optional[BillOutDataScheduledOptions]
            Options for scheduled bills.

        status : typing.Optional[Billstatus]

        terms : typing.Optional[Terms]

        total_amount : typing.Optional[float]
            Total amount of the bill.

        vendor : typing.Optional[VendorData]
            The vendor associated with the bill. Although you can create a vendor in a create bill request, Payabli recommends creating a vendor separately and passing a valid `vendorNumber` here. At minimum, the `vendorNumber` is required.

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

        Returns
        -------
        AsyncHttpResponse[BillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/single/{jsonable_encoder(entry)}",
            method="POST",
            json={
                "accountingField1": accounting_field_1,
                "accountingField2": accounting_field_2,
                "additionalData": additional_data,
                "attachments": convert_and_respect_annotation_metadata(
                    object_=attachments, annotation=Attachments, direction="write"
                ),
                "billDate": bill_date,
                "billItems": convert_and_respect_annotation_metadata(
                    object_=bill_items, annotation=Billitems, direction="write"
                ),
                "billNumber": bill_number,
                "comments": comments,
                "discount": discount,
                "dueDate": due_date,
                "endDate": end_date,
                "frequency": frequency,
                "lotNumber": lot_number,
                "mode": mode,
                "netAmount": net_amount,
                "scheduledOptions": convert_and_respect_annotation_metadata(
                    object_=scheduled_options, annotation=BillOutDataScheduledOptions, direction="write"
                ),
                "status": status,
                "terms": terms,
                "totalAmount": total_amount,
                "vendor": convert_and_respect_annotation_metadata(
                    object_=vendor, annotation=VendorData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
                "idempotencyKey": str(idempotency_key) if idempotency_key is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[BillResponse]:
        """
        Delete a file attached to a bill.

        Parameters
        ----------
        filename : str
            The filename in Payabli. Filename is `zipName` in response to a
            request to `/api/Invoice/{idInvoice}`. Here, the filename is
            `0_Bill.pdf`.

            ```json
              "DocumentsRef": {
                "zipfile": "inva_269.zip",
                "filelist": [
                  {
                    "originalName": "Bill.pdf",
                    "zipName": "0_Bill.pdf",
                    "descriptor": null
                  }
                ]
              }
              ```

        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        return_object : typing.Optional[bool]
            When `true`, the request returns the file content as a Base64-encoded string.

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

        Returns
        -------
        AsyncHttpResponse[BillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/attachedFileFromBill/{jsonable_encoder(id_bill)}/{jsonable_encoder(filename)}",
            method="DELETE",
            params={
                "returnObject": return_object,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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_bill(
        self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[BillResponse]:
        """
        Deletes a bill by ID.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

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

        Returns
        -------
        AsyncHttpResponse[BillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/{jsonable_encoder(id_bill)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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_bill(
        self,
        id_bill: int,
        *,
        accounting_field_1: typing.Optional[AccountingField] = OMIT,
        accounting_field_2: typing.Optional[AccountingField] = OMIT,
        additional_data: typing.Optional[AdditionalDataString] = OMIT,
        attachments: typing.Optional[Attachments] = OMIT,
        bill_date: typing.Optional[Datenullable] = OMIT,
        bill_items: typing.Optional[Billitems] = OMIT,
        bill_number: typing.Optional[str] = OMIT,
        comments: typing.Optional[Comments] = OMIT,
        discount: typing.Optional[float] = OMIT,
        due_date: typing.Optional[Datenullable] = OMIT,
        end_date: typing.Optional[Datenullable] = OMIT,
        frequency: typing.Optional[Frequency] = OMIT,
        lot_number: typing.Optional[str] = OMIT,
        mode: typing.Optional[int] = OMIT,
        net_amount: typing.Optional[float] = OMIT,
        scheduled_options: typing.Optional[BillOutDataScheduledOptions] = OMIT,
        status: typing.Optional[Billstatus] = OMIT,
        terms: typing.Optional[Terms] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        vendor: typing.Optional[VendorData] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[EditBillResponse]:
        """
        Updates a bill by ID.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        accounting_field_1 : typing.Optional[AccountingField]

        accounting_field_2 : typing.Optional[AccountingField]

        additional_data : typing.Optional[AdditionalDataString]

        attachments : typing.Optional[Attachments]
            An array of bill images. Attachments aren't required, but we strongly recommend including them. Including a bill image can make payouts smoother and prevent delays. You can include either the Base64-encoded file content, or you can include an fURL to a public file. The maximum file size for image uploads is 30 MB.

        bill_date : typing.Optional[Datenullable]
            Date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        bill_items : typing.Optional[Billitems]

        bill_number : typing.Optional[str]
            Unique identifier for the bill. Required when adding a bill.

        comments : typing.Optional[Comments]

        discount : typing.Optional[float]
            Discount amount applied to the bill.

        due_date : typing.Optional[Datenullable]
            Due date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY.

        end_date : typing.Optional[Datenullable]
            End Date for scheduled bills. Applied only in `Mode` = 1. Accepted formats: YYYY-MM-DD, MM/DD/YYYY

        frequency : typing.Optional[Frequency]
            Frequency for scheduled bills. Applied only in `Mode` = 1.

        lot_number : typing.Optional[str]
            Lot number associated with the bill.

        mode : typing.Optional[int]
            Bill mode: value `0` for one-time bills, `1` for scheduled bills.

        net_amount : typing.Optional[float]
            Net Amount owed in bill. Required when adding a bill.

        scheduled_options : typing.Optional[BillOutDataScheduledOptions]
            Options for scheduled bills.

        status : typing.Optional[Billstatus]

        terms : typing.Optional[Terms]

        total_amount : typing.Optional[float]
            Total amount of the bill.

        vendor : typing.Optional[VendorData]
            The vendor associated with the bill. Although you can create a vendor in a create bill request, Payabli recommends creating a vendor separately and passing a valid `vendorNumber` here. At minimum, the `vendorNumber` is required.

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

        Returns
        -------
        AsyncHttpResponse[EditBillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/{jsonable_encoder(id_bill)}",
            method="PUT",
            json={
                "accountingField1": accounting_field_1,
                "accountingField2": accounting_field_2,
                "additionalData": additional_data,
                "attachments": convert_and_respect_annotation_metadata(
                    object_=attachments, annotation=Attachments, direction="write"
                ),
                "billDate": bill_date,
                "billItems": convert_and_respect_annotation_metadata(
                    object_=bill_items, annotation=Billitems, direction="write"
                ),
                "billNumber": bill_number,
                "comments": comments,
                "discount": discount,
                "dueDate": due_date,
                "endDate": end_date,
                "frequency": frequency,
                "lotNumber": lot_number,
                "mode": mode,
                "netAmount": net_amount,
                "scheduledOptions": convert_and_respect_annotation_metadata(
                    object_=scheduled_options, annotation=BillOutDataScheduledOptions, direction="write"
                ),
                "status": status,
                "terms": terms,
                "totalAmount": total_amount,
                "vendor": convert_and_respect_annotation_metadata(
                    object_=vendor, annotation=VendorData, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    EditBillResponse,
                    parse_obj_as(
                        type_=EditBillResponse,  # 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_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[FileContent]:
        """
        Retrieves a file attached to a bill, either as a binary file or as a Base64-encoded string.

        Parameters
        ----------
        filename : str
            The filename in Payabli. Filename is `zipName` in response to a request to `/api/Invoice/{idInvoice}`. Here, the filename is `0_Bill.pdf``.
            "DocumentsRef": {
              "zipfile": "inva_269.zip",
              "filelist": [
                {
                  "originalName": "Bill.pdf",
                  "zipName": "0_Bill.pdf",
                  "descriptor": null
                }
              ]
            }

        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        return_object : typing.Optional[bool]
            When `true`, the request returns the file content as a Base64-encoded string.

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

        Returns
        -------
        AsyncHttpResponse[FileContent]
            A successful response returns a binary file when `returnObject` is `false`. When `returnObject` is `true`, the response contains the file content as a Base64-encoded string in an object. Due to technical limitations, only the object response is documented here.
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/attachedFileFromBill/{jsonable_encoder(id_bill)}/{jsonable_encoder(filename)}",
            method="GET",
            params={
                "returnObject": return_object,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    FileContent,
                    parse_obj_as(
                        type_=FileContent,  # 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_bill(
        self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[GetBillResponse]:
        """
        Retrieves a bill by ID from an entrypoint.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

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

        Returns
        -------
        AsyncHttpResponse[GetBillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/{jsonable_encoder(id_bill)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetBillResponse,
                    parse_obj_as(
                        type_=GetBillResponse,  # 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 list_bills(
        self,
        entry: str,
        *,
        export_format: typing.Optional[ExportFormat] = None,
        from_record: typing.Optional[int] = None,
        limit_record: typing.Optional[int] = None,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        sort_by: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[BillQueryResponse]:
        """
        Retrieve a list of bills for an entrypoint. Use filters to limit results. Include the `exportFormat` query parameter to return the results as a file instead of a JSON response.

        Parameters
        ----------
        entry : str
            The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)

        export_format : typing.Optional[ExportFormat]

        from_record : typing.Optional[int]
            The number of records to skip before starting to collect the result set.

        limit_record : typing.Optional[int]
            Max number of records to return for the query. Use `0` or negative value to return all records.

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Collection of field names, conditions, and values used to filter the query
            <Info>
              **You must remove `parameters=` from the request before you send it, otherwise Payabli will ignore the filters.**

              Because of a technical limitation, you can't make a request that includes filters from the API console on this page. The response isn't filtered. Instead, copy the request, remove `parameters=` and run the request in a different client.

              For example:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?parameters=totalAmount(gt)=1000&limitRecord=20

              should become:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?totalAmount(gt)=1000&limitRecord=20
            </Info>
            See [Filters and Conditions Reference](/developers/developer-guides/pay-ops-reporting-engine-overview#filters-and-conditions-reference) for help.

            List of field names accepted:
            - `frequency` (`in`, `nin`, `ne`, `eq`)
            - `method` (`in`, `nin`, `eq`, `ne`)
            - `event` (`in`, `nin`, `eq`, `ne`)
            - `target` (`ct`, `nct`, `eq`, `ne`)
            - `status` (`eq`, `ne`)
            - `approvalUserId` (`eq`, `ne`)
            - `parentOrgId` (`ne`, `eq`, `nin`, `in`)
            - `approvalUserEmail` (`eq`, `ne`)
            - `scheduleId` (`ne`, `eq`)

            List of comparison accepted - enclosed between parentheses:
            - `eq` or empty => equal
            - `gt` => greater than
            - `ge` => greater or equal
            - `lt` => less than
            - `le` => less or equal
            - `ne` => not equal
            - `ct` => contains
            - `nct` => not contains
            - `in` => inside array
            - `nin` => not inside array

            List of parameters accepted:
            - `limitRecord` : max number of records for query (default="20", "0" or negative value for all)
            - `fromRecord` : initial record in query
            Example: `totalAmount(gt)=20` returns all records with a `totalAmount` that's greater than 20.00

        sort_by : typing.Optional[str]
            The field name to use for sorting results. Use `desc(field_name)` to sort descending by `field_name`, and use `asc(field_name)` to sort ascending by `field_name`.

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

        Returns
        -------
        AsyncHttpResponse[BillQueryResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Query/bills/{jsonable_encoder(entry)}",
            method="GET",
            params={
                "exportFormat": export_format,
                "fromRecord": from_record,
                "limitRecord": limit_record,
                "parameters": parameters,
                "sortBy": sort_by,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillQueryResponse,
                    parse_obj_as(
                        type_=BillQueryResponse,  # 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 list_bills_org(
        self,
        org_id: int,
        *,
        export_format: typing.Optional[ExportFormat] = None,
        from_record: typing.Optional[int] = None,
        limit_record: typing.Optional[int] = None,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
        sort_by: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[BillQueryResponse]:
        """
        Retrieve a list of bills for an organization. Use filters to limit results. Include the `exportFormat` query parameter to return the results as a file instead of a JSON response.

        Parameters
        ----------
        org_id : int
            The numeric identifier for organization, assigned by Payabli.

        export_format : typing.Optional[ExportFormat]

        from_record : typing.Optional[int]
            The number of records to skip before starting to collect the result set.

        limit_record : typing.Optional[int]
            Max number of records to return for the query. Use `0` or negative value to return all records.

        parameters : typing.Optional[typing.Dict[str, typing.Optional[str]]]
            Collection of field names, conditions, and values used to filter the query
            <Info>
              **You must remove `parameters=` from the request before you send it, otherwise Payabli will ignore the filters.**

              Because of a technical limitation, you can't make a request that includes filters from the API console on this page. The response isn't filtered. Instead, copy the request, remove `parameters=` and run the request in a different client.

              For example:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?parameters=totalAmount(gt)=1000&limitRecord=20

              should become:

              --url https://api-sandbox.payabli.com/api/Query/transactions/org/236?totalAmount(gt)=1000&limitRecord=20
            </Info>
            See [Filters and Conditions Reference](/developers/developer-guides/pay-ops-reporting-engine-overview#filters-and-conditions-reference) for help.

            List of field names accepted:
            - `frequency` (in, nin, ne, eq)
            - `method` (in, nin, eq, ne)
            - `event` (in, nin, eq, ne)
            - `target` (ct, nct, eq, ne)
            - `status` (eq, ne)
            - `parentOrgId` (ne, eq, nin, in)
            - `approvalUserId` (eq, ne)
            - `approvalUserEmail` (eq, ne)

            List of comparison accepted - enclosed between parentheses:
            - eq or empty => equal
            - gt => greater than
            - ge => greater or equal
            - lt => less than
            - le => less or equal
            - ne => not equal
            - ct => contains
            - nct => not contains
            - in => inside array
            - nin => not inside array

            List of parameters accepted:
            - limitRecord : max number of records for query (default="20", "0" or negative value for all)
            - fromRecord : initial record in query

            Example: totalAmount(gt)=20 return all records with totalAmount greater than 20.00

        sort_by : typing.Optional[str]
            The field name to use for sorting results. Use `desc(field_name)` to sort descending by `field_name`, and use `asc(field_name)` to sort ascending by `field_name`.

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

        Returns
        -------
        AsyncHttpResponse[BillQueryResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Query/bills/org/{jsonable_encoder(org_id)}",
            method="GET",
            params={
                "exportFormat": export_format,
                "fromRecord": from_record,
                "limitRecord": limit_record,
                "parameters": parameters,
                "sortBy": sort_by,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillQueryResponse,
                    parse_obj_as(
                        type_=BillQueryResponse,  # 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 modify_approval_bill(
        self, id_bill: int, *, request: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[ModifyApprovalBillResponse]:
        """
        Modify the list of users the bill is sent to for approval.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        request : typing.Sequence[str]

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

        Returns
        -------
        AsyncHttpResponse[ModifyApprovalBillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/approval/{jsonable_encoder(id_bill)}",
            method="PUT",
            json=request,
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ModifyApprovalBillResponse,
                    parse_obj_as(
                        type_=ModifyApprovalBillResponse,  # 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 send_to_approval_bill(
        self,
        id_bill: int,
        *,
        request: typing.Sequence[str],
        autocreate_user: typing.Optional[bool] = None,
        idempotency_key: typing.Optional[IdempotencyKey] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[BillResponse]:
        """
        Send a bill to a user or list of users to approve.

        Parameters
        ----------
        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        request : typing.Sequence[str]

        autocreate_user : typing.Optional[bool]
            Automatically create the target user for approval if they don't exist.

        idempotency_key : typing.Optional[IdempotencyKey]

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

        Returns
        -------
        AsyncHttpResponse[BillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/approval/{jsonable_encoder(id_bill)}",
            method="POST",
            params={
                "autocreateUser": autocreate_user,
            },
            json=request,
            headers={
                "content-type": "application/json",
                "idempotencyKey": str(idempotency_key) if idempotency_key is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    BillResponse,
                    parse_obj_as(
                        type_=BillResponse,  # 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 set_approved_bill(
        self,
        approved: str,
        id_bill: int,
        *,
        email: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[SetApprovedBillResponse]:
        """
        Approve or disapprove a bill by ID.

        Parameters
        ----------
        approved : str
            String representing the approved status. Accepted values: 'true' or 'false'.

        id_bill : int
            Payabli ID for the bill. Get this ID by querying `/api/Query/bills/` for the entrypoint or the organization.

        email : typing.Optional[str]
            Email or username of user modifying approval status.

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

        Returns
        -------
        AsyncHttpResponse[SetApprovedBillResponse]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Bill/approval/{jsonable_encoder(id_bill)}/{jsonable_encoder(approved)}",
            method="GET",
            params={
                "email": email,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    SetApprovedBillResponse,
                    parse_obj_as(
                        type_=SetApprovedBillResponse,  # 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)
