-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuyers.py
More file actions
111 lines (94 loc) · 3.03 KB
/
buyers.py
File metadata and controls
111 lines (94 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncCreateFileMixin,
AsyncDeleteMixin,
AsyncDisableMixin,
AsyncEnableMixin,
AsyncGetMixin,
AsyncUpdateFileMixin,
CollectionMixin,
CreateFileMixin,
DeleteMixin,
DisableMixin,
EnableMixin,
GetMixin,
UpdateFileMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.models.model import ResourceData
from mpt_api_client.resources.accounts.mixins.activatable_mixin import (
ActivatableMixin,
AsyncActivatableMixin,
)
from mpt_api_client.resources.accounts.mixins.validate_mixin import (
AsyncValidateMixin,
ValidateMixin,
)
class Buyer(Model):
"""Buyer Model."""
class BuyersServiceConfig:
"""Buyers Service Configuration."""
_endpoint = "/public/v1/accounts/buyers"
_model_class = Buyer
_collection_key = "data"
_upload_file_key = "logo"
_upload_data_key = "buyer"
class BuyersService(
CreateFileMixin[Buyer],
UpdateFileMixin[Buyer],
ActivatableMixin[Buyer],
EnableMixin[Buyer],
DisableMixin[Buyer],
ValidateMixin[Buyer],
GetMixin[Buyer],
DeleteMixin,
CollectionMixin[Buyer],
Service[Buyer],
BuyersServiceConfig,
):
"""Buyers Service."""
def synchronize(self, resource_id: str, resource_data: ResourceData | None = None) -> Buyer:
"""Synchronize a buyer.
Args:
resource_id: Resource ID
resource_data: Resource data will be updated
"""
return self._resource_action(resource_id, "POST", "synchronize", json=resource_data)
def transfer(self, resource_id: str, resource_data: ResourceData | None = None) -> Buyer:
"""Transfer a buyer.
Args:
resource_id: Resource ID
resource_data: Resource data will be updated
"""
return self._resource_action(resource_id, "POST", "transfer", json=resource_data)
class AsyncBuyersService(
AsyncCreateFileMixin[Buyer],
AsyncUpdateFileMixin[Buyer],
AsyncActivatableMixin[Buyer],
AsyncEnableMixin[Buyer],
AsyncDisableMixin[Buyer],
AsyncValidateMixin[Buyer],
AsyncGetMixin[Buyer],
AsyncDeleteMixin,
AsyncCollectionMixin[Buyer],
AsyncService[Buyer],
BuyersServiceConfig,
):
"""Async Buyers Service."""
async def synchronize(
self, resource_id: str, resource_data: ResourceData | None = None
) -> Buyer:
"""Synchronize a buyer.
Args:
resource_id: Resource ID
resource_data: Resource data will be updated
"""
return await self._resource_action(resource_id, "POST", "synchronize", json=resource_data)
async def transfer(self, resource_id: str, resource_data: ResourceData | None = None) -> Buyer:
"""Transfer a buyer.
Args:
resource_id: Resource ID
resource_data: Resource data will be updated
"""
return await self._resource_action(resource_id, "POST", "transfer", json=resource_data)