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

import datetime as dt
import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.bad_request_error import BadRequestError
from ..errors.internal_server_error import InternalServerError
from ..errors.service_unavailable_error import ServiceUnavailableError
from ..errors.unauthorized_error import UnauthorizedError
from ..types.additional_data import AdditionalData
from ..types.idempotency_key import IdempotencyKey
from ..types.page_content import PageContent
from ..types.page_identifier import PageIdentifier
from ..types.page_setting import PageSetting
from ..types.payabli_api_response import PayabliApiResponse
from ..types.payabli_api_response_00_responsedatanonobject import PayabliApiResponse00Responsedatanonobject
from ..types.payabli_credentials import PayabliCredentials
from ..types.payabli_pages import PayabliPages
from ..types.receipt_content import ReceiptContent
from ..types.subdomain import Subdomain

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


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

    def load_page(
        self, entry: str, subdomain: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[PayabliPages]:
        """
        Loads all of a payment page's details including `pageIdentifier` and `validationCode`. This endpoint requires an `application` API token.

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

        subdomain : str
            Payment page identifier. The subdomain value is the last part of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

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

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

    def new_page(
        self,
        entry: str,
        *,
        idempotency_key: typing.Optional[IdempotencyKey] = None,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        credentials: typing.Optional[typing.Sequence[PayabliCredentials]] = OMIT,
        last_access: typing.Optional[dt.datetime] = OMIT,
        page_content: typing.Optional[PageContent] = OMIT,
        page_identifier: typing.Optional[PageIdentifier] = OMIT,
        page_settings: typing.Optional[PageSetting] = OMIT,
        published: typing.Optional[int] = OMIT,
        receipt_content: typing.Optional[ReceiptContent] = OMIT,
        subdomain: typing.Optional[Subdomain] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        validation_code: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PayabliApiResponse00Responsedatanonobject]:
        """

        Creates a new payment page for a paypoint.
        Note: this operation doesn't create a new paypoint, just a payment page for an existing paypoint. Paypoints are created by the Payabli team when a boarding application is approved.

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

        idempotency_key : typing.Optional[IdempotencyKey]

        additional_data : typing.Optional[AdditionalData]

        credentials : typing.Optional[typing.Sequence[PayabliCredentials]]
            Array of credential objects with active services for the page

        last_access : typing.Optional[dt.datetime]
            Timestamp of last access to page structure

        page_content : typing.Optional[PageContent]
            Sections of page

        page_identifier : typing.Optional[PageIdentifier]

        page_settings : typing.Optional[PageSetting]
            Settings of page

        published : typing.Optional[int]
            Flag indicating if page is active to accept payments. `0` for false, `1` for true.

        receipt_content : typing.Optional[ReceiptContent]
            Sections of payment receipt

        subdomain : typing.Optional[Subdomain]
            Page identifier. Must be unique in platform.

        total_amount : typing.Optional[float]
            Total amount to pay in this page

        validation_code : typing.Optional[str]
            Base64 encoded image of CAPTCHA associated to this page load

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

        Returns
        -------
        HttpResponse[PayabliApiResponse00Responsedatanonobject]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Paypoint/{jsonable_encoder(entry)}",
            method="POST",
            json={
                "AdditionalData": additional_data,
                "credentials": convert_and_respect_annotation_metadata(
                    object_=credentials, annotation=typing.Sequence[PayabliCredentials], direction="write"
                ),
                "lastAccess": last_access,
                "pageContent": convert_and_respect_annotation_metadata(
                    object_=page_content, annotation=PageContent, direction="write"
                ),
                "pageIdentifier": page_identifier,
                "pageSettings": convert_and_respect_annotation_metadata(
                    object_=page_settings, annotation=PageSetting, direction="write"
                ),
                "published": published,
                "receiptContent": convert_and_respect_annotation_metadata(
                    object_=receipt_content, annotation=ReceiptContent, direction="write"
                ),
                "subdomain": subdomain,
                "totalAmount": total_amount,
                "validationCode": validation_code,
            },
            headers={
                "content-type": "application/json",
                "idempotencyKey": str(idempotency_key) if idempotency_key is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponse00Responsedatanonobject,
                    parse_obj_as(
                        type_=PayabliApiResponse00Responsedatanonobject,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def save_page(
        self,
        entry: str,
        subdomain_: str,
        *,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        credentials: typing.Optional[typing.Sequence[PayabliCredentials]] = OMIT,
        last_access: typing.Optional[dt.datetime] = OMIT,
        page_content: typing.Optional[PageContent] = OMIT,
        page_identifier: typing.Optional[PageIdentifier] = OMIT,
        page_settings: typing.Optional[PageSetting] = OMIT,
        published: typing.Optional[int] = OMIT,
        receipt_content: typing.Optional[ReceiptContent] = OMIT,
        subdomain: typing.Optional[Subdomain] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        validation_code: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PayabliApiResponse00Responsedatanonobject]:
        """
        Updates a payment page in a paypoint.

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

        subdomain_ : str
            Payment page identifier. The subdomain value is the last part of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

        additional_data : typing.Optional[AdditionalData]

        credentials : typing.Optional[typing.Sequence[PayabliCredentials]]
            Array of credential objects with active services for the page

        last_access : typing.Optional[dt.datetime]
            Timestamp of last access to page structure

        page_content : typing.Optional[PageContent]
            Sections of page

        page_identifier : typing.Optional[PageIdentifier]

        page_settings : typing.Optional[PageSetting]
            Settings of page

        published : typing.Optional[int]
            Flag indicating if page is active to accept payments. `0` for false, `1` for true.

        receipt_content : typing.Optional[ReceiptContent]
            Sections of payment receipt

        subdomain : typing.Optional[Subdomain]
            Page identifier. Must be unique in platform.

        total_amount : typing.Optional[float]
            Total amount to pay in this page

        validation_code : typing.Optional[str]
            Base64 encoded image of CAPTCHA associated to this page load

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

        Returns
        -------
        HttpResponse[PayabliApiResponse00Responsedatanonobject]
            Success
        """
        _response = self._client_wrapper.httpx_client.request(
            f"Paypoint/{jsonable_encoder(entry)}/{jsonable_encoder(subdomain_)}",
            method="PUT",
            json={
                "AdditionalData": additional_data,
                "credentials": convert_and_respect_annotation_metadata(
                    object_=credentials, annotation=typing.Sequence[PayabliCredentials], direction="write"
                ),
                "lastAccess": last_access,
                "pageContent": convert_and_respect_annotation_metadata(
                    object_=page_content, annotation=PageContent, direction="write"
                ),
                "pageIdentifier": page_identifier,
                "pageSettings": convert_and_respect_annotation_metadata(
                    object_=page_settings, annotation=PageSetting, direction="write"
                ),
                "published": published,
                "receiptContent": convert_and_respect_annotation_metadata(
                    object_=receipt_content, annotation=ReceiptContent, direction="write"
                ),
                "subdomain": subdomain,
                "totalAmount": total_amount,
                "validationCode": validation_code,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponse00Responsedatanonobject,
                    parse_obj_as(
                        type_=PayabliApiResponse00Responsedatanonobject,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


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

    async def load_page(
        self, entry: str, subdomain: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[PayabliPages]:
        """
        Loads all of a payment page's details including `pageIdentifier` and `validationCode`. This endpoint requires an `application` API token.

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

        subdomain : str
            Payment page identifier. The subdomain value is the last part of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

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

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

    async def new_page(
        self,
        entry: str,
        *,
        idempotency_key: typing.Optional[IdempotencyKey] = None,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        credentials: typing.Optional[typing.Sequence[PayabliCredentials]] = OMIT,
        last_access: typing.Optional[dt.datetime] = OMIT,
        page_content: typing.Optional[PageContent] = OMIT,
        page_identifier: typing.Optional[PageIdentifier] = OMIT,
        page_settings: typing.Optional[PageSetting] = OMIT,
        published: typing.Optional[int] = OMIT,
        receipt_content: typing.Optional[ReceiptContent] = OMIT,
        subdomain: typing.Optional[Subdomain] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        validation_code: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PayabliApiResponse00Responsedatanonobject]:
        """

        Creates a new payment page for a paypoint.
        Note: this operation doesn't create a new paypoint, just a payment page for an existing paypoint. Paypoints are created by the Payabli team when a boarding application is approved.

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

        idempotency_key : typing.Optional[IdempotencyKey]

        additional_data : typing.Optional[AdditionalData]

        credentials : typing.Optional[typing.Sequence[PayabliCredentials]]
            Array of credential objects with active services for the page

        last_access : typing.Optional[dt.datetime]
            Timestamp of last access to page structure

        page_content : typing.Optional[PageContent]
            Sections of page

        page_identifier : typing.Optional[PageIdentifier]

        page_settings : typing.Optional[PageSetting]
            Settings of page

        published : typing.Optional[int]
            Flag indicating if page is active to accept payments. `0` for false, `1` for true.

        receipt_content : typing.Optional[ReceiptContent]
            Sections of payment receipt

        subdomain : typing.Optional[Subdomain]
            Page identifier. Must be unique in platform.

        total_amount : typing.Optional[float]
            Total amount to pay in this page

        validation_code : typing.Optional[str]
            Base64 encoded image of CAPTCHA associated to this page load

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

        Returns
        -------
        AsyncHttpResponse[PayabliApiResponse00Responsedatanonobject]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Paypoint/{jsonable_encoder(entry)}",
            method="POST",
            json={
                "AdditionalData": additional_data,
                "credentials": convert_and_respect_annotation_metadata(
                    object_=credentials, annotation=typing.Sequence[PayabliCredentials], direction="write"
                ),
                "lastAccess": last_access,
                "pageContent": convert_and_respect_annotation_metadata(
                    object_=page_content, annotation=PageContent, direction="write"
                ),
                "pageIdentifier": page_identifier,
                "pageSettings": convert_and_respect_annotation_metadata(
                    object_=page_settings, annotation=PageSetting, direction="write"
                ),
                "published": published,
                "receiptContent": convert_and_respect_annotation_metadata(
                    object_=receipt_content, annotation=ReceiptContent, direction="write"
                ),
                "subdomain": subdomain,
                "totalAmount": total_amount,
                "validationCode": validation_code,
            },
            headers={
                "content-type": "application/json",
                "idempotencyKey": str(idempotency_key) if idempotency_key is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponse00Responsedatanonobject,
                    parse_obj_as(
                        type_=PayabliApiResponse00Responsedatanonobject,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def save_page(
        self,
        entry: str,
        subdomain_: str,
        *,
        additional_data: typing.Optional[AdditionalData] = OMIT,
        credentials: typing.Optional[typing.Sequence[PayabliCredentials]] = OMIT,
        last_access: typing.Optional[dt.datetime] = OMIT,
        page_content: typing.Optional[PageContent] = OMIT,
        page_identifier: typing.Optional[PageIdentifier] = OMIT,
        page_settings: typing.Optional[PageSetting] = OMIT,
        published: typing.Optional[int] = OMIT,
        receipt_content: typing.Optional[ReceiptContent] = OMIT,
        subdomain: typing.Optional[Subdomain] = OMIT,
        total_amount: typing.Optional[float] = OMIT,
        validation_code: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PayabliApiResponse00Responsedatanonobject]:
        """
        Updates a payment page in a paypoint.

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

        subdomain_ : str
            Payment page identifier. The subdomain value is the last part of the payment page URL. For example, in`https://paypages-sandbox.payabli.com/513823dc10/pay-your-fees-1`, the subdomain is `pay-your-fees-1`.

        additional_data : typing.Optional[AdditionalData]

        credentials : typing.Optional[typing.Sequence[PayabliCredentials]]
            Array of credential objects with active services for the page

        last_access : typing.Optional[dt.datetime]
            Timestamp of last access to page structure

        page_content : typing.Optional[PageContent]
            Sections of page

        page_identifier : typing.Optional[PageIdentifier]

        page_settings : typing.Optional[PageSetting]
            Settings of page

        published : typing.Optional[int]
            Flag indicating if page is active to accept payments. `0` for false, `1` for true.

        receipt_content : typing.Optional[ReceiptContent]
            Sections of payment receipt

        subdomain : typing.Optional[Subdomain]
            Page identifier. Must be unique in platform.

        total_amount : typing.Optional[float]
            Total amount to pay in this page

        validation_code : typing.Optional[str]
            Base64 encoded image of CAPTCHA associated to this page load

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

        Returns
        -------
        AsyncHttpResponse[PayabliApiResponse00Responsedatanonobject]
            Success
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"Paypoint/{jsonable_encoder(entry)}/{jsonable_encoder(subdomain_)}",
            method="PUT",
            json={
                "AdditionalData": additional_data,
                "credentials": convert_and_respect_annotation_metadata(
                    object_=credentials, annotation=typing.Sequence[PayabliCredentials], direction="write"
                ),
                "lastAccess": last_access,
                "pageContent": convert_and_respect_annotation_metadata(
                    object_=page_content, annotation=PageContent, direction="write"
                ),
                "pageIdentifier": page_identifier,
                "pageSettings": convert_and_respect_annotation_metadata(
                    object_=page_settings, annotation=PageSetting, direction="write"
                ),
                "published": published,
                "receiptContent": convert_and_respect_annotation_metadata(
                    object_=receipt_content, annotation=ReceiptContent, direction="write"
                ),
                "subdomain": subdomain,
                "totalAmount": total_amount,
                "validationCode": validation_code,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PayabliApiResponse00Responsedatanonobject,
                    parse_obj_as(
                        type_=PayabliApiResponse00Responsedatanonobject,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 503:
                raise ServiceUnavailableError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        PayabliApiResponse,
                        parse_obj_as(
                            type_=PayabliApiResponse,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
