crypticorn 2.4.5__py3-none-any.whl → 2.4.6__py3-none-any.whl

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.
@@ -18,67 +18,35 @@ import re # noqa: F401
18
18
  import json
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional, Union
21
+ from typing import Any, ClassVar, Dict, List, Union
22
+ from crypticorn.pay.client.models.payment_status import PaymentStatus
23
+ from crypticorn.pay.client.models.services import Services
22
24
  from typing import Optional, Set
23
25
  from typing_extensions import Self
24
26
 
25
27
 
26
28
  class Payment(BaseModel):
27
29
  """
28
- Model representing a single payment.
30
+ Combined payment model across all services
29
31
  """ # noqa: E501
30
32
 
31
- payment_id: StrictInt = Field(description="Unique payment identifier")
32
- invoice_id: Optional[StrictInt] = None
33
- payment_status: StrictStr = Field(description="Current payment status")
34
- pay_address: StrictStr = Field(description="Payment destination address")
35
- payin_extra_id: Optional[StrictStr] = None
36
- price_amount: Union[StrictFloat, StrictInt] = Field(
37
- description="Original price amount"
38
- )
39
- price_currency: StrictStr = Field(description="Original price currency")
40
- pay_amount: Union[StrictFloat, StrictInt] = Field(description="Amount to pay")
41
- actually_paid: Union[StrictFloat, StrictInt] = Field(
42
- description="Actually paid amount"
43
- )
44
- pay_currency: StrictStr = Field(description="Payment currency")
45
- order_id: Optional[StrictStr] = None
46
- order_description: Optional[StrictStr] = None
47
- purchase_id: Optional[StrictInt] = None
48
- outcome_amount: Optional[Union[StrictFloat, StrictInt]] = None
49
- outcome_currency: Optional[StrictStr] = None
50
- payout_hash: Optional[StrictStr] = None
51
- payin_hash: Optional[StrictStr] = None
52
- created_at: StrictStr = Field(description="Payment creation timestamp")
53
- updated_at: StrictStr = Field(description="Payment last update timestamp")
54
- type: StrictStr = Field(description="Type of payment (e.g., crypto2crypto)")
55
- payment_extra_ids: Optional[List[StrictInt]] = None
56
- parent_payment_id: Optional[StrictInt] = None
57
- origin_type: Optional[StrictStr] = None
33
+ id: StrictStr = Field(description="Payment ID")
34
+ product_id: StrictStr = Field(description="Product ID")
35
+ var_date: StrictInt = Field(description="Payment date in seconds", alias="date")
36
+ amount: Union[StrictFloat, StrictInt] = Field(description="Payment amount")
37
+ currency: StrictStr = Field(description="Payment currency")
38
+ status: PaymentStatus
39
+ service: Services = Field(description="Payment service")
40
+ market: StrictStr = Field(description="Payment market")
58
41
  __properties: ClassVar[List[str]] = [
59
- "payment_id",
60
- "invoice_id",
61
- "payment_status",
62
- "pay_address",
63
- "payin_extra_id",
64
- "price_amount",
65
- "price_currency",
66
- "pay_amount",
67
- "actually_paid",
68
- "pay_currency",
69
- "order_id",
70
- "order_description",
71
- "purchase_id",
72
- "outcome_amount",
73
- "outcome_currency",
74
- "payout_hash",
75
- "payin_hash",
76
- "created_at",
77
- "updated_at",
78
- "type",
79
- "payment_extra_ids",
80
- "parent_payment_id",
81
- "origin_type",
42
+ "id",
43
+ "product_id",
44
+ "date",
45
+ "amount",
46
+ "currency",
47
+ "status",
48
+ "service",
49
+ "market",
82
50
  ]
83
51
 
84
52
  model_config = ConfigDict(
@@ -118,78 +86,6 @@ class Payment(BaseModel):
118
86
  exclude=excluded_fields,
119
87
  exclude_none=True,
120
88
  )
