ebay_client/ebay_client/account/client.py

61 lines
2 KiB
Python

from __future__ import annotations
from ebay_client.core.http.transport import ApiTransport
from ebay_client.generated.account.models import (
FulfillmentPolicyResponse,
PaymentPolicyResponse,
Programs,
ReturnPolicyResponse,
SellingPrivileges,
)
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) -> FulfillmentPolicyResponse:
return self.transport.request_model(
FulfillmentPolicyResponse,
"GET",
"/sell/account/v1/fulfillment_policy",
scopes=[ACCOUNT_READ_SCOPE],
params={"marketplace_id": marketplace_id},
)
def get_payment_policies(self, *, marketplace_id: str) -> PaymentPolicyResponse:
return self.transport.request_model(
PaymentPolicyResponse,
"GET",
"/sell/account/v1/payment_policy",
scopes=[ACCOUNT_READ_SCOPE],
params={"marketplace_id": marketplace_id},
)
def get_return_policies(self, *, marketplace_id: str) -> ReturnPolicyResponse:
return self.transport.request_model(
ReturnPolicyResponse,
"GET",
"/sell/account/v1/return_policy",
scopes=[ACCOUNT_READ_SCOPE],
params={"marketplace_id": marketplace_id},
)
def get_privileges(self) -> SellingPrivileges:
return self.transport.request_model(
SellingPrivileges,
"GET",
"/sell/account/v1/privilege",
scopes=[ACCOUNT_SCOPE],
)
def get_opted_in_programs(self) -> Programs:
return self.transport.request_model(
Programs,
"GET",
"/sell/account/v1/program/get_opted_in_programs",
scopes=[ACCOUNT_READ_SCOPE],
)