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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
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.terms import Terms
from ..types.vendor_data import VendorData
from .raw_client import AsyncRawBillClient, RawBillClient
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 BillClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBillClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawBillClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawBillClient
        """
        return self._raw_client

    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,
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        import datetime

        from payabli import BillItem, FileContent, VendorData, payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.add_bill(
            entry="8cfec329267",
            bill_number="ABC-123",
            net_amount=3762.87,
            bill_date=datetime.date.fromisoformat(
                "2024-07-01",
            ),
            due_date=datetime.date.fromisoformat(
                "2024-07-01",
            ),
            comments="Deposit for materials",
            bill_items=[
                BillItem(
                    item_product_code="M-DEPOSIT",
                    item_product_name="Materials deposit",
                    item_description="Deposit for materials",
                    item_commodity_code="010",
                    item_unit_of_measure="SqFt",
                    item_cost=5.0,
                    item_qty=1,
                    item_mode=0,
                    item_categories=["deposits"],
                    item_total_amount=123.0,
                    item_tax_amount=7.0,
                    item_tax_rate=0.075,
                )
            ],
            mode=0,
            accounting_field_1="MyInternalId",
            vendor=VendorData(
                vendor_number="1234-A",
            ),
            end_date=datetime.date.fromisoformat(
                "2024-07-01",
            ),
            frequency="monthly",
            terms="NET30",
            status=-99,
            attachments=[
                FileContent(
                    ftype="pdf",
                    filename="my-doc.pdf",
                    furl="https://mysite.com/my-doc.pdf",
                )
            ],
        )
        """
        _response = self._raw_client.add_bill(
            entry,
            idempotency_key=idempotency_key,
            accounting_field_1=accounting_field_1,
            accounting_field_2=accounting_field_2,
            additional_data=additional_data,
            attachments=attachments,
            bill_date=bill_date,
            bill_items=bill_items,
            bill_number=bill_number,
            comments=comments,
            discount=discount,
            due_date=due_date,
            end_date=end_date,
            frequency=frequency,
            lot_number=lot_number,
            mode=mode,
            net_amount=net_amount,
            scheduled_options=scheduled_options,
            status=status,
            terms=terms,
            total_amount=total_amount,
            vendor=vendor,
            request_options=request_options,
        )
        return _response.data

    def delete_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.delete_attached_from_bill(
            filename="0_Bill.pdf",
            id_bill=285,
        )
        """
        _response = self._raw_client.delete_attached_from_bill(
            filename, id_bill, return_object=return_object, request_options=request_options
        )
        return _response.data

    def delete_bill(self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.delete_bill(
            id_bill=285,
        )
        """
        _response = self._raw_client.delete_bill(id_bill, request_options=request_options)
        return _response.data

    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,
    ) -> 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
        -------
        EditBillResponse
            Success

        Examples
        --------
        import datetime

        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.edit_bill(
            id_bill=285,
            net_amount=3762.87,
            bill_date=datetime.date.fromisoformat(
                "2025-07-01",
            ),
        )
        """
        _response = self._raw_client.edit_bill(
            id_bill,
            accounting_field_1=accounting_field_1,
            accounting_field_2=accounting_field_2,
            additional_data=additional_data,
            attachments=attachments,
            bill_date=bill_date,
            bill_items=bill_items,
            bill_number=bill_number,
            comments=comments,
            discount=discount,
            due_date=due_date,
            end_date=end_date,
            frequency=frequency,
            lot_number=lot_number,
            mode=mode,
            net_amount=net_amount,
            scheduled_options=scheduled_options,
            status=status,
            terms=terms,
            total_amount=total_amount,
            vendor=vendor,
            request_options=request_options,
        )
        return _response.data

    def get_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> 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
        -------
        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.

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.get_attached_from_bill(
            filename="0_Bill.pdf",
            id_bill=285,
            return_object=True,
        )
        """
        _response = self._raw_client.get_attached_from_bill(
            filename, id_bill, return_object=return_object, request_options=request_options
        )
        return _response.data

    def get_bill(self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None) -> 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
        -------
        GetBillResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.get_bill(
            id_bill=285,
        )
        """
        _response = self._raw_client.get_bill(id_bill, request_options=request_options)
        return _response.data

    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,
    ) -> 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
        -------
        BillQueryResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.list_bills(
            entry="8cfec329267",
            from_record=251,
            limit_record=0,
            sort_by="desc(field_name)",
        )
        """
        _response = self._raw_client.list_bills(
            entry,
            export_format=export_format,
            from_record=from_record,
            limit_record=limit_record,
            parameters=parameters,
            sort_by=sort_by,
            request_options=request_options,
        )
        return _response.data

    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,
    ) -> 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
        -------
        BillQueryResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.list_bills_org(
            org_id=123,
            from_record=251,
            limit_record=0,
            sort_by="desc(field_name)",
        )
        """
        _response = self._raw_client.list_bills_org(
            org_id,
            export_format=export_format,
            from_record=from_record,
            limit_record=limit_record,
            parameters=parameters,
            sort_by=sort_by,
            request_options=request_options,
        )
        return _response.data

    def modify_approval_bill(
        self, id_bill: int, *, request: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
    ) -> 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
        -------
        ModifyApprovalBillResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.modify_approval_bill(
            id_bill=285,
            request=["string"],
        )
        """
        _response = self._raw_client.modify_approval_bill(id_bill, request=request, request_options=request_options)
        return _response.data

    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,
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.send_to_approval_bill(
            id_bill=285,
            idempotency_key="6B29FC40-CA47-1067-B31D-00DD010662DA",
            request=["string"],
        )
        """
        _response = self._raw_client.send_to_approval_bill(
            id_bill,
            request=request,
            autocreate_user=autocreate_user,
            idempotency_key=idempotency_key,
            request_options=request_options,
        )
        return _response.data

    def set_approved_bill(
        self,
        approved: str,
        id_bill: int,
        *,
        email: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> 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
        -------
        SetApprovedBillResponse
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.bill.set_approved_bill(
            approved="true",
            id_bill=285,
        )
        """
        _response = self._raw_client.set_approved_bill(approved, id_bill, email=email, request_options=request_options)
        return _response.data


class AsyncBillClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBillClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawBillClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawBillClient
        """
        return self._raw_client

    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,
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        import asyncio
        import datetime

        from payabli import Asyncpayabli, BillItem, FileContent, VendorData

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.add_bill(
                entry="8cfec329267",
                bill_number="ABC-123",
                net_amount=3762.87,
                bill_date=datetime.date.fromisoformat(
                    "2024-07-01",
                ),
                due_date=datetime.date.fromisoformat(
                    "2024-07-01",
                ),
                comments="Deposit for materials",
                bill_items=[
                    BillItem(
                        item_product_code="M-DEPOSIT",
                        item_product_name="Materials deposit",
                        item_description="Deposit for materials",
                        item_commodity_code="010",
                        item_unit_of_measure="SqFt",
                        item_cost=5.0,
                        item_qty=1,
                        item_mode=0,
                        item_categories=["deposits"],
                        item_total_amount=123.0,
                        item_tax_amount=7.0,
                        item_tax_rate=0.075,
                    )
                ],
                mode=0,
                accounting_field_1="MyInternalId",
                vendor=VendorData(
                    vendor_number="1234-A",
                ),
                end_date=datetime.date.fromisoformat(
                    "2024-07-01",
                ),
                frequency="monthly",
                terms="NET30",
                status=-99,
                attachments=[
                    FileContent(
                        ftype="pdf",
                        filename="my-doc.pdf",
                        furl="https://mysite.com/my-doc.pdf",
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.add_bill(
            entry,
            idempotency_key=idempotency_key,
            accounting_field_1=accounting_field_1,
            accounting_field_2=accounting_field_2,
            additional_data=additional_data,
            attachments=attachments,
            bill_date=bill_date,
            bill_items=bill_items,
            bill_number=bill_number,
            comments=comments,
            discount=discount,
            due_date=due_date,
            end_date=end_date,
            frequency=frequency,
            lot_number=lot_number,
            mode=mode,
            net_amount=net_amount,
            scheduled_options=scheduled_options,
            status=status,
            terms=terms,
            total_amount=total_amount,
            vendor=vendor,
            request_options=request_options,
        )
        return _response.data

    async def delete_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.delete_attached_from_bill(
                filename="0_Bill.pdf",
                id_bill=285,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_attached_from_bill(
            filename, id_bill, return_object=return_object, request_options=request_options
        )
        return _response.data

    async def delete_bill(
        self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.delete_bill(
                id_bill=285,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_bill(id_bill, request_options=request_options)
        return _response.data

    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,
    ) -> 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
        -------
        EditBillResponse
            Success

        Examples
        --------
        import asyncio
        import datetime

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.edit_bill(
                id_bill=285,
                net_amount=3762.87,
                bill_date=datetime.date.fromisoformat(
                    "2025-07-01",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.edit_bill(
            id_bill,
            accounting_field_1=accounting_field_1,
            accounting_field_2=accounting_field_2,
            additional_data=additional_data,
            attachments=attachments,
            bill_date=bill_date,
            bill_items=bill_items,
            bill_number=bill_number,
            comments=comments,
            discount=discount,
            due_date=due_date,
            end_date=end_date,
            frequency=frequency,
            lot_number=lot_number,
            mode=mode,
            net_amount=net_amount,
            scheduled_options=scheduled_options,
            status=status,
            terms=terms,
            total_amount=total_amount,
            vendor=vendor,
            request_options=request_options,
        )
        return _response.data

    async def get_attached_from_bill(
        self,
        filename: str,
        id_bill: int,
        *,
        return_object: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> 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
        -------
        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.

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.get_attached_from_bill(
                filename="0_Bill.pdf",
                id_bill=285,
                return_object=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_attached_from_bill(
            filename, id_bill, return_object=return_object, request_options=request_options
        )
        return _response.data

    async def get_bill(
        self, id_bill: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> 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
        -------
        GetBillResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.get_bill(
                id_bill=285,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_bill(id_bill, request_options=request_options)
        return _response.data

    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,
    ) -> 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
        -------
        BillQueryResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.list_bills(
                entry="8cfec329267",
                from_record=251,
                limit_record=0,
                sort_by="desc(field_name)",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_bills(
            entry,
            export_format=export_format,
            from_record=from_record,
            limit_record=limit_record,
            parameters=parameters,
            sort_by=sort_by,
            request_options=request_options,
        )
        return _response.data

    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,
    ) -> 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
        -------
        BillQueryResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.list_bills_org(
                org_id=123,
                from_record=251,
                limit_record=0,
                sort_by="desc(field_name)",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_bills_org(
            org_id,
            export_format=export_format,
            from_record=from_record,
            limit_record=limit_record,
            parameters=parameters,
            sort_by=sort_by,
            request_options=request_options,
        )
        return _response.data

    async def modify_approval_bill(
        self, id_bill: int, *, request: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
    ) -> 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
        -------
        ModifyApprovalBillResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.modify_approval_bill(
                id_bill=285,
                request=["string"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.modify_approval_bill(
            id_bill, request=request, request_options=request_options
        )
        return _response.data

    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,
    ) -> 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
        -------
        BillResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.send_to_approval_bill(
                id_bill=285,
                idempotency_key="6B29FC40-CA47-1067-B31D-00DD010662DA",
                request=["string"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.send_to_approval_bill(
            id_bill,
            request=request,
            autocreate_user=autocreate_user,
            idempotency_key=idempotency_key,
            request_options=request_options,
        )
        return _response.data

    async def set_approved_bill(
        self,
        approved: str,
        id_bill: int,
        *,
        email: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> 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
        -------
        SetApprovedBillResponse
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.bill.set_approved_bill(
                approved="true",
                id_bill=285,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.set_approved_bill(
            approved, id_bill, email=email, request_options=request_options
        )
        return _response.data