121
- # set to None if invoice_id (nullable) is None
122
- # and model_fields_set contains the field
123
- if self.invoice_id is None and "invoice_id" in self.model_fields_set:
124
- _dict["invoice_id"] = None
125
-
126
- # set to None if payin_extra_id (nullable) is None
127
- # and model_fields_set contains the field
128
- if self.payin_extra_id is None and "payin_extra_id" in self.model_fields_set:
129
- _dict["payin_extra_id"] = None
130
-
131
- # set to None if order_id (nullable) is None
132
- # and model_fields_set contains the field
133
- if self.order_id is None and "order_id" in self.model_fields_set:
134
- _dict["order_id"] = None
135
-
136
- # set to None if order_description (nullable) is None
137
- # and model_fields_set contains the field
138
- if (
139
- self.order_description is None
140
- and "order_description" in self.model_fields_set
141
- ):
142
- _dict["order_description"] = None
143
-
144
- # set to None if purchase_id (nullable) is None
145
- # and model_fields_set contains the field
146
- if self.purchase_id is None and "purchase_id" in self.model_fields_set:
147
- _dict["purchase_id"] = None
148
-
149
- # set to None if outcome_amount (nullable) is None
150
- # and model_fields_set contains the field
151
- if self.outcome_amount is None and "outcome_amount" in self.model_fields_set:
152
- _dict["outcome_amount"] = None
153
-
154
- # set to None if outcome_currency (nullable) is None
155
- # and model_fields_set contains the field
156
- if (
157
- self.outcome_currency is None
158
- and "outcome_currency" in self.model_fields_set
159
- ):
160
- _dict["outcome_currency"] = None
161
-
162
- # set to None if payout_hash (nullable) is None
163
- # and model_fields_set contains the field
164
- if self.payout_hash is None and "payout_hash" in self.model_fields_set:
165
- _dict["payout_hash"] = None
166
-
167
- # set to None if payin_hash (nullable) is None
168
- # and model_fields_set contains the field
169
- if self.payin_hash is None and "payin_hash" in self.model_fields_set:
170
- _dict["payin_hash"] = None
171
-
172
- # set to None if payment_extra_ids (nullable) is None
173
- # and model_fields_set contains the field
174
- if (
175
- self.payment_extra_ids is None
176
- and "payment_extra_ids" in self.model_fields_set
177
- ):
178
- _dict["payment_extra_ids"] = None
179
-
180
- # set to None if parent_payment_id (nullable) is None
181
- # and model_fields_set contains the field
182
- if (
183
- self.parent_payment_id is None
184
- and "parent_payment_id" in self.model_fields_set
185
- ):
186
- _dict["parent_payment_id"] = None
187
-
188
- # set to None if origin_type (nullable) is None
189
- # and model_fields_set contains the field
190
- if self.origin_type is None and "origin_type" in self.model_fields_set:
191
- _dict["origin_type"] = None
192
-
193
89
  return _dict
194
90
 
195
91
  @classmethod
@@ -203,29 +99,14 @@ class Payment(BaseModel):
203
99
 
204
100
  _obj = cls.model_validate(
205
101
  {
206
- "payment_id": obj.get("payment_id"),
207
- "invoice_id": obj.get("invoice_id"),
208
- "payment_status": obj.get("payment_status"),
209
- "pay_address": obj.get("pay_address"),
210
- "payin_extra_id": obj.get("payin_extra_id"),
211
- "price_amount": obj.get("price_amount"),
212
- "price_currency": obj.get("price_currency"),
213
- "pay_amount": obj.get("pay_amount"),
214
- "actually_paid": obj.get("actually_paid"),
215
- "pay_currency": obj.get("pay_currency"),
216
- "order_id": obj.get("order_id"),
217
- "order_description": obj.get("order_description"),
218
- "purchase_id": obj.get("purchase_id"),
219
- "outcome_amount": obj.get("outcome_amount"),
220
- "outcome_currency": obj.get("outcome_currency"),
221
- "payout_hash": obj.get("payout_hash"),
222
- "payin_hash": obj.get("payin_hash"),
223
- "created_at": obj.get("created_at"),
224
- "updated_at": obj.get("updated_at"),
225
- "type": obj.get("type"),
226
- "payment_extra_ids": obj.get("payment_extra_ids"),
227
- "parent_payment_id": obj.get("parent_payment_id"),
228
- "origin_type": obj.get("origin_type"),
102
+ "id": obj.get("id"),
103
+ "product_id": obj.get("product_id"),
104
+ "date": obj.get("date"),
105
+ "amount": obj.get("amount"),
106
+ "currency": obj.get("currency"),
107
+ "status": obj.get("status"),
108
+ "service": obj.get("service"),
109
+ "market": obj.get("market"),
229
110
  }
230
111
  )
231
112
  return _obj
