masstack-python-client 0.0.2__tar.gz → 0.0.4__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.
Files changed (46) hide show
  1. {masstack_python_client-0.0.2/src/masstack_python_client.egg-info → masstack_python_client-0.0.4}/PKG-INFO +12 -1
  2. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/README.md +11 -0
  3. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/__init__.py +1 -1
  4. masstack_python_client-0.0.4/src/masstack_python_client/resources/catalogue.py +110 -0
  5. masstack_python_client-0.0.4/src/masstack_python_client/resources/customers.py +106 -0
  6. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/__init__.py +0 -0
  7. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/bundled_product_category.py +12 -0
  8. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/commercial_segment_name.py +6 -0
  9. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/customer_segment_name.py +8 -0
  10. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/customer_type_name.py +6 -0
  11. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/document_type_search.py +9 -0
  12. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/sale_type_name.py +9 -0
  13. masstack_python_client-0.0.4/src/masstack_python_client/resources/enums/technology_name.py +6 -0
  14. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/bundled.py +58 -0
  15. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/client_address.py +11 -0
  16. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/client_attribute.py +27 -0
  17. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/client_payment.py +14 -0
  18. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/products.py +90 -0
  19. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/signup.py +78 -0
  20. masstack_python_client-0.0.4/src/masstack_python_client/resources/models/user.py +42 -0
  21. masstack_python_client-0.0.4/src/masstack_python_client/resources/utils/serialize.py +7 -0
  22. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4/src/masstack_python_client.egg-info}/PKG-INFO +12 -1
  23. masstack_python_client-0.0.4/src/masstack_python_client.egg-info/SOURCES.txt +43 -0
  24. masstack_python_client-0.0.2/src/masstack_python_client.egg-info/SOURCES.txt +0 -25
  25. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/LICENSE +0 -0
  26. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/MANIFEST.in +0 -0
  27. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/pyproject.toml +0 -0
  28. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/setup.cfg +0 -0
  29. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/auth/__init__.py +0 -0
  30. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/auth/token.py +0 -0
  31. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/auth/token_manager.py +0 -0
  32. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/auth/token_store.py +0 -0
  33. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/client.py +0 -0
  34. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/data/data_utils.py +0 -0
  35. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/data/province_translation.csv +0 -0
  36. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/data/street_type_translation.csv +0 -0
  37. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/data/unit_translation.csv +0 -0
  38. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/exceptions.py +0 -0
  39. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/resources/__init__.py +0 -0
  40. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/resources/feasibility.py +0 -0
  41. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client/resources/models/address.py +0 -0
  42. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client.egg-info/dependency_links.txt +0 -0
  43. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client.egg-info/requires.txt +0 -0
  44. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/src/masstack_python_client.egg-info/top_level.txt +0 -0
  45. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/tests/test_client.py +0 -0
  46. {masstack_python_client-0.0.2 → masstack_python_client-0.0.4}/tests/test_exceptions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: masstack-python-client
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: This Python API client provides access to masmovil core API domains
5
5
  Author-email: Borja Gimeno <borja.gimeno@somconnexio.coop>
6
6
  License: GPL-3.0-only
@@ -38,6 +38,17 @@ This Python API client provides access to masmovil core API domains.
38
38
  - get: returns a unit by id with a list of coverages
39
39
  - get_coverage: returns coverage info for a unit id and territory_owner
40
40
 
41
+ * Customers
42
+ - Signups - access to signups new clients
43
+ - post new client
44
+ - Users
45
+ - returns customer tree data associated to a given document identification, email or number of the client.
46
+ - returns user data by userId
47
+
48
+ * Catalogue
49
+ - bundled_products - access to bundled products
50
+ - get sellable bundled products
51
+
41
52
  ## Installation
42
53
 
