from __future__ import annotations

from typing import Any

from ebay_client.core.http.transport import ApiTransport

ACCOUNT_SCOPE = "https://api.ebay.com/oauth/api_scope/sell.account"
ACCOUNT_READ_SCOPE = "https://api.ebay.com/oauth/api_scope/sell.account.readonly"


class AccountClient:
    def __init__(self, transport: ApiTransport) -> None:
        self.transport = transport

    def get_fulfillment_policies(self, *, marketplace_id: str) -> dict[str, Any]:
        return self.transport.request_json(
            "GET",
            "/sell/account/v1/fulfillment_policy",
            scopes=[ACCOUNT_READ_SCOPE],
            params={"marketplace_id": marketplace_id},
        )

    def get_payment_policies(self, *, marketplace_id: str) -> dict[str, Any]:
        return self.transport.request_json(
            "GET",
            "/sell/account/v1/payment_policy",
            scopes=[ACCOUNT_READ_SCOPE],
            params={"marketplace_id": marketplace_id},
        )

    def get_return_policies(self, *, marketplace_id: str) -> dict[str, Any]:
        return self.transport.request_json(
            "GET",
            "/sell/account/v1/return_policy",
            scopes=[ACCOUNT_READ_SCOPE],
            params={"marketplace_id": marketplace_id},
        )

    def get_privileges(self) -> dict[str, Any]:
        return self.transport.request_json(
            "GET",
            "/sell/account/v1/privilege",
            scopes=[ACCOUNT_SCOPE],
        )

    def get_opted_in_programs(self) -> dict[str, Any]:
        return self.transport.request_json(
            "GET",
            "/sell/account/v1/program/get_opted_in_programs",
            scopes=[ACCOUNT_READ_SCOPE],
        )