@@ -0,0 +1,120 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Payment API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import (
21
+ BaseModel,
22
+ ConfigDict,
23
+ Field,
24
+ StrictBool,
25
+ StrictFloat,
26
+ StrictInt,
27
+ StrictStr,
28
+ )
29
+ from typing import Any, ClassVar, Dict, List, Optional, Union
30
+ from crypticorn.pay.client.models.scope import Scope
31
+ from typing import Optional, Set
32
+ from typing_extensions import Self
33
+
34
+
35
+ class ProductCreate(BaseModel):
36
+ """
37
+ Model for creating a product
38
+ """ # noqa: E501
39
+
40
+ name: StrictStr = Field(description="Product name")
41
+ price: Union[StrictFloat, StrictInt] = Field(description="Product price")
42
+ scopes: Optional[List[Scope]] = None
43
+ duration: StrictInt = Field(
44
+ description="Product duration in days. 0 means unlimited."
45
+ )
46
+ description: StrictStr = Field(description="Product description")
47
+ is_active: StrictBool = Field(description="Product is active")
48
+ __properties: ClassVar[List[str]] = [
49
+ "name",
50
+ "price",
51
+ "scopes",
52
+ "duration",
53
+ "description",
54
+ "is_active",
55
+ ]
56
+
57
+ model_config = ConfigDict(
58
+ populate_by_name=True,
59
+ validate_assignment=True,
60
+ protected_namespaces=(),
61
+ )
62
+
63
+ def to_str(self) -> str:
64
+ """Returns the string representation of the model using alias"""
65
+ return pprint.pformat(self.model_dump(by_alias=True))
66
+
67
+ def to_json(self) -> str:
68
+ """Returns the JSON representation of the model using alias"""
69
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
70
+ return json.dumps(self.to_dict())
71
+
72
+ @classmethod
73
+ def from_json(cls, json_str: str) -> Optional[Self]:
74
+ """Create an instance of ProductCreate from a JSON string"""
75
+ return cls.from_dict(json.loads(json_str))
76
+
77
+ def to_dict(self) -> Dict[str, Any]:
78
+ """Return the dictionary representation of the model using alias.
79
+
80
+ This has the following differences from calling pydantic's
81
+ `self.model_dump(by_alias=True)`:
82
+
83
+ * `None` is only added to the output dict for nullable fields that
84
+ were set at model initialization. Other fields with value `None`
85
+ are ignored.
86
+ """
87
+ excluded_fields: Set[str] = set([])
88
+
89
+ _dict = self.model_dump(
90
+ by_alias=True,
91
+ exclude=excluded_fields,
92
+ exclude_none=True,
93
+ )
94
+ # set to None if scopes (nullable) is None
95
+ # and model_fields_set contains the field
96
+ if self.scopes is None and "scopes" in self.model_fields_set:
97
+ _dict["scopes"] = None
98
+
99
+ return _dict
100
+
101
+ @classmethod
102
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
103
+ """Create an instance of ProductCreate from a dict"""
104
+ if obj is None:
105
+ return None
106
+
107
+ if not isinstance(obj, dict):
108
+ return cls.model_validate(obj)
109
+
110
+ _obj = cls.model_validate(
111
+ {
112
+ "name": obj.get("name"),
113
+ "price": obj.get("price"),
114
+ "scopes": obj.get("scopes"),
115
+ "duration": obj.get("duration"),
116
+ "description": obj.get("description"),
117
+ "is_active": obj.get("is_active"),
118
+ }
119
+ )
120
+ return _obj
@@ -0,0 +1,123 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Payment API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import (
21
+ BaseModel,
22
+ ConfigDict,
23
+ Field,
24
+ StrictBool,
25
+ StrictFloat,
26
+ StrictInt,
27
+ StrictStr,
28
+ )
29
+ from typing import Any, ClassVar, Dict, List, Optional, Union
30
+ from crypticorn.pay.client.models.scope import Scope
31
+ from typing import Optional, Set
32
+ from typing_extensions import Self
33
+
34
+
35
+ class ProductRead(BaseModel):
36
+ """
37
+ Model for reading a product
38
+ """ # noqa: E501
39
+
40
+ name: StrictStr = Field(description="Product name")
41
+ price: Union[StrictFloat, StrictInt] = Field(description="Product price")
42
+ scopes: Optional[List[Scope]] = None
43
+ duration: StrictInt = Field(
44
+ description="Product duration in days. 0 means unlimited."
45
+ )
46
+ description: StrictStr = Field(description="Product description")
47
+ is_active: StrictBool = Field(description="Product is active")
48
+ id: StrictStr = Field(description="UID of the product")
49
+ __properties: ClassVar[List[str]] = [
50
+ "name",
51
+ "price",
52
+ "scopes",
53
+ "duration",
54
+ "description",
55
+ "is_active",
56
+ "id",
57
+ ]
58
+
59
+ model_config = ConfigDict(
60
+ populate_by_name=True,
61
+ validate_assignment=True,
62
+ protected_namespaces=(),
63
+ )
64
+
65
+ def to_str(self) -> str:
66
+ """Returns the string representation of the model using alias"""
67
+ return pprint.pformat(self.model_dump(by_alias=True))
68
+
69
+ def to_json(self) -> str:
70
+ """Returns the JSON representation of the model using alias"""
71
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
72
+ return json.dumps(self.to_dict())
73
+
74
+ @classmethod
75
+ def from_json(cls, json_str: str) -> Optional[Self]:
76
+ """Create an instance of ProductRead from a JSON string"""
77
+ return cls.from_dict(json.loads(json_str))
78
+
79
+ def to_dict(self) -> Dict[str, Any]:
80
+ """Return the dictionary representation of the model using alias.
81
+
82
+ This has the following differences from calling pydantic's
83
+ `self.model_dump(by_alias=True)`:
84
+
85
+ * `None` is only added to the output dict for nullable fields that
86
+ were set at model initialization. Other fields with value `None`
87
+ are ignored.
88
+ """
89
+ excluded_fields: Set[str] = set([])
90
+
91
+ _dict = self.model_dump(
92
+ by_alias=True,
93
+ exclude=excluded_fields,
94
+ exclude_none=True,
95
+ )
96
+ # set to None if scopes (nullable) is None
97
+ # and model_fields_set contains the field
98
+ if self.scopes is None and "scopes" in self.model_fields_set:
99
+ _dict["scopes"] = None
100
+
101
+ return _dict
102
+
103
+ @classmethod
104
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
105
+ """Create an instance of ProductRead from a dict"""
106
+ if obj is None:
107
+ return None
108
+
109
+ if not isinstance(obj, dict):
110
+ return cls.model_validate(obj)
111
+
112
+ _obj = cls.model_validate(
113
+ {
114
+ "name": obj.get("name"),
115
+ "price": obj.get("price"),
116
+ "scopes": obj.get("scopes"),
117
+ "duration": obj.get("duration"),
118
+ "description": obj.get("description"),
119
+ "is_active": obj.get("is_active"),
120
+ "id": obj.get("id"),
121
+ }
122
+ )
123
+ return _obj
@@ -0,0 +1,103 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Payment API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+
26
+ class ProductSubRead(BaseModel):
27
+ """
28
+ Model for reading a product subscription
29
+ """ # noqa: E501
30
+
31
+ user_id: StrictStr = Field(description="User ID")
32
+ product_id: StrictStr = Field(description="Product ID")
33
+ access_from: StrictInt = Field(description="Access from timestamp in milliseconds")
34
+ access_until: StrictInt = Field(
35
+ description="Access until timestamp in milliseconds. 0 means unlimited."
36
+ )
37
+ id: StrictStr = Field(description="UID of the product subscription")
38
+ __properties: ClassVar[List[str]] = [
39
+ "user_id",
40
+ "product_id",
41
+ "access_from",
42
+ "access_until",
43
+ "id",
44
+ ]
45
+
46
+ model_config = ConfigDict(
47
+ populate_by_name=True,
48
+ validate_assignment=True,
49
+ protected_namespaces=(),
50
+ )
51
+
52
+ def to_str(self) -> str:
53
+ """Returns the string representation of the model using alias"""
54
+ return pprint.pformat(self.model_dump(by_alias=True))
55
+
56
+ def to_json(self) -> str:
57
+ """Returns the JSON representation of the model using alias"""
58
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
59
+ return json.dumps(self.to_dict())
60
+
61
+ @classmethod
62
+ def from_json(cls, json_str: str) -> Optional[Self]:
63
+ """Create an instance of ProductSubRead from a JSON string"""
64
+ return cls.from_dict(json.loads(json_str))
65
+
66
+ def to_dict(self) -> Dict[str, Any]:
67
+ """Return the dictionary representation of the model using alias.
68
+
69
+ This has the following differences from calling pydantic's
70
+ `self.model_dump(by_alias=True)`:
71
+
72
+ * `None` is only added to the output dict for nullable fields that
73
+ were set at model initialization. Other fields with value `None`
74
+ are ignored.
75
+ """
76
+ excluded_fields: Set[str] = set([])
77
+
78
+ _dict = self.model_dump(
79
+ by_alias=True,
80
+ exclude=excluded_fields,
81
+ exclude_none=True,
82
+ )
83
+ return _dict
84
+
85
+ @classmethod
86
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87
+ """Create an instance of ProductSubRead from a dict"""
88
+ if obj is None:
89
+ return None
90
+
91
+ if not isinstance(obj, dict):
92
+ return cls.model_validate(obj)
93
+
94
+ _obj = cls.model_validate(
95
+ {
96
+ "user_id": obj.get("user_id"),
97
+ "product_id": obj.get("product_id"),
98
+ "access_from": obj.get("access_from"),
99
+ "access_until": obj.get("access_until"),
100
+ "id": obj.get("id"),
101
+ }
102
+ )
103
+ return _obj
@@ -0,0 +1,142 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Payment API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import (
21
+ BaseModel,
22
+ ConfigDict,
23
+ StrictBool,
24
+ StrictFloat,
25
+ StrictInt,
26
+ StrictStr,
27
+ )
28
+ from typing import Any, ClassVar, Dict, List, Optional, Union
29
+ from crypticorn.pay.client.models.scope import Scope
30
+ from typing import Optional, Set
31
+ from typing_extensions import Self
32
+
33
+
34
+ class ProductUpdate(BaseModel):
35
+ """
36
+ Model for updating a product
37
+ """ # noqa: E501
38
+
39
+ name: Optional[StrictStr] = None
40
+ price: Optional[Union[StrictFloat, StrictInt]] = None
41
+ scopes: Optional[List[Scope]] = None
42
+ duration: Optional[StrictInt] = None
43
+ description: Optional[StrictStr] = None
44
+ is_active: Optional[StrictBool] = None
45
+ __properties: ClassVar[List[str]] = [
46
+ "name",
47
+ "price",
48
+ "scopes",
49
+ "duration",
50
+ "description",
51
+ "is_active",
52
+ ]
53
+
54
+ model_config = ConfigDict(
55
+ populate_by_name=True,
56
+ validate_assignment=True,
57
+ protected_namespaces=(),
58
+ )
59
+
60
+ def to_str(self) -> str:
61
+ """Returns the string representation of the model using alias"""
62
+ return pprint.pformat(self.model_dump(by_alias=True))
63
+
64
+ def to_json(self) -> str:
65
+ """Returns the JSON representation of the model using alias"""
66
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
67
+ return json.dumps(self.to_dict())
68
+
69
+ @classmethod
70
+ def from_json(cls, json_str: str) -> Optional[Self]:
71
+ """Create an instance of ProductUpdate from a JSON string"""
72
+ return cls.from_dict(json.loads(json_str))
73
+
74
+ def to_dict(self) -> Dict[str, Any]:
75
+ """Return the dictionary representation of the model using alias.
76
+
77
+ This has the following differences from calling pydantic's
78
+ `self.model_dump(by_alias=True)`:
79
+
80
+ * `None` is only added to the output dict for nullable fields that
81
+ were set at model initialization. Other fields with value `None`
82
+ are ignored.
83
+ """
84
+ excluded_fields: Set[str] = set([])
85
+
86
+ _dict = self.model_dump(
87
+ by_alias=True,
88
+ exclude=excluded_fields,
89
+ exclude_none=True,
90
+ )
91
+ # set to None if name (nullable) is None
92
+ # and model_fields_set contains the field
93
+ if self.name is None and "name" in self.model_fields_set:
94
+ _dict["name"] = None
95
+
96
+ # set to None if price (nullable) is None
97
+ # and model_fields_set contains the field
98
+ if self.price is None and "price" in self.model_fields_set:
99
+ _dict["price"] = None
100
+
101
+ # set to None if scopes (nullable) is None
102
+ # and model_fields_set contains the field
103
+ if self.scopes is None and "scopes" in self.model_fields_set:
104
+ _dict["scopes"] = None
105
+
106
+ # set to None if duration (nullable) is None
107
+ # and model_fields_set contains the field
108
+ if self.duration is None and "duration" in self.model_fields_set:
109
+ _dict["duration"] = None
110
+
111
+ # set to None if description (nullable) is None
112
+ # and model_fields_set contains the field
113
+ if self.description is None and "description" in self.model_fields_set:
114
+ _dict["description"] = None
115
+
116
+ # set to None if is_active (nullable) is None
117
+ # and model_fields_set contains the field
118
+ if self.is_active is None and "is_active" in self.model_fields_set:
119
+ _dict["is_active"] = None
120
+
121
+ return _dict
122
+
123
+ @classmethod
124
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
125
+ """Create an instance of ProductUpdate from a dict"""
126
+ if obj is None:
127
+ return None
128
+
129
+ if not isinstance(obj, dict):
130
+ return cls.model_validate(obj)
131
+
132
+ _obj = cls.model_validate(
133
+ {
134
+ "name": obj.get("name"),
135
+ "price": obj.get("price"),
136
+ "scopes": obj.get("scopes"),
137
+ "duration": obj.get("duration"),
138
+ "description": obj.get("description"),
139
+ "is_active": obj.get("is_active"),
140
+ }
141
+ )
142
+ return _obj