sysnet-pyutils 1.2.4__py3-none-any.whl → 1.2.5__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.
@@ -1,11 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
+ import pprint
4
5
  from datetime import datetime
5
6
  from enum import Enum
6
- from typing import Optional, List, Tuple, Any
7
+ from typing import Optional, List, Tuple, Any, ClassVar, Dict
7
8
 
8
- from pydantic import BaseModel, Field, EmailStr
9
+ from pydantic import BaseModel, Field, EmailStr, StrictStr
9
10
  from typing_extensions import Self
10
11
 
11
12
  from sysnet_pyutils.utils import local_now, is_valid_unid, is_valid_pid, is_valid_uuid
@@ -74,7 +75,13 @@ class AclLevelEnum(BaseEnum):
74
75
 
75
76
  class PersonTypeEnum(BaseEnum):
76
77
  """
77
- Typ osoby (zdroj CRŽP): - legalEntity: tuzemská právnická osoba - legalEntityWithoutIco: tuzemská právnická osoba bez IČO - foreignLegalEntity: zahraniční právnická osoba - businessNaturalPerson: tuzemská fyzická osoba podnikající - naturalPerson: tuzemská fyzická osoba nepodnikající - foreignNaturalPerson: zahraniční fyzická osoba podnikající
78
+ Typ osoby (zdroj CRŽP):
79
+ - legalEntity: tuzemská právnická osoba
80
+ - legalEntityWithoutIco: tuzemská právnická osoba bez IČO
81
+ - foreignLegalEntity: zahraniční právnická osoba
82
+ - businessNaturalPerson: tuzemská fyzická osoba podnikající
83
+ - naturalPerson: tuzemská fyzická osoba nepodnikající
84
+ - foreignNaturalPerson: zahraniční fyzická osoba podnikající
78
85
  """
79
86
  LEGAL_ENTITY = 'legalEntity'
80
87
  LEGAL_ENTITY_WO_ICO = 'legalEntityWithoutIco'
@@ -315,3 +322,155 @@ class WorkflowType(BaseModel):
315
322
  status_to: Optional[str] = Field(default=None, description='Následný stav')
316
323
 
317
324
 
325
+ class PhoneNumberType(BaseModel):
326
+ """
327
+ Telefonní číslo
328
+ """ # noqa: E501
329
+ name: Optional[StrictStr] = Field(default=None, description="Název telefonního čísla (mobil, práce, domů)")
330
+ prefix: Optional[StrictStr] = Field(default=None, description="Národní prefix")
331
+ number: Optional[StrictStr] = Field(default=None, description="Vlastní telefonní číslo")
332
+ __properties: ClassVar[List[str]] = ["name", "prefix", "number"]
333
+
334
+ model_config = {
335
+ "populate_by_name": True,
336
+ "validate_assignment": True,
337
+ "protected_namespaces": (),
338
+ }
339
+
340
+
341
+ def to_str(self) -> str:
342
+ """Returns the string representation of the model using alias"""
343
+ return pprint.pformat(self.model_dump(by_alias=True))
344
+
345
+ def to_json(self) -> str:
346
+ """Returns the JSON representation of the model using alias"""
347
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
348
+ return json.dumps(self.to_dict())
349
+
350
+ @classmethod
351
+ def from_json(cls, json_str: str) -> Self:
352
+ """Create an instance of PhoneNumberType from a JSON string"""
353
+ return cls.from_dict(json.loads(json_str))
354
+
355
+ def to_dict(self) -> Dict[str, Any]:
356
+ """Return the dictionary representation of the model using alias.
357
+
358
+ This has the following differences from calling pydantic's
359
+ `self.model_dump(by_alias=True)`:
360
+
361
+ * `None` is only added to the output dict for nullable fields that
362
+ were set at model initialization. Other fields with value `None`
363
+ are ignored.
364
+ """
365
+ _dict = self.model_dump(
366
+ by_alias=True,
367
+ exclude={
368
+ },
369
+ exclude_none=True,
370
+ )
371
+ # set to None if name (nullable) is None
372
+ # and model_fields_set contains the field
373
+ if self.name is None and "name" in self.model_fields_set:
374
+ _dict['name'] = None
375
+
376
+ # set to None if prefix (nullable) is None
377
+ # and model_fields_set contains the field
378
+ if self.prefix is None and "prefix" in self.model_fields_set:
379
+ _dict['prefix'] = None
380
+
381
+ # set to None if number (nullable) is None
382
+ # and model_fields_set contains the field
383
+ if self.number is None and "number" in self.model_fields_set:
384
+ _dict['number'] = None
385
+
386
+ return _dict
387
+
388
+ @classmethod
389
+ def from_dict(cls, obj: Dict) -> Self:
390
+ """Create an instance of PhoneNumberType from a dict"""
391
+ if obj is None:
392
+ return None
393
+
394
+ if not isinstance(obj, dict):
395
+ return cls.model_validate(obj)
396
+
397
+ _obj = cls.model_validate({
398
+ "name": obj.get("name"),
399
+ "prefix": obj.get("prefix"),
400
+ "number": obj.get("number")
401
+ })
402
+ return _obj
403
+
404
+
405
+ class MailAddressType(BaseModel):
406
+ """
407
+ Adresa elektronické pošty
408
+ """ # noqa: E501
409
+ name: Optional[StrictStr] = Field(default=None, description="Název adresa elektronické pošty (práce, domů)")
410
+ email: Optional[StrictStr] = Field(default=None, description="Adresa elektronické pošty")
411
+ __properties: ClassVar[List[str]] = ["name", "email"]
412
+
413
+ model_config = {
414
+ "populate_by_name": True,
415
+ "validate_assignment": True,
416
+ "protected_namespaces": (),
417
+ }
418
+
419
+
420
+ def to_str(self) -> str:
421
+ """Returns the string representation of the model using alias"""
422
+ return pprint.pformat(self.model_dump(by_alias=True))
423
+
424
+ def to_json(self) -> str:
425
+ """Returns the JSON representation of the model using alias"""
426
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
427
+ return json.dumps(self.to_dict())
428
+
429
+ @classmethod
430
+ def from_json(cls, json_str: str) -> Self:
431
+ """Create an instance of MailAddressType from a JSON string"""
432
+ return cls.from_dict(json.loads(json_str))
433
+
434
+ def to_dict(self) -> Dict[str, Any]:
435
+ """Return the dictionary representation of the model using alias.
436
+
437
+ This has the following differences from calling pydantic's
438
+ `self.model_dump(by_alias=True)`:
439
+
440
+ * `None` is only added to the output dict for nullable fields that
441
+ were set at model initialization. Other fields with value `None`
442
+ are ignored.
443
+ """
444
+ _dict = self.model_dump(
445
+ by_alias=True,
446
+ exclude={
447
+ },
448
+ exclude_none=True,
449
+ )
450
+ # set to None if name (nullable) is None
451
+ # and model_fields_set contains the field
452
+ if self.name is None and "name" in self.model_fields_set:
453
+ _dict['name'] = None
454
+
455
+ # set to None if email (nullable) is None
456
+ # and model_fields_set contains the field
457
+ if self.email is None and "email" in self.model_fields_set:
458
+ _dict['email'] = None
459
+
460
+ return _dict
461
+
462
+ @classmethod
463
+ def from_dict(cls, obj: Dict) -> Self:
464
+ """Create an instance of MailAddressType from a dict"""
465
+ if obj is None:
466
+ return None
467
+
468
+ if not isinstance(obj, dict):
469
+ return cls.model_validate(obj)
470
+
471
+ _obj = cls.model_validate({
472
+ "name": obj.get("name"),
473
+ "email": obj.get("email")
474
+ })
475
+ return _obj
476
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sysnet-pyutils
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: Python Utilities
5
5
  Author-email: Data Developer <info@sysnet.cz>