43
54
  ```commandline
@@ -21,6 +21,17 @@ This Python API client provides access to masmovil core API domains.
21
21
  - get: returns a unit by id with a list of coverages
22
22
  - get_coverage: returns coverage info for a unit id and territory_owner
23
23
 
24
+ * Customers
25
+ - Signups - access to signups new clients
26
+ - post new client
27
+ - Users
28
+ - returns customer tree data associated to a given document identification, email or number of the client.
29
+ - returns user data by userId
30
+
31
+ * Catalogue
32
+ - bundled_products - access to bundled products
33
+ - get sellable bundled products
34
+
24
35
  ## Installation
25
36
 
26
37
  ```commandline
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.2"
1
+ __version__ = "0.0.4"
2
2
  __homepage__ = "https://somconnexio.coop/"
3
3
  __author__ = "Borja Gimeno <borja.gimeno@somconnexio.coop>"
4
4
  __license__ = "GPL-3.0-only"
@@ -0,0 +1,110 @@
1
+ from typing import Optional, List
2
+ from masstack_python_client.client import MasstackClient
3
+ from masstack_python_client.resources.enums.bundled_product_category import (
4
+ BundleCategory,
5
+ )
6
+ from masstack_python_client.resources.enums.commercial_segment_name import (
7
+ CommercialSegmentName,
8
+ )
9
+ from masstack_python_client.resources.enums.customer_segment_name import (
10
+ CustomerSegmentName,
11
+ )
12
+ from masstack_python_client.resources.enums.customer_type_name import CustomerTypeName
13
+ from masstack_python_client.resources.enums.sale_type_name import SaleTypeName
14
+ from masstack_python_client.resources.enums.technology_name import TechnologyName
15
+ from masstack_python_client.resources.models.bundled import BundledProduct
16
+
17
+
18
+ class CatalogueResource:
19
+ """Support sales and post-sales operations from catalogue perspective
20
+ https://developers.masstack.com/en/docs/apis_catalogue_doc_swagger/2/apioverview/
21
+ """
22
+
23
+ _api_domain = "catalogue"
24
+
25
+
26
+ class BundledProducts(CatalogueResource):
27
+ _api_path = "bundled_products"
28
+ _version = "v2"
29
+
30
+ @classmethod
31
+ def _get_endpoint(cls, subpath: str) -> str:
32
+ return f"{cls._api_path}/{subpath}"
33
+
34
+ @classmethod
35
+ def _request(
36
+ cls,
37
+ method: str,
38
+ subpath: str,
39
+ params: Optional[dict] = None,
40
+ data: Optional[dict] = None,
41
+ ) -> dict:
42
+ client = MasstackClient()
43
+ func = getattr(client, method)
44
+
45
+ return func(
46
+ api=cls._api_domain,
47
+ version=cls._version,
48
+ endpoint=cls._get_endpoint(subpath),
49
+ params=params,
50
+ data=data,
51
+ )
52
+
53
+
54
+ class Sellable(BundledProducts):
55
+
56
+ _api_subpath = "sellable"
57
+
58
+ @classmethod
59
+ def get(
60
+ cls,
61
+ commercial_profile_name: Optional[str] = None,
62
+ technology_name: Optional[TechnologyName] = None,
63
+ territory_owner_id: Optional[str] = None,
64
+ category: Optional[BundleCategory] = None,
65
+ customer_segment_name: Optional[CustomerSegmentName] = None,
66
+ commercial_segment_name: Optional[CommercialSegmentName] = None,
67
+ customer_type_name: Optional[CustomerTypeName] = None,
68
+ sale_type_name: Optional[SaleTypeName] = None,
69
+ ) -> List[BundledProduct]:
70
+ """Returns an array of sellable bundled products based on input criteria,
71
+ including the mandatory bundled commercial products for each bundled product.
72
+ Provides details for each bundled commercial product about the marketing name.
73
+
74
+ Args:
75
+ commercial_profile_name (str): commercial profile name
76
+ technology_name (TechnologyName): technology name
77
+ territory_owner_id (str): territory owner identifier
78
+ category (BundleCategory): bundled product category
79
+ customer_segment_name (CustomerSegmentName): customer segment name
80
+ commercial_segment_name(CommercialSegmentName): SmallMediumEnterprise or Consumer
81
+ customer_type_name(CustomerTypeName): customer type name
82
+ sale_type_name(SaleTypeName): sale type name
83
+
84
+ Returns:
85
+ BundledProduct
86
+
87
+ """
88
+ params = {
89
+ "commercial_profile_name": commercial_profile_name,
90
+ "technology_name": technology_name,
91
+ "territory_owner_id": territory_owner_id,
92
+ "category": category,
93
+ "customer_segment_name": customer_segment_name,
94
+ "commercial_segment_name": commercial_segment_name,
95
+ "customer_type_name": customer_type_name,
96
+ "sale_type_name": sale_type_name,
97
+ }
98
+ sellable_bundled_products = cls._request(
99
+ "get",
100
+ cls._api_subpath,
101
+ {
102
+ k: (v.value if hasattr(v, "value") else v)
103
+ for k, v in params.items()
104
+ if v is not None
105
+ },
106
+ )
107
+ return [
108
+ BundledProduct.from_dict(**sellable_bundled_product)
109
+ for sellable_bundled_product in sellable_bundled_products
110
+ ]
@@ -0,0 +1,106 @@
1
+ from typing import Optional
2
+ from dataclasses import asdict
3
+
4
+ from masstack_python_client.client import MasstackClient
5
+ from masstack_python_client.resources.enums.document_type_search import (
6
+ DocumentTypeSearch,
7
+ )
8
+ from masstack_python_client.resources.models.signup import (
9
+ SignupRequestData,
10
+ SignupsResponseData,
11
+ )
12
+ from masstack_python_client.resources.models.user import UserData
13
+ from masstack_python_client.resources.utils.serialize import remove_none
14
+
15
+
16
+ class CustomersResource:
17
+ """Provide the necessary functionality to be able to give
18
+ E2E coverage to the entire life-cycle of a client
19
+ https://developers.masstack.com/en/docs/apis_customers_doc_swagger/2/apioverview
20
+ """
21
+
22
+ _api_domain = "customers"
23
+
24
+ @classmethod
25
+ def _request(
26
+ cls,
27
+ method: str,
28
+ endpoint: str,
29
+ params: Optional[dict] = None,
30
+ data: Optional[dict] = None,
31
+ ) -> dict:
32
+ client = MasstackClient()
33
+ func = getattr(client, method)
34
+
35
+ return func(
36
+ api=cls._api_domain,
37
+ version=cls._version,
38
+ endpoint=endpoint,
39
+ params=params,
40
+ data=data,
41
+ )
42
+
43
+
44
+ class SignupsResource(CustomersResource):
45
+ _api_path = "signups"
46
+ _version = "v2"
47
+
48
+ @classmethod
49
+ def add_customer(cls, customer_data: SignupRequestData) -> SignupsResponseData:
50
+ """Add new customers including products purchased.
51
+
52
+ Args:
53
+ customer_data (SignupRequestData): The data of the customer to be added.
54
+
55
+ Returns:
56
+ SignupsResponseData
57
+ """
58
+ payload = remove_none(asdict(customer_data))
59
+ result = cls._request(
60
+ method="post",
61
+ endpoint=cls._api_path,
62
+ data=payload,
63
+ )
64
+
65
+ return SignupsResponseData(
66
+ sell_id=result["sell_id"],
67
+ customer_id=result["customer_id"],
68
+ work_order_id=[result["work_order_id"]],
69
+ )
70
+
71
+
72
+ class Users(CustomersResource):
73
+ _api_path = "users"
74
+ _version = "v2"
75
+
76
+ @classmethod
77
+ def get_user_id_by_doc(cls, doc: str, doc_type: DocumentTypeSearch) -> str:
78
+ """
79
+ Get user ID associated to a given document identification
80
+
81
+ Args:
82
+ doc (str): The user's document number.
83
+ doc_type (DocumentTypeSearch): The type of document.
84
+
85
+ Returns:
86
+ user id.
87
+ """
88
+ data = {"document_type": doc_type.value, "document": doc}
89
+
90
+ return cls._request(method="post", endpoint=f"{cls._api_path}/tree", data=data)[
91
+ "id"
92
+ ]
93
+
94
+ @classmethod
95
+ def get_user_by_id(cls, user_id: str) -> dict:
96
+ """
97
+ Get user information by user ID
98
+
99
+ Args:
100
+ user_id (str): The user's ID.
101
+
102
+ Returns:
103
+ UserData
104
+ """
105
+ user = cls._request(method="get", endpoint=f"{cls._api_path}/{user_id}")
106
+ return UserData.from_dict(**user)
@@ -0,0 +1,12 @@
1
+ from enum import Enum
2
+
3
+
4
+ class BundleCategory(Enum):
5
+ MOBILE = "Mobile"
6
+ TV = "TV"
7
+ FIXED_BROADBAND = "Fixed+Broadband"
8
+ FIXED_MOBILE = "Fixed+Mobile"
9
+ FIXED_BROADBAND_MOBILE = "Fixed+Broadband+Mobile"
10
+ FIXED_BROADBAND_TV = "Fixed+Broadband+TV"
11
+ FIXED_BROADBAND_MOBILE_NTX = "Fixed+Broadband+Mobile+Netflix"
12
+ FIXED_BROADBAND_MOBILE_TV = "Fixed+Broadband+Mobile+TV"
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class CommercialSegmentName(Enum):
5
+ SME = "SME"
6
+ CONSUMER = "Consumer"
@@ -0,0 +1,8 @@
1
+ from enum import Enum
2
+
3
+
4
+ class CustomerSegmentName(Enum):
5
+ RESIDENTIAL = "RESIDENCIAL"
6
+ COMPANY = "EMPRESA"
7
+ AUTONOMOUS = "AUTONOMO"
8
+ HORECA = "HORECA"
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class CustomerTypeName(Enum):
5
+ NEW = "Nuevo"
6
+ EXISTING = "Existente"
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class DocumentTypeSearch(Enum):
5
+ NIF = "NIF"
6
+ DNI = "DNI"
7
+ TR = "TR"
8
+ PASS = "PASS"
9
+ CIF = "CIF"
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class SaleTypeName(Enum):
5
+ SALE = "Venta"
6
+ MIGRATION = "Migración"
7
+ ADD_LINE = "Añadir Línea"
8
+ CROSS_SELL = "Cross Sell"
9
+ WALLET = "Cartera"
@@ -0,0 +1,6 @@
1
+ from enum import Enum
2
+
3
+
4
+ class TechnologyName(Enum):
5
+ ADSL = "ADSL"
6
+ FIBRA = "FIBRA"
@@ -0,0 +1,58 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class SubsType:
6
+ id: str
7
+ name: str
8
+ description: str
9
+
10
+
11
+ @dataclass(frozen=True)
12
+ class ComercialProduct:
13
+ id: str
14
+ name: str
15
+
16
+ @classmethod
17
+ def from_dict(cls, commercial_product, **kwargs) -> "ComercialProduct":
18
+ return cls(commercial_product["id"], commercial_product["name"])
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class BundledProductSubtype:
23
+ id: str
24
+ bundled_commercial_products: list[ComercialProduct]
25
+ subs_type: SubsType
26
+
27
+ @classmethod
28
+ def from_dict(
29
+ cls, id, bundled_commercial_products, subs_type, **kwargs
30
+ ) -> "BundledProductSubtype":
31
+ return cls(
32
+ id,
33
+ bundled_commercial_products=[
34
+ ComercialProduct.from_dict(**bundled_commercial_product)
35
+ for bundled_commercial_product in bundled_commercial_products
36
+ ],
37
+ subs_type=SubsType(**subs_type),
38
+ )
39
+
40
+
41
+ @dataclass(frozen=True)
42
+ class BundledProduct:
43
+ id: str
44
+ name: str
45
+ bundled_product_subs_types: list[BundledProductSubtype]
46
+
47
+ @classmethod
48
+ def from_dict(
49
+ cls, id, name, bundled_product_subs_types, **kwargs
50
+ ) -> "BundledProduct":
51
+ return cls(
52
+ id,
53
+ name,
54
+ bundled_product_subs_types=[
55
+ BundledProductSubtype.from_dict(**bundled_product_subs_type)
56
+ for bundled_product_subs_type in bundled_product_subs_types
57
+ ],
58
+ )
@@ -0,0 +1,11 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class ClientAddress:
6
+ street_name: str
7
+ state_id: int
8
+ locality: str
9
+ postal_code: str
10
+ number: int
11
+ country: str = "España"
@@ -0,0 +1,27 @@
1
+ from dataclasses import dataclass
2
+ from typing import Dict, Any
3
+
4
+ from masstack_python_client.resources.models.client_address import ClientAddress
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class ClientAttribute:
9
+ type: str
10
+ document_type_id: int
11
+ document_value: str
12
+ email: str
13
+ birthdate: str
14
+ nationality_id: int
15
+ contact_phone: str
16
+ gender: str
17
+ language_id: int
18
+ address: ClientAddress
19
+ name: str = None
20
+ company_name: str = None
21
+ middlename: str = "."
22
+ lastname: str = "."
23
+
24
+ @classmethod
25
+ def from_dict(cls, data: Dict[str, Any]) -> "ClientAttribute":
26
+ data_address = data.pop("address")
27
+ return cls(address=ClientAddress(**data_address), **data)
@@ -0,0 +1,14 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class BankAccount:
6
+ bank_account: str
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class ScoringAccount:
11
+ id_value: float = 1.01
12
+ scoring_value: int = 71
13
+ up_front: float = 1.01
14
+ forced_value: float = 0.01
@@ -0,0 +1,90 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import List, Dict, Any
3
+
4
+
5
+ @dataclass(frozen=True)
6
+ class Contact:
7
+ name: str
8
+ phone: str
9
+ email: str
10
+ document_type_id: str
11
+ document_value: str
12
+ middlename: str = "."
13
+ lastname: str = "."
14
+
15
+
16
+ @dataclass(frozen=True)
17
+ class Address:
18
+ street_type_id: int
19
+ street_name: str
20
+ number: int
21
+ supplement: str
22
+ state_id: int
23
+ locality: str
24
+ postal_code: str
25
+ gescal: str
26
+ address_id: str
27
+ pair_vacancy: bool = True
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class Info:
32
+ contact: Contact
33
+ address: Address
34
+
35
+ @classmethod
36
+ def from_dict(
37
+ cls,
38
+ data: Dict[str, Any],
39
+ ) -> "Info":
40
+ return cls(
41
+ contact=Contact(**data["contact"]),
42
+ address=Address(**data["address"]),
43
+ )
44
+
45
+
46
+ @dataclass(frozen=True)
47
+ class Landline:
48
+ product_id: int
49
+ number: str
50
+ services: List = field(default_factory=list)
51
+ wants_communications: bool = False
52
+ # TODO portability_info
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class Ftth:
57
+ product_id: int
58
+ connection_type: str = ""
59
+ installer: str = "MM"
60
+ wants_communications: bool = False
61
+ # TODO access_reuse
62
+ # TODO access_reuse_choice
63
+ # TODO iua
64
+
65
+
66
+ @dataclass(frozen=True)
67
+ class Bundle:
68
+ bundle_id: int
69
+ territory_owner: str
70
+ installation_info: Info
71
+ delivery_info: Info
72
+ landline: Landline
73
+ ftth: Ftth
74
+
75
+ @classmethod
76
+ def from_dict(
77
+ cls,
78
+ bundle_id: int,
79
+ territory_owner: str,
80
+ **data,
81
+ ) -> "Bundle":
82
+ info = Info.from_dict(data["client_info"])
83
+ return cls(
84
+ bundle_id,
85
+ territory_owner,
86
+ installation_info=info,
87
+ delivery_info=info,
88
+ landline=Landline(**data["land_line"]),
89
+ ftth=Ftth(**data["ftth"]),
90
+ )
@@ -0,0 +1,78 @@
1
+ from dataclasses import dataclass
2
+ from typing import List, Dict, Any
3
+
4
+ from masstack_python_client.resources.models.client_attribute import ClientAttribute
5
+ from masstack_python_client.resources.models.client_payment import (
6
+ BankAccount,
7
+ ScoringAccount,
8
+ )
9
+ from masstack_python_client.resources.models.products import Bundle
10
+
11
+
12
+ @dataclass(frozen=True)
13
+ class SalesInfo:
14
+ dealer_id: str
15
+ shop_id: str
16
+ channel: str = "dealer"
17
+ logistic: bool = False
18
+
19
+
20
+ @dataclass(frozen=True)
21
+ class Clients:
22
+ attributes: List[ClientAttribute]
23
+ sector_id: int = 1
24
+
25
+ @classmethod
26
+ def from_dict(cls, data: Dict[str, Any]) -> "Clients":
27
+ client_types = ["client", "account"]
28
+ return cls(
29
+ attributes=[
30
+ ClientAttribute.from_dict({"type": client_type, **data})
31
+ for client_type in client_types
32
+ ]
33
+ )
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class ClientPayment:
38
+ info: BankAccount
39
+ scoring: ScoringAccount = ScoringAccount()
40
+ billing_type_id: int = 1
41
+
42
+ @classmethod
43
+ def from_dict(cls, data: Dict[str, Any]) -> "ClientPayment":
44
+ return cls(info=BankAccount(bank_account=data["bank_account"]))
45
+
46
+
47
+ @dataclass(frozen=True)
48
+ class Products:
49
+ bundle: Bundle
50
+
51
+ @classmethod
52
+ def from_dict(cls, data: Dict[str, Any]) -> "Products":
53
+ return cls(bundle=Bundle.from_dict(**data))
54
+
55
+
56
+ @dataclass(frozen=True)
57
+ class SignupRequestData:
58
+ sales_info: SalesInfo
59
+ clients: Clients
60
+ payment: ClientPayment
61
+ products: Products
62
+ sales_type: str = "telecomunications"
63
+
64
+ @classmethod
65
+ def from_dict(cls, data: Dict[str, Any]) -> "SignupRequestData":
66
+ return cls(
67
+ sales_info=SalesInfo(**data["sales"]),
68
+ clients=Clients.from_dict(data["client"]),
69
+ payment=ClientPayment.from_dict(data["payment"]),
70
+ products=Products.from_dict(data["products"]),
71
+ )
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class SignupsResponseData:
76
+ sell_id: int
77
+ customer_id: int
78
+ work_order_id: str
@@ -0,0 +1,42 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class UserData:
6
+ id: int
7
+ document_value: str
8
+ document_type_id: int
9
+ gender: str
10
+ first_name: str
11
+ middle_name: str
12
+ last_name: str
13
+ nationality: str
14
+ email: str
15
+ birthdate: str
16
+ phone: str
17
+
18
+ @classmethod
19
+ def from_dict(
20
+ cls,
21
+ id,
22
+ document_value: str,
23
+ document_type: dict,
24
+ nationality: dict,
25
+ personal: dict,
26
+ **kwargs,
27
+ ):
28
+ return cls(
29
+ **{
30
+ "id": id,
31
+ "document_value": document_value,
32
+ "document_type_id": document_type["id"],
33
+ "gender": personal["gender"],
34
+ "first_name": personal["first_name"],
35
+ "middle_name": personal["middle_name"],
36
+ "last_name": personal["last_name"],
37
+ "nationality": nationality["value"],
38
+ "email": personal["email"],
39
+ "birthdate": personal["birthdate"],
40
+ "phone": personal["other_phone"],
41
+ }
42
+ )
@@ -0,0 +1,7 @@
1
+ def remove_none(obj):
2
+ if isinstance(obj, dict):
3
+ return {k: remove_none(v) for k, v in obj.items() if v is not None}
4
+ elif isinstance(obj, list):
5
+ return [remove_none(v) for v in obj if v is not None]
6
+ else:
7
+ return obj
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: masstack-python-client
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: This Python API client provides access to masmovil core API domains
5
5
  Author-email: Borja Gimeno <borja.gimeno@somconnexio.coop>
