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

import typing
from ..core.client_wrapper import SyncClientWrapper
from .raw_client import RawRefundsClient
from ..types.list_payment_refunds_request_sort_field import ListPaymentRefundsRequestSortField
from ..core.request_options import RequestOptions
from ..core.pagination import SyncPager
from ..types.payment_refund import PaymentRefund
from ..types.list_payment_refunds_response import ListPaymentRefundsResponse
from ..core.unchecked_base_model import construct_type
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..requests.money import MoneyParams
from ..requests.destination_details_cash_refund_details import DestinationDetailsCashRefundDetailsParams
from ..requests.destination_details_external_refund_details import DestinationDetailsExternalRefundDetailsParams
from ..types.refund_payment_response import RefundPaymentResponse
from ..types.get_payment_refund_response import GetPaymentRefundResponse
from ..core.client_wrapper import AsyncClientWrapper
from .raw_client import AsyncRawRefundsClient
from ..core.pagination import AsyncPager

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


class RefundsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawRefundsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawRefundsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        begin_time: typing.Optional[str] = None,
        end_time: typing.Optional[str] = None,
        sort_order: typing.Optional[str] = None,
        cursor: typing.Optional[str] = None,
        location_id: typing.Optional[str] = None,
        status: typing.Optional[str] = None,
        source_type: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        updated_at_begin_time: typing.Optional[str] = None,
        updated_at_end_time: typing.Optional[str] = None,
        sort_field: typing.Optional[ListPaymentRefundsRequestSortField] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[PaymentRefund]:
        """
        Retrieves a list of refunds for the account making the request.

        Results are eventually consistent, and new refunds or changes to refunds might take several
        seconds to appear.

        The maximum results per page is 100.

        Parameters
        ----------
        begin_time : typing.Optional[str]
            Indicates the start of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `created_at` field for each `PaymentRefund`.

            Default: The current time minus one year.

        end_time : typing.Optional[str]
            Indicates the end of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `created_at` field for each `PaymentRefund`.

            Default: The current time.

        sort_order : typing.Optional[str]
            The order in which results are listed by `PaymentRefund.created_at`:
            - `ASC` - Oldest to newest.
            - `DESC` - Newest to oldest (default).

        cursor : typing.Optional[str]
            A pagination cursor returned by a previous call to this endpoint.
            Provide this cursor to retrieve the next set of results for the original query.

            For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

        location_id : typing.Optional[str]
            Limit results to the location supplied. By default, results are returned
            for all locations associated with the seller.

        status : typing.Optional[str]
            If provided, only refunds with the given status are returned.
            For a list of refund status values, see [PaymentRefund](entity:PaymentRefund).

            Default: If omitted, refunds are returned regardless of their status.

        source_type : typing.Optional[str]
            If provided, only returns refunds whose payments have the indicated source type.
            Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`.
            For information about these payment source types, see
            [Take Payments](https://developer.squareup.com/docs/payments-api/take-payments).

            Default: If omitted, refunds are returned regardless of the source type.

        limit : typing.Optional[int]
            The maximum number of results to be returned in a single page.

            It is possible to receive fewer results than the specified limit on a given page.

            If the supplied value is greater than 100, no more than 100 results are returned.

            Default: 100

        updated_at_begin_time : typing.Optional[str]
            Indicates the start of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `updated_at` field for each `PaymentRefund`.

            Default: If omitted, the time range starts at `begin_time`.

        updated_at_end_time : typing.Optional[str]
            Indicates the end of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `updated_at` field for each `PaymentRefund`.

            Default: The current time.

        sort_field : typing.Optional[ListPaymentRefundsRequestSortField]
            The field used to sort results by. The default is `CREATED_AT`.

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

        Returns
        -------
        SyncPager[PaymentRefund]
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        response = client.refunds.list()
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        _response = self._raw_client._client_wrapper.httpx_client.request(
            "v2/refunds",
            method="GET",
            params={
                "begin_time": begin_time,
                "end_time": end_time,
                "sort_order": sort_order,
                "cursor": cursor,
                "location_id": location_id,
                "status": status,
                "source_type": source_type,
                "limit": limit,
                "updated_at_begin_time": updated_at_begin_time,
                "updated_at_end_time": updated_at_end_time,
                "sort_field": sort_field,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _parsed_response = typing.cast(
                    ListPaymentRefundsResponse,
                    construct_type(
                        type_=ListPaymentRefundsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                _parsed_next = _parsed_response.cursor
                _has_next = _parsed_next is not None and _parsed_next != ""
                _get_next = lambda: self.list(
                    begin_time=begin_time,
                    end_time=end_time,
                    sort_order=sort_order,
                    cursor=_parsed_next,
                    location_id=location_id,
                    status=status,
                    source_type=source_type,
                    limit=limit,
                    updated_at_begin_time=updated_at_begin_time,
                    updated_at_end_time=updated_at_end_time,
                    sort_field=sort_field,
                    request_options=request_options,
                )
                _items = _parsed_response.refunds
                return SyncPager(has_next=_has_next, items=_items, get_next=_get_next)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def refund_payment(
        self,
        *,
        idempotency_key: str,
        amount_money: MoneyParams,
        app_fee_money: typing.Optional[MoneyParams] = OMIT,
        payment_id: typing.Optional[str] = OMIT,
        destination_id: typing.Optional[str] = OMIT,
        unlinked: typing.Optional[bool] = OMIT,
        location_id: typing.Optional[str] = OMIT,
        customer_id: typing.Optional[str] = OMIT,
        reason: typing.Optional[str] = OMIT,
        payment_version_token: typing.Optional[str] = OMIT,
        team_member_id: typing.Optional[str] = OMIT,
        cash_details: typing.Optional[DestinationDetailsCashRefundDetailsParams] = OMIT,
        external_details: typing.Optional[DestinationDetailsExternalRefundDetailsParams] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RefundPaymentResponse:
        """
        Refunds a payment. You can refund the entire payment amount or a
        portion of it. You can use this endpoint to refund a card payment or record a
        refund of a cash or external payment. For more information, see
        [Refund Payment](https://developer.squareup.com/docs/payments-api/refund-payments).

        Parameters
        ----------
        idempotency_key : str
             A unique string that identifies this `RefundPayment` request. The key can be any valid string
            but must be unique for every `RefundPayment` request.

            Keys are limited to a max of 45 characters - however, the number of allowed characters might be
            less than 45, if multi-byte characters are used.

            For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency).

        amount_money : MoneyParams
            The amount of money to refund.

            This amount cannot be more than the `total_money` value of the payment minus the total
            amount of all previously completed refunds for this payment.

            This amount must be specified in the smallest denomination of the applicable currency
            (for example, US dollar amounts are specified in cents). For more information, see
            [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).

            The currency code must match the currency associated with the business
            that is charging the card.

        app_fee_money : typing.Optional[MoneyParams]
            The amount of money the developer contributes to help cover the refunded amount.
            This amount is specified in the smallest denomination of the applicable currency (for example,
            US dollar amounts are specified in cents).

            The value cannot be more than the `amount_money`.

            You can specify this parameter in a refund request only if the same parameter was also included
            when taking the payment. This is part of the application fee scenario the API supports. For more
            information, see [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees).

            To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required.
            For more information, see [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions).

        payment_id : typing.Optional[str]
            The unique ID of the payment being refunded.
            Required when unlinked=false, otherwise must not be set.

        destination_id : typing.Optional[str]
            The ID indicating where funds will be refunded to. Required for unlinked refunds. For more
            information, see [Process an Unlinked Refund](https://developer.squareup.com/docs/refunds-api/unlinked-refunds).

            For refunds linked to Square payments, `destination_id` is usually omitted; in this case, funds
            will be returned to the original payment source. The field may be specified in order to request
            a cross-method refund to a gift card. For more information,
            see [Cross-method refunds to gift cards](https://developer.squareup.com/docs/payments-api/refund-payments#cross-method-refunds-to-gift-cards).

        unlinked : typing.Optional[bool]
            Indicates that the refund is not linked to a Square payment.
            If set to true, `destination_id` and `location_id` must be supplied while `payment_id` must not
            be provided.

        location_id : typing.Optional[str]
            The location ID associated with the unlinked refund.
            Required for requests specifying `unlinked=true`.
            Otherwise, if included when `unlinked=false`, will throw an error.

        customer_id : typing.Optional[str]
            The [Customer](entity:Customer) ID of the customer associated with the refund.
            This is required if the `destination_id` refers to a card on file created using the Cards
            API. Only allowed when `unlinked=true`.

        reason : typing.Optional[str]
            A description of the reason for the refund.

        payment_version_token : typing.Optional[str]
             Used for optimistic concurrency. This opaque token identifies the current `Payment`
            version that the caller expects. If the server has a different version of the Payment,
            the update fails and a response with a VERSION_MISMATCH error is returned.
            If the versions match, or the field is not provided, the refund proceeds as normal.

        team_member_id : typing.Optional[str]
            An optional [TeamMember](entity:TeamMember) ID to associate with this refund.

        cash_details : typing.Optional[DestinationDetailsCashRefundDetailsParams]
            Additional details required when recording an unlinked cash refund (`destination_id` is CASH).

        external_details : typing.Optional[DestinationDetailsExternalRefundDetailsParams]
            Additional details required when recording an unlinked external refund
            (`destination_id` is EXTERNAL).

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

        Returns
        -------
        RefundPaymentResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.refunds.refund_payment(
            idempotency_key="9b7f2dcf-49da-4411-b23e-a2d6af21333a",
            amount_money={"amount": 1000, "currency": "USD"},
            app_fee_money={"amount": 10, "currency": "USD"},
            payment_id="R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
            reason="Example",
        )
        """
        response = self._raw_client.refund_payment(
            idempotency_key=idempotency_key,
            amount_money=amount_money,
            app_fee_money=app_fee_money,
            payment_id=payment_id,
            destination_id=destination_id,
            unlinked=unlinked,
            location_id=location_id,
            customer_id=customer_id,
            reason=reason,
            payment_version_token=payment_version_token,
            team_member_id=team_member_id,
            cash_details=cash_details,
            external_details=external_details,
            request_options=request_options,
        )
        return response.data

    def get(
        self, refund_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetPaymentRefundResponse:
        """
        Retrieves a specific refund using the `refund_id`.

        Parameters
        ----------
        refund_id : str
            The unique ID for the desired `PaymentRefund`.

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

        Returns
        -------
        GetPaymentRefundResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.refunds.get(
            refund_id="refund_id",
        )
        """
        response = self._raw_client.get(refund_id, request_options=request_options)
        return response.data


class AsyncRefundsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawRefundsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawRefundsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        begin_time: typing.Optional[str] = None,
        end_time: typing.Optional[str] = None,
        sort_order: typing.Optional[str] = None,
        cursor: typing.Optional[str] = None,
        location_id: typing.Optional[str] = None,
        status: typing.Optional[str] = None,
        source_type: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        updated_at_begin_time: typing.Optional[str] = None,
        updated_at_end_time: typing.Optional[str] = None,
        sort_field: typing.Optional[ListPaymentRefundsRequestSortField] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[PaymentRefund]:
        """
        Retrieves a list of refunds for the account making the request.

        Results are eventually consistent, and new refunds or changes to refunds might take several
        seconds to appear.

        The maximum results per page is 100.

        Parameters
        ----------
        begin_time : typing.Optional[str]
            Indicates the start of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `created_at` field for each `PaymentRefund`.

            Default: The current time minus one year.

        end_time : typing.Optional[str]
            Indicates the end of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `created_at` field for each `PaymentRefund`.

            Default: The current time.

        sort_order : typing.Optional[str]
            The order in which results are listed by `PaymentRefund.created_at`:
            - `ASC` - Oldest to newest.
            - `DESC` - Newest to oldest (default).

        cursor : typing.Optional[str]
            A pagination cursor returned by a previous call to this endpoint.
            Provide this cursor to retrieve the next set of results for the original query.

            For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

        location_id : typing.Optional[str]
            Limit results to the location supplied. By default, results are returned
            for all locations associated with the seller.

        status : typing.Optional[str]
            If provided, only refunds with the given status are returned.
            For a list of refund status values, see [PaymentRefund](entity:PaymentRefund).

            Default: If omitted, refunds are returned regardless of their status.

        source_type : typing.Optional[str]
            If provided, only returns refunds whose payments have the indicated source type.
            Current values include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`.
            For information about these payment source types, see
            [Take Payments](https://developer.squareup.com/docs/payments-api/take-payments).

            Default: If omitted, refunds are returned regardless of the source type.

        limit : typing.Optional[int]
            The maximum number of results to be returned in a single page.

            It is possible to receive fewer results than the specified limit on a given page.

            If the supplied value is greater than 100, no more than 100 results are returned.

            Default: 100

        updated_at_begin_time : typing.Optional[str]
            Indicates the start of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `updated_at` field for each `PaymentRefund`.

            Default: If omitted, the time range starts at `begin_time`.

        updated_at_end_time : typing.Optional[str]
            Indicates the end of the time range to retrieve each `PaymentRefund` for, in RFC 3339
            format.  The range is determined using the `updated_at` field for each `PaymentRefund`.

            Default: The current time.

        sort_field : typing.Optional[ListPaymentRefundsRequestSortField]
            The field used to sort results by. The default is `CREATED_AT`.

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

        Returns
        -------
        AsyncPager[PaymentRefund]
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            response = await client.refunds.list()
            async for item in response:
                yield item
            # alternatively, you can paginate page-by-page
            async for page in response.iter_pages():
                yield page


        asyncio.run(main())
        """
        _response = await self._raw_client._client_wrapper.httpx_client.request(
            "v2/refunds",
            method="GET",
            params={
                "begin_time": begin_time,
                "end_time": end_time,
                "sort_order": sort_order,
                "cursor": cursor,
                "location_id": location_id,
                "status": status,
                "source_type": source_type,
                "limit": limit,
                "updated_at_begin_time": updated_at_begin_time,
                "updated_at_end_time": updated_at_end_time,
                "sort_field": sort_field,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _parsed_response = typing.cast(
                    ListPaymentRefundsResponse,
                    construct_type(
                        type_=ListPaymentRefundsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                _parsed_next = _parsed_response.cursor
                _has_next = _parsed_next is not None and _parsed_next != ""
                _get_next = lambda: self.list(
                    begin_time=begin_time,
                    end_time=end_time,
                    sort_order=sort_order,
                    cursor=_parsed_next,
                    location_id=location_id,
                    status=status,
                    source_type=source_type,
                    limit=limit,
                    updated_at_begin_time=updated_at_begin_time,
                    updated_at_end_time=updated_at_end_time,
                    sort_field=sort_field,
                    request_options=request_options,
                )
                _items = _parsed_response.refunds
                return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def refund_payment(
        self,
        *,
        idempotency_key: str,
        amount_money: MoneyParams,
        app_fee_money: typing.Optional[MoneyParams] = OMIT,
        payment_id: typing.Optional[str] = OMIT,
        destination_id: typing.Optional[str] = OMIT,
        unlinked: typing.Optional[bool] = OMIT,
        location_id: typing.Optional[str] = OMIT,
        customer_id: typing.Optional[str] = OMIT,
        reason: typing.Optional[str] = OMIT,
        payment_version_token: typing.Optional[str] = OMIT,
        team_member_id: typing.Optional[str] = OMIT,
        cash_details: typing.Optional[DestinationDetailsCashRefundDetailsParams] = OMIT,
        external_details: typing.Optional[DestinationDetailsExternalRefundDetailsParams] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RefundPaymentResponse:
        """
        Refunds a payment. You can refund the entire payment amount or a
        portion of it. You can use this endpoint to refund a card payment or record a
        refund of a cash or external payment. For more information, see
        [Refund Payment](https://developer.squareup.com/docs/payments-api/refund-payments).

        Parameters
        ----------
        idempotency_key : str
             A unique string that identifies this `RefundPayment` request. The key can be any valid string
            but must be unique for every `RefundPayment` request.

            Keys are limited to a max of 45 characters - however, the number of allowed characters might be
            less than 45, if multi-byte characters are used.

            For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency).

        amount_money : MoneyParams
            The amount of money to refund.

            This amount cannot be more than the `total_money` value of the payment minus the total
            amount of all previously completed refunds for this payment.

            This amount must be specified in the smallest denomination of the applicable currency
            (for example, US dollar amounts are specified in cents). For more information, see
            [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).

            The currency code must match the currency associated with the business
            that is charging the card.

        app_fee_money : typing.Optional[MoneyParams]
            The amount of money the developer contributes to help cover the refunded amount.
            This amount is specified in the smallest denomination of the applicable currency (for example,
            US dollar amounts are specified in cents).

            The value cannot be more than the `amount_money`.

            You can specify this parameter in a refund request only if the same parameter was also included
            when taking the payment. This is part of the application fee scenario the API supports. For more
            information, see [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees).

            To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required.
            For more information, see [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions).

        payment_id : typing.Optional[str]
            The unique ID of the payment being refunded.
            Required when unlinked=false, otherwise must not be set.

        destination_id : typing.Optional[str]
            The ID indicating where funds will be refunded to. Required for unlinked refunds. For more
            information, see [Process an Unlinked Refund](https://developer.squareup.com/docs/refunds-api/unlinked-refunds).

            For refunds linked to Square payments, `destination_id` is usually omitted; in this case, funds
            will be returned to the original payment source. The field may be specified in order to request
            a cross-method refund to a gift card. For more information,
            see [Cross-method refunds to gift cards](https://developer.squareup.com/docs/payments-api/refund-payments#cross-method-refunds-to-gift-cards).

        unlinked : typing.Optional[bool]
            Indicates that the refund is not linked to a Square payment.
            If set to true, `destination_id` and `location_id` must be supplied while `payment_id` must not
            be provided.

        location_id : typing.Optional[str]
            The location ID associated with the unlinked refund.
            Required for requests specifying `unlinked=true`.
            Otherwise, if included when `unlinked=false`, will throw an error.

        customer_id : typing.Optional[str]
            The [Customer](entity:Customer) ID of the customer associated with the refund.
            This is required if the `destination_id` refers to a card on file created using the Cards
            API. Only allowed when `unlinked=true`.

        reason : typing.Optional[str]
            A description of the reason for the refund.

        payment_version_token : typing.Optional[str]
             Used for optimistic concurrency. This opaque token identifies the current `Payment`
            version that the caller expects. If the server has a different version of the Payment,
            the update fails and a response with a VERSION_MISMATCH error is returned.
            If the versions match, or the field is not provided, the refund proceeds as normal.

        team_member_id : typing.Optional[str]
            An optional [TeamMember](entity:TeamMember) ID to associate with this refund.

        cash_details : typing.Optional[DestinationDetailsCashRefundDetailsParams]
            Additional details required when recording an unlinked cash refund (`destination_id` is CASH).

        external_details : typing.Optional[DestinationDetailsExternalRefundDetailsParams]
            Additional details required when recording an unlinked external refund
            (`destination_id` is EXTERNAL).

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

        Returns
        -------
        RefundPaymentResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.refunds.refund_payment(
                idempotency_key="9b7f2dcf-49da-4411-b23e-a2d6af21333a",
                amount_money={"amount": 1000, "currency": "USD"},
                app_fee_money={"amount": 10, "currency": "USD"},
                payment_id="R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
                reason="Example",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.refund_payment(
            idempotency_key=idempotency_key,
            amount_money=amount_money,
            app_fee_money=app_fee_money,
            payment_id=payment_id,
            destination_id=destination_id,
            unlinked=unlinked,
            location_id=location_id,
            customer_id=customer_id,
            reason=reason,
            payment_version_token=payment_version_token,
            team_member_id=team_member_id,
            cash_details=cash_details,
            external_details=external_details,
            request_options=request_options,
        )
        return response.data

    async def get(
        self, refund_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetPaymentRefundResponse:
        """
        Retrieves a specific refund using the `refund_id`.

        Parameters
        ----------
        refund_id : str
            The unique ID for the desired `PaymentRefund`.

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

        Returns
        -------
        GetPaymentRefundResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.refunds.get(
                refund_id="refund_id",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.get(refund_id, request_options=request_options)
        return response.data