6
6
  Project-URL: Homepage, https://github.com/SYSNET-CZ/pyutils
@@ -9,9 +9,9 @@ sysnet_pyutils/ses.py,sha256=WJzs0y2QnF4XGDGjls_W0p0v6DJ4fZ4_97m3XbzpaFw,2713
9
9
  sysnet_pyutils/tools.py,sha256=ZioHvUIufrhuJyZLdPnuMUD8Li5LTljSMSCxqRnKIi4,377
10
10
  sysnet_pyutils/utils.py,sha256=4dOqlP8JhKaIzWlbYw4PLckBf1SigBJK-MzK1EWTgYk,23523
11
11
  sysnet_pyutils/models/__init__.py,sha256=oozOr_DKhenkM9BDaPOmtbLXhP5vtMUCjBPEjZDW4GQ,167
12
- sysnet_pyutils/models/general.py,sha256=N3meFkl5v3wxEkP9jOy-leOobRhfhKDKgzu2b0BCmrc,17228
13
- sysnet_pyutils-1.2.4.dist-info/licenses/LICENSE,sha256=bx5iLIKjgAdYQ7sISn7DsfHRKkoCUm1154sJJKhgqnU,35184
14
- sysnet_pyutils-1.2.4.dist-info/METADATA,sha256=ZxxTqw45stJQZY4tP1hiB2E5_zDwNHJMkQPvgcX9txM,15747
15
- sysnet_pyutils-1.2.4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
16
- sysnet_pyutils-1.2.4.dist-info/top_level.txt,sha256=ZKTltQWbLlWBXw4oovo1w7ui-JQ1WoyECqMSWdBj6XE,15
17
- sysnet_pyutils-1.2.4.dist-info/RECORD,,
12
+ sysnet_pyutils/models/general.py,sha256=ZN7DUM_1Pnu--Rre22qqrygWnD_RAxR-gEn5a-hIs4k,22588
13
+ sysnet_pyutils-1.2.5.dist-info/licenses/LICENSE,sha256=bx5iLIKjgAdYQ7sISn7DsfHRKkoCUm1154sJJKhgqnU,35184
14
+ sysnet_pyutils-1.2.5.dist-info/METADATA,sha256=RPOygEMyUmGgzJiYkvzGuZu4C2pAUvumB6IkRH7KdnI,15747
15
+ sysnet_pyutils-1.2.5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
16
+ sysnet_pyutils-1.2.5.dist-info/top_level.txt,sha256=ZKTltQWbLlWBXw4oovo1w7ui-JQ1WoyECqMSWdBj6XE,15
17
+ sysnet_pyutils-1.2.5.dist-info/RECORD,,