Self-Employed API¶
API для работы с самозанятыми.
- class aioyookassa.core.api.self_employed.SelfEmployedAPI(client: BaseAPIClient)[source]¶
Bases:
BaseAPI[CreateSelfEmployedParams,SelfEmployed]YooKassa self-employed API client.
Provides methods for creating and retrieving self-employed persons.
Initialize base API client.
- Parameters:
client – Base API client instance.
- async create_self_employed(params: CreateSelfEmployedParams) SelfEmployed[source]¶
Create a new self-employed in YooKassa.
- Parameters:
params (CreateSelfEmployedParams) – Self-employed creation parameters (CreateSelfEmployedParams).
- Returns:
SelfEmployed object.
- Return type:
- Seealso:
- Example:
>>> from aioyookassa.types.params import ( ... CreateSelfEmployedParams, ... SelfEmployedConfirmationData ... ) >>> params = CreateSelfEmployedParams( ... itn="123456789012", ... confirmation=SelfEmployedConfirmationData( ... confirmation_url="https://example.com/confirm" ... ) ... ) >>> self_employed = await client.self_employed.create_self_employed(params)
- async get_self_employed(self_employed_id: str) SelfEmployed[source]¶
Retrieve self-employed information by self-employed ID.
- Parameters:
self_employed_id (str) – Self-employed identifier.
- Returns:
SelfEmployed object.
- Return type:
- Seealso:
Методы¶
create_self_employed¶
Создание нового самозанятого.
from aioyookassa.types.params import (
CreateSelfEmployedParams,
SelfEmployedConfirmationData
)
params = CreateSelfEmployedParams(
itn="123456789012", # ИНН самозанятого (12 цифр)
confirmation=SelfEmployedConfirmationData(
type="redirect",
confirmation_url="https://example.com/confirm"
)
)
self_employed = await client.self_employed.create_self_employed(params)
# Или с телефоном вместо ИНН
params = CreateSelfEmployedParams(
phone="79000000000", # Телефон в формате ITU-T E.164
confirmation=SelfEmployedConfirmationData(
type="redirect",
confirmation_url="https://example.com/confirm"
)
)
self_employed = await client.self_employed.create_self_employed(params)
get_self_employed¶
Получение информации о самозанятом.
self_employed = await client.self_employed.get_self_employed("self_employed_id")
print(f"Status: {self_employed.status}")
print(f"ITN: {self_employed.itn}")
print(f"Phone: {self_employed.phone}")