6
6
  License: GPL-3.0-only
@@ -38,6 +38,17 @@ This Python API client provides access to masmovil core API domains.
38
38
  - get: returns a unit by id with a list of coverages
39
39
  - get_coverage: returns coverage info for a unit id and territory_owner
40
40
 
41
+ * Customers
42
+ - Signups - access to signups new clients
43
+ - post new client
44
+ - Users
45
+ - returns customer tree data associated to a given document identification, email or number of the client.
46
+ - returns user data by userId
47
+
48
+ * Catalogue
49
+ - bundled_products - access to bundled products
50
+ - get sellable bundled products
51
+
41
52
  ## Installation
42
53
 
43
54
  ```commandline
@@ -0,0 +1,43 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ src/masstack_python_client/__init__.py
6
+ src/masstack_python_client/client.py
7
+ src/masstack_python_client/exceptions.py
8
+ src/masstack_python_client.egg-info/PKG-INFO
9
+ src/masstack_python_client.egg-info/SOURCES.txt
10
+ src/masstack_python_client.egg-info/dependency_links.txt
11
+ src/masstack_python_client.egg-info/requires.txt
12
+ src/masstack_python_client.egg-info/top_level.txt
13
+ src/masstack_python_client/auth/__init__.py
14
+ src/masstack_python_client/auth/token.py
15
+ src/masstack_python_client/auth/token_manager.py
16
+ src/masstack_python_client/auth/token_store.py
17
+ src/masstack_python_client/data/data_utils.py
18
+ src/masstack_python_client/data/province_translation.csv
19
+ src/masstack_python_client/data/street_type_translation.csv
20
+ src/masstack_python_client/data/unit_translation.csv
21
+ src/masstack_python_client/resources/__init__.py
22
+ src/masstack_python_client/resources/catalogue.py
23
+ src/masstack_python_client/resources/customers.py
24
+ src/masstack_python_client/resources/feasibility.py
25
+ src/masstack_python_client/resources/enums/__init__.py
26
+ src/masstack_python_client/resources/enums/bundled_product_category.py
27
+ src/masstack_python_client/resources/enums/commercial_segment_name.py
28
+ src/masstack_python_client/resources/enums/customer_segment_name.py
29
+ src/masstack_python_client/resources/enums/customer_type_name.py
30
+ src/masstack_python_client/resources/enums/document_type_search.py
31
+ src/masstack_python_client/resources/enums/sale_type_name.py
32
+ src/masstack_python_client/resources/enums/technology_name.py
33
+ src/masstack_python_client/resources/models/address.py
34
+ src/masstack_python_client/resources/models/bundled.py
35
+ src/masstack_python_client/resources/models/client_address.py
36
+ src/masstack_python_client/resources/models/client_attribute.py
37
+ src/masstack_python_client/resources/models/client_payment.py
38
+ src/masstack_python_client/resources/models/products.py
39
+ src/masstack_python_client/resources/models/signup.py
40
+ src/masstack_python_client/resources/models/user.py
41
+ src/masstack_python_client/resources/utils/serialize.py
42
+ tests/test_client.py
43
+ tests/test_exceptions.py
@@ -1,25 +0,0 @@
1
- LICENSE
2
- MANIFEST.in
3
- README.md
4
- pyproject.toml
5
- src/masstack_python_client/__init__.py
6
- src/masstack_python_client/client.py
7
- src/masstack_python_client/exceptions.py
8
- src/masstack_python_client.egg-info/PKG-INFO
9
- src/masstack_python_client.egg-info/SOURCES.txt
10
- src/masstack_python_client.egg-info/dependency_links.txt
11
- src/masstack_python_client.egg-info/requires.txt
12
- src/masstack_python_client.egg-info/top_level.txt
13
- src/masstack_python_client/auth/__init__.py
14
- src/masstack_python_client/auth/token.py
15
- src/masstack_python_client/auth/token_manager.py
16
- src/masstack_python_client/auth/token_store.py
17
- src/masstack_python_client/data/data_utils.py
18
- src/masstack_python_client/data/province_translation.csv
19
- src/masstack_python_client/data/street_type_translation.csv
20
- src/masstack_python_client/data/unit_translation.csv
21
- src/masstack_python_client/resources/__init__.py
22
- src/masstack_python_client/resources/feasibility.py
23
- src/masstack_python_client/resources/models/address.py
24
- tests/test_client.py
25
- tests/test_exceptions.py