xync-schema 0.6.68__tar.gz → 0.6.70__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: xync-schema
3
- Version: 0.6.68
3
+ Version: 0.6.70
4
4
  Summary: XyncNet project database model schema
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: EULA
@@ -112,8 +112,9 @@ class ExAction(IntEnum):
112
112
  coins = 22 # Список торгуемых монет (с ограничениям по валютам, если есть)
113
113
  pairs = 23 # Список пар валюта/монет
114
114
  ads = 24 # Список объяв по покупке/продаже, валюте, монете, платежному методу (buy/sell, cur, coin, pm)
115
- cur_mins = 42 # Минимальные объемы валют в объявлении
116
- coin_mins = 43 # Минимальные объемы монет в объявлении
115
+ ad = 42 # Объява по id
116
+ cur_mins = 43 # Минимальные объемы валют в объявлении
117
+ coin_mins = 44 # Минимальные объемы монет в объявлении
117
118
  """ Agent: Fiat """
118
119
  my_fiats = 25 # Список реквизитов моих платежных методов
119
120
  fiat_new = 26 # Создание реквизита моего платежного метода
@@ -26,7 +26,7 @@ from xync_schema.enums import ExType, AdStatus, AssetType, OrderStatus, ExAction
26
26
  class Cur(Model):
27
27
  id = fields.SmallIntField(True)
28
28
  ticker: str = fields.CharField(3, unique=True)
29
- rate: float | None = fields.FloatField(default=0)
29
+ rate: float | None = fields.FloatField(default=0, null=True)
30
30
  # country: str | None = fields.CharField(63, null=True)
31
31
 
32
32
  pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="pmcur")
@@ -84,11 +84,11 @@ class Ex(Model):
84
84
  class PydanticMeta(Model.PydanticMeta):
85
85
  include = "name", "logo"
86
86
 
87
- def client(self):
87
+ def client(self, agent: "Agent" = None):
88
88
  module_name = f"xync_client.{self.name}.ex"
89
89
  __import__(module_name)
90
90
  client = sys.modules[module_name].ExClient
91
- return client(self)
91
+ return client(self, agent)
92
92
 
93
93
 
94
94
  class Curex(BaseModel):
@@ -96,6 +96,7 @@ class Curex(BaseModel):
96
96
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
97
97
  exid: str = fields.CharField(31)
98
98
  minimum: float = fields.FloatField(null=True)
99
+ rounding_scale: int = fields.SmallIntField(null=True)
99
100
  # countries: fields.ManyToManyRelation[Country] = fields.ManyToManyField(
100
101
  # "models.Country", through="curexcountry", backward_key="curexs"
101
102
  # )
@@ -248,6 +249,16 @@ class Adpm(Model):
248
249
  table_description = "P2P Advertisements - Payment methods"
249
250
 
250
251
 
252
+ class Adfiat(Model):
253
+ ad: fields.ForeignKeyRelation["Ad"] = fields.ForeignKeyField("models.Ad")
254
+ fiat: fields.ForeignKeyRelation["Fiat"] = fields.ForeignKeyField("models.Fiat")
255
+
256
+ _name = {"ad__id", "fiat__id"}
257
+
258
+ class Meta:
259
+ table_description = "P2P Advertisements - Payment details"
260
+
261
+
251
262
  class Ad(Model, TsTrait):
252
263
  id: int = fields.BigIntField(True)
253
264
  direction: fields.ForeignKeyRelation[Direction] = fields.ForeignKeyField("models.Direction", related_name="ads")
@@ -3,7 +3,15 @@ from datetime import datetime
3
3
  from pydantic import BaseModel, model_validator
4
4
 
5
5
  from xync_schema.enums import AdStatus, PmType
6
- from xync_schema.models import Fiat, Agent, Direction, Pm, Pmcur, User
6
+ from xync_schema.models import Fiat, Agent, Direction, Pmcur, User, Ex
7
+
8
+
9
+ class CurEpyd(BaseModel):
10
+ exid: int | str
11
+ ticker: str
12
+ rate: float | None = None
13
+ minimum: int | None = None
14
+ rounding_scale: int | None = None
7
15
 
8
16
 
9
17
  class PmexBankPyd(BaseModel):
@@ -65,7 +73,7 @@ class FiatPydIn(BaseModel):
65
73
  def check_at_least_one_field(cls, values):
66
74
  if (values.get("pmcur") or values.get("pmcur_id")) and (values.get("user") or values.get("user_id")):
67
75
  return values
68
- raise ValueError("pmcur_id or pmcur is required")
76
+ raise ValueError("pmcur(_id) and user(_id) is required")
69
77
 
70
78
  def args(self) -> tuple[dict, dict]:
71
79
  unq: tuple[str, ...] = "id", "user_id", "user", "pmcur_id", "pmcur"
@@ -74,18 +82,31 @@ class FiatPydIn(BaseModel):
74
82
  return {k: getattr(self, k) for k in df if d.get(k)}, {k: getattr(self, k) for k in unq if d.get(k)}
75
83
 
76
84
 
77
- # class FiatexPyd(BaseModel):
78
- # id: int | None = None
79
- # exid: str
80
- # ex_id: int
81
- # fiat_id: int
85
+ class FiatexPydIn(BaseModel):
86
+ id: int | None = None
87
+ exid: str
88
+ ex: Ex | None = None
89
+ ex_id: int | None = None
90
+ fiat: Fiat | None = None
91
+ fiat_id: int | None = None
82
92
 
93
+ class Config:
94
+ arbitrary_types_allowed = True
83
95
 
84
- class AdPydIn(BaseModel):
85
- # unq
86
- id: int
87
- # df
96
+ @classmethod
97
+ @model_validator(mode="before")
98
+ def check_at_least_one_field(cls, values):
99
+ if (values.get("ex") or values.get("ex_id")) and (values.get("fiat") or values.get("fiat_id")):
100
+ return values
101
+ raise ValueError("ex(_id) and fiat(_id) is required")
102
+
103
+
104
+ class BaseAd(BaseModel):
105
+ id: int | None = None
88
106
  price: float
107
+
108
+
109
+ class AdPydIn(BaseAd):
89
110
  min_fiat: float
90
111
  max_fiat: float | None = None
91
112
  detail: str | None = None
@@ -95,7 +116,8 @@ class AdPydIn(BaseModel):
95
116
  direction_id: int | None = None
96
117
  agent: Agent | None = None
97
118
  direction: Direction | None = None
98
- payMeths: list[Pm]
119
+ pms_: list | None = None
120
+ fiats_: list | None = None
99
121
 
100
122
  class Config:
101
123
  arbitrary_types_allowed = True
@@ -103,9 +125,12 @@ class AdPydIn(BaseModel):
103
125
  @classmethod
104
126
  @model_validator(mode="before")
105
127
  def check_at_least_one_field(cls, values):
106
- if (values.get("agent") or values.get("agent_id")) and (values.get("direction") or values.get("direction_id")):
128
+ agent = values.get("agent") or values.get("agent_id")
129
+ direction = values.get("direction") or values.get("direction_id")
130
+ pms_or_fiats = values.get("pms_") or values.get("fiats_")
131
+ if agent and direction and pms_or_fiats:
107
132
  return values
108
- raise ValueError("pmcur_id or pmcur is required")
133
+ raise ValueError("(pms or fiats) and agent(_id) and direction(_id) is required")
109
134
 
110
135
 
111
136
  class OrderPyd(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: xync-schema
3
- Version: 0.6.68
3
+ Version: 0.6.70
4
4
  Summary: XyncNet project database model schema
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: EULA
File without changes
File without changes
File without changes
File without changes
File without changes