masstack-python-client 0.0.5__tar.gz → 0.1.0__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 (50) hide show
  1. {masstack_python_client-0.0.5/src/masstack_python_client.egg-info → masstack_python_client-0.1.0}/PKG-INFO +32 -31
  2. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/README.md +31 -30
  3. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/__init__.py +1 -1
  4. masstack_python_client-0.1.0/src/masstack_python_client/resources/base.py +59 -0
  5. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/catalogue.py +22 -43
  6. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/customers.py +7 -31
  7. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/feasibility.py +21 -50
  8. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/portability.py +8 -3
  9. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/provision.py +6 -29
  10. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0/src/masstack_python_client.egg-info}/PKG-INFO +32 -31
  11. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client.egg-info/SOURCES.txt +1 -0
  12. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/LICENSE +0 -0
  13. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/MANIFEST.in +0 -0
  14. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/pyproject.toml +0 -0
  15. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/setup.cfg +0 -0
  16. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/auth/__init__.py +0 -0
  17. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/auth/token.py +0 -0
  18. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/auth/token_manager.py +0 -0
  19. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/auth/token_store.py +0 -0
  20. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/client.py +0 -0
  21. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/data/data_utils.py +0 -0
  22. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/data/province_translation.csv +0 -0
  23. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/data/street_type_translation.csv +0 -0
  24. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/data/unit_translation.csv +0 -0
  25. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/exceptions.py +0 -0
  26. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/__init__.py +0 -0
  27. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/__init__.py +0 -0
  28. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/bundled_product_category.py +0 -0
  29. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/commercial_segment_name.py +0 -0
  30. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/customer_segment_name.py +0 -0
  31. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/customer_type_name.py +0 -0
  32. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/document_type_search.py +0 -0
  33. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/sale_type_name.py +0 -0
  34. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/technology.py +0 -0
  35. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/enums/technology_name.py +0 -0
  36. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/address.py +0 -0
  37. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/bundled.py +0 -0
  38. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/client_address.py +0 -0
  39. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/client_attribute.py +0 -0
  40. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/client_payment.py +0 -0
  41. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/fixed_phone.py +0 -0
  42. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/products.py +0 -0
  43. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/signup.py +0 -0
  44. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/models/user.py +0 -0
  45. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client/resources/utils/serialize.py +0 -0
  46. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client.egg-info/dependency_links.txt +0 -0
  47. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client.egg-info/requires.txt +0 -0
  48. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/src/masstack_python_client.egg-info/top_level.txt +0 -0
  49. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/tests/test_client.py +0 -0
  50. {masstack_python_client-0.0.5 → masstack_python_client-0.1.0}/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.5
3
+ Version: 0.1.0
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
@@ -25,36 +25,37 @@ This Python API client provides access to masmovil core API domains.
25
25
 
26
26
  ## Resources
27
27
 
28
- * Feasibility
29
- - Coverage - find an address
30
- - Streets:
31
- - search: returns a list of street by text
32
- - get_building_info_by_street: returns a list of building info by street id
33
- - Buildings:
34
- - search: returns a list of buildings by text
35
- - multi_search: returns a list of buildings by request body
36
- - get: returns a building by id with a list of units
37
- - Units:
38
- - get: returns a unit by id with a list of coverages
39
- - get_coverage: returns coverage info for a unit id and territory_owner
40
- - Portability - Checks if a landline portability or an access transfer is allowed
41
- - PortabilityCheck:
42
- - check: Returns whether the portability process can be carried out and whether it requires a new installation
43
-
44
- * Customers
45
- - Signups - access to signups new clients
46
- - post new client
47
- - Users
48
- - returns customer tree data associated to a given document identification, email or number of the client.
49
- - returns user data by userId
50
-
51
- * Catalogue
52
- - bundled_products - access to bundled products
53
- - get sellable bundled products
54
-
55
- * Provision inventory network
56
- - fixed - Obtain fixed numbering for sale
57
- - get number
28
+ - **Feasibility**
29
+ - Coverage - find an address
30
+ - Streets:
31
+ - *search: returns a list of street by text*
32
+ - *get_building_info_by_street: returns a list of building info by street id*
33
+ - Buildings:
34
+ - *search: returns a list of buildings by text*
35
+ - *multi_search: returns a list of buildings by request body*
36
+ - *get: returns a building by id with a list of units*
37
+ - Units:
38
+ - *get: returns a unit by id with a list of coverages*
39
+ - *get_coverage: returns coverage info for a unit id and territory_owner*
40
+ - Portability - Checks if a landline portability or an access transfer is allowed
41
+ - PortabilityCheck:
42
+ - *check: Returns whether the portability process can be carried out and whether it requires a new* installation
43
+
44
+ - **Customers**
45
+ - Signups - access to signups new clients
46
+ - *post new client*
47
+ - Users
48
+ - *returns customer tree data associated to a given document identification, email or number of the client.*
49
+ - *returns user data by userId*
50
+
51
+ - **Catalogue**
52
+ - bundled_products - access to bundled products
53
+ - Sellable:
54
+ - *get: Returns sellable bundled products*
55
+
56
+ - **Provision inventory network**
57
+ - fixed - Obtain fixed numbering for sale
58
+ - *get number*
58
59
 
59
60
 
60
61
  ## Installation
@@ -8,36 +8,37 @@ This Python API client provides access to masmovil core API domains.
8
8
 
9
9
  ## Resources
10
10
 
11
- * Feasibility
12
- - Coverage - find an address
13
- - Streets:
14
- - search: returns a list of street by text
15
- - get_building_info_by_street: returns a list of building info by street id
16
- - Buildings:
17
- - search: returns a list of buildings by text
18
- - multi_search: returns a list of buildings by request body
19
- - get: returns a building by id with a list of units
20
- - Units:
21
- - get: returns a unit by id with a list of coverages
22
- - get_coverage: returns coverage info for a unit id and territory_owner
23
- - Portability - Checks if a landline portability or an access transfer is allowed
24
- - PortabilityCheck:
25
- - check: Returns whether the portability process can be carried out and whether it requires a new installation
26
-
27
- * Customers
28
- - Signups - access to signups new clients
29
- - post new client
30
- - Users
31
- - returns customer tree data associated to a given document identification, email or number of the client.
32
- - returns user data by userId
33
-
34
- * Catalogue
35
- - bundled_products - access to bundled products
36
- - get sellable bundled products
37
-
38
- * Provision inventory network
39
- - fixed - Obtain fixed numbering for sale
40
- - get number
11
+ - **Feasibility**
12
+ - Coverage - find an address
13
+ - Streets:
14
+ - *search: returns a list of street by text*
15
+ - *get_building_info_by_street: returns a list of building info by street id*
16
+ - Buildings:
17
+ - *search: returns a list of buildings by text*
18
+ - *multi_search: returns a list of buildings by request body*
19
+ - *get: returns a building by id with a list of units*
20
+ - Units:
21
+ - *get: returns a unit by id with a list of coverages*
22
+ - *get_coverage: returns coverage info for a unit id and territory_owner*
23
+ - Portability - Checks if a landline portability or an access transfer is allowed
24
+ - PortabilityCheck:
25
+ - *check: Returns whether the portability process can be carried out and whether it requires a new* installation
26
+
27
+ - **Customers**
28
+ - Signups - access to signups new clients
29
+ - *post new client*
30
+ - Users
31
+ - *returns customer tree data associated to a given document identification, email or number of the client.*
32
+ - *returns user data by userId*
33
+
34
+ - **Catalogue**
35
+ - bundled_products - access to bundled products
36
+ - Sellable:
37
+ - *get: Returns sellable bundled products*
38
+
39
+ - **Provision inventory network**
40
+ - fixed - Obtain fixed numbering for sale
41
+ - *get number*
41
42
 
42
43
 
43
44
  ## Installation
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.5"
1
+ __version__ = "0.1.0"
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,59 @@
1
+ from typing import Optional, Union
2
+ from masstack_python_client.client import MasstackClient
3
+
4
+
5
+ class BaseResource:
6
+ __abstract__ = True
7
+
8
+ required_class_attributes = (
9
+ "_api_path",
10
+ "_api_domain",
11
+ "_version",
12
+ )
13
+
14
+ def __init_subclass__(cls, **kwargs):
15
+ super().__init_subclass__(**kwargs)
16
+
17
+ if cls.__dict__.get("__abstract__", False):
18
+ return
19
+
20
+ missing = [
21
+ attr for attr in cls.required_class_attributes if not hasattr(cls, attr)
22
+ ]
23
+
24
+ if missing:
25
+ raise TypeError(
26
+ f"{cls.__name__} missing required class attributes: "
27
+ f"{', '.join(missing)}"
28
+ )
29
+
30
+ @classmethod
31
+ def _get_endpoint(cls, suffix: str = "") -> str:
32
+ parts = [
33
+ cls._api_path,
34
+ getattr(cls, "_api_subpath", ""),
35
+ suffix,
36
+ ]
37
+ return "/".join(part.strip("/") for part in parts if part)
38
+
39
+ @classmethod
40
+ def _request(
41
+ cls,
42
+ *,
43
+ method: str,
44
+ suffix: Optional[str] = "",
45
+ header: Optional[dict] = None,
46
+ data: Optional[dict] = None,
47
+ params: Optional[dict] = None,
48
+ ) -> Union[dict, list]:
49
+ client = MasstackClient()
50
+ func = getattr(client, method)
51
+
52
+ return func(
53
+ api=cls._api_domain,
54
+ version=cls._version,
55
+ endpoint=cls._get_endpoint(suffix),
56
+ params=params,
57
+ data=data,
58
+ header=header,
59
+ )
@@ -1,5 +1,9 @@
1
1
  from typing import Optional, List
2
- from masstack_python_client.client import MasstackClient
2
+ from masstack_python_client.resources.base import BaseResource
3
+ from masstack_python_client.resources.enums.customer_type_name import CustomerTypeName
4
+ from masstack_python_client.resources.enums.sale_type_name import SaleTypeName
5
+ from masstack_python_client.resources.enums.technology_name import TechnologyName
6
+ from masstack_python_client.resources.models.bundled import BundledProduct
3
7
  from masstack_python_client.resources.enums.bundled_product_category import (
4
8
  BundleCategory,
5
9
  )
@@ -9,50 +13,25 @@ from masstack_python_client.resources.enums.commercial_segment_name import (
9
13
  from masstack_python_client.resources.enums.customer_segment_name import (
10
14
  CustomerSegmentName,
11
15
  )
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
+ from masstack_python_client.resources.utils.serialize import remove_none
16
17
 
17
18
 
18
- class CatalogueResource:
19
+ class CatalogueResource(BaseResource):
19
20
  """Support sales and post-sales operations from catalogue perspective
20
21
  https://developers.masstack.com/en/docs/apis_catalogue_doc_swagger/2/apioverview/
21
22
  """
22
23
 
24
+ __abstract__ = True
23
25
  _api_domain = "catalogue"
24
26
 
25
27
 
26
28
  class BundledProducts(CatalogueResource):
29
+ __abstract__ = True
27
30
  _api_path = "bundled_products"
28
31
  _version = "v2"
29
32
 
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
33
 
54
34
  class Sellable(BundledProducts):
55
-
56
35
  _api_subpath = "sellable"
57
36
 
58
37
  @classmethod
@@ -87,22 +66,22 @@ class Sellable(BundledProducts):
87
66
  """
88
67
  params = {
89
68
  "commercial_profile_name": commercial_profile_name,
90
- "technology_name": technology_name,
69
+ "technology_name": technology_name.value if technology_name else None,
91
70
  "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,
71
+ "category": category.value if category else None,
72
+ "customer_segment_name": (
73
+ customer_segment_name.value if customer_segment_name else None
74
+ ),
75
+ "commercial_segment_name": (
76
+ commercial_segment_name.value if commercial_segment_name else None
77
+ ),
78
+ "customer_type_name": (
79
+ customer_type_name.value if customer_type_name else None
80
+ ),
81
+ "sale_type_name": sale_type_name.value if sale_type_name else None,
97
82
  }
98
83
  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
- },
84
+ method="get", params=remove_none(params)
106
85
  )
107
86
  return [
108
87
  BundledProduct.from_dict(**sellable_bundled_product)
@@ -1,7 +1,7 @@
1
- from typing import Optional
2
1
  from dataclasses import asdict
3
-
4
- from masstack_python_client.client import MasstackClient
2
+ from masstack_python_client.resources.base import BaseResource
3
+ from masstack_python_client.resources.models.user import UserData
4
+ from masstack_python_client.resources.utils.serialize import remove_none
5
5
  from masstack_python_client.resources.enums.document_type_search import (
6
6
  DocumentTypeSearch,
7
7
  )
@@ -9,37 +9,17 @@ from masstack_python_client.resources.models.signup import (
9
9
  SignupRequestData,
10
10
  SignupsResponseData,
11
11
  )
12
- from masstack_python_client.resources.models.user import UserData
13
- from masstack_python_client.resources.utils.serialize import remove_none
14
12
 
15
13
 
16
- class CustomersResource:
14
+ class CustomersResource(BaseResource):
17
15
  """Provide the necessary functionality to be able to give
18
16
  E2E coverage to the entire life-cycle of a client
19
17
  https://developers.masstack.com/en/docs/apis_customers_doc_swagger/2/apioverview
20
18
  """
21
19
 
20
+ __abstract__ = True
22
21
  _api_domain = "customers"
23
22
 
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
23
 
44
24
  class SignupsResource(CustomersResource):
45
25
  _api_path = "signups"
@@ -58,7 +38,6 @@ class SignupsResource(CustomersResource):
58
38
  payload = remove_none(asdict(customer_data))
59
39
  result = cls._request(
60
40
  method="post",
61
- endpoint=cls._api_path,
62
41
  data=payload,
63
42
  )
64
43
 
@@ -86,10 +65,7 @@ class Users(CustomersResource):
86
65
  user id.
87
66
  """
88
67
  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
- ]
68
+ return cls._request(method="post", suffix="tree", data=data)["id"]
93
69
 
94
70
  @classmethod
95
71
  def get_user_by_id(cls, user_id: str) -> dict:
@@ -102,5 +78,5 @@ class Users(CustomersResource):
102
78
  Returns:
103
79
  UserData
104
80
  """
105
- user = cls._request(method="get", endpoint=f"{cls._api_path}/{user_id}")
81
+ user = cls._request(method="get", suffix=user_id)
106
82
  return UserData.from_dict(**user)
@@ -1,7 +1,8 @@
1
1
  import os
2
- from typing import Optional, List
3
- from masstack_python_client.client import MasstackClient
2
+ from typing import Optional, List, Union
3
+ from masstack_python_client.resources.base import BaseResource
4
4
  from masstack_python_client.resources.enums.technology import Technology
5
+ from masstack_python_client.resources.models.portability import PortabilityData
5
6
  from masstack_python_client.resources.models.address import (
6
7
  BuildingData,
7
8
  ClarifierData,
@@ -9,62 +10,35 @@ from masstack_python_client.resources.models.address import (
9
10
  StreetData,
10
11
  UnitData,
11
12
  )
12
- from masstack_python_client.resources.models.portability import PortabilityData
13
-
14
13
 
15
14
  """
16
- FeasibilityResource
17
- ├── Coverage
18
- ├── Streets
19
- │ ├── Buildings
20
- └── Units
21
- └── Portability
22
- └── PortabilityCheck
15
+ BaseResource
16
+ └──FeasibilityResource
17
+ ├── Coverage
18
+ │ ├── Streets
19
+ ├── Buildings
20
+ └── Units
21
+ └── Portability
22
+ └── PortabilityCheck
23
23
  """
24
24
 
25
25
 
26
- class FeasibilityResource:
26
+ class FeasibilityResource(BaseResource):
27
27
  """Resource for feasibility operations
28
28
  https://developers.masstack.com/en/docs/apis_feasibility_doc_swagger/1/apioverview
29
29
  """
30
30
 
31
+ __abstract__ = True
31
32
  _api_domain = "feasibility"
32
33
 
33
- @classmethod
34
- def _get_endpoint(cls, suffix: str) -> str:
35
- return f"{cls._api_path}/{cls._api_subpath}{suffix}"
36
-
37
- @classmethod
38
- def _request(
39
- cls,
40
- *,
41
- method: str,
42
- suffix: Optional[str] = "",
43
- header: Optional[dict] = None,
44
- data: Optional[dict] = None,
45
- params: Optional[dict] = None,
46
- ) -> dict | list:
47
- client = MasstackClient()
48
- func = getattr(client, method)
49
-
50
- return func(
51
- api=cls._api_domain,
52
- version=cls._version,
53
- endpoint=cls._get_endpoint(suffix),
54
- params=params,
55
- data=data,
56
- header=header,
57
- )
58
-
59
34
 
60
35
  class Portability(FeasibilityResource):
61
-
36
+ __abstract__ = True
62
37
  _api_path = "portability"
63
38
  _version = "v2"
64
39
 
65
40
 
66
41
  class PortabilityCheck(Portability):
67
-
68
42
  _api_subpath = "portabilityCheck"
69
43
 
70
44
  @classmethod
@@ -105,7 +79,7 @@ class PortabilityCheck(Portability):
105
79
 
106
80
 
107
81
  class Coverage(FeasibilityResource):
108
-
82
+ __abstract__ = True
109
83
  _api_path = "coverage"
110
84
  _version = "v1"
111
85
 
@@ -126,12 +100,11 @@ class Coverage(FeasibilityResource):
126
100
  }
127
101
 
128
102
  @classmethod
129
- def _request(cls, *, uuid: str, **kwargs) -> dict | list:
103
+ def _request(cls, *, uuid: str, **kwargs) -> Union[dict, list]:
130
104
  return super()._request(header=cls._get_header(uuid), **kwargs)
131
105
 
132
106
 
133
107
  class Streets(Coverage):
134
-
135
108
  _api_subpath = "streets"
136
109
 
137
110
  @classmethod
@@ -169,7 +142,7 @@ class Streets(Coverage):
169
142
  """
170
143
  clarifiers = cls._request(
171
144
  method="get",
172
- suffix=f"/clarifiers/{street_id}",
145
+ suffix=f"clarifiers/{street_id}",
173
146
  uuid=uuid,
174
147
  )
175
148
 
@@ -177,7 +150,6 @@ class Streets(Coverage):
177
150
 
178
151
 
179
152
  class Buildings(Coverage):
180
-
181
153
  _api_subpath = "buildings"
182
154
 
183
155
  @classmethod
@@ -218,7 +190,7 @@ class Buildings(Coverage):
218
190
  """
219
191
  building = cls._request(
220
192
  method="get",
221
- suffix=f"/{id}",
193
+ suffix=id,
222
194
  uuid=uuid,
223
195
  params={"unit_to_data": unit_to_data},
224
196
  )
@@ -257,7 +229,7 @@ class Buildings(Coverage):
257
229
 
258
230
  buildings = cls._request(
259
231
  method="post",
260
- suffix="/search",
232
+ suffix="search",
261
233
  uuid=uuid,
262
234
  data={
263
235
  "way_name": way_name,
@@ -273,7 +245,6 @@ class Buildings(Coverage):
273
245
 
274
246
 
275
247
  class Units(Coverage):
276
-
277
248
  _api_subpath = "units"
278
249
 
279
250
  @classmethod
@@ -293,7 +264,7 @@ class Units(Coverage):
293
264
  """
294
265
  unit = cls._request(
295
266
  method="get",
296
- suffix=f"/{unit_id}",
267
+ suffix=unit_id,
297
268
  uuid=uuid,
298
269
  params={"parent_coverage": parent_coverage},
299
270
  )
@@ -321,7 +292,7 @@ class Units(Coverage):
321
292
  """
322
293
  unit = cls._request(
323
294
  method="get",
324
- suffix="/extra",
295
+ suffix="extra",
325
296
  uuid=uuid,
326
297
  params={"id": unit_id, "territory_owner": territory_owner},
327
298
  )
@@ -1,4 +1,5 @@
1
1
  from dataclasses import dataclass
2
+ from typing import Optional
2
3
 
3
4
 
4
5
  @dataclass(frozen=True)
@@ -23,17 +24,21 @@ class PortabilityData:
23
24
  isPortable: bool
24
25
  installationRequired: bool
25
26
  operator: OperatorData
26
- installationInfo: InstallationInfoData
27
+ installationInfo: Optional[InstallationInfoData] = None
27
28
 
28
29
  @classmethod
29
30
  def from_dict(
30
31
  cls,
31
32
  operator,
32
- installationInformation,
33
+ installationInformation=None,
33
34
  **kwargs,
34
35
  ):
35
36
  return cls(
36
37
  operator=OperatorData(**operator),
37
- installationInfo=InstallationInfoData(**installationInformation),
38
+ installationInfo=(
39
+ InstallationInfoData(**installationInformation)
40
+ if installationInformation
41
+ else None
42
+ ),
38
43
  **kwargs,
39
44
  )
@@ -1,14 +1,14 @@
1
- from typing import Optional
2
- from masstack_python_client.client import MasstackClient
1
+ from masstack_python_client.resources.base import BaseResource
3
2
  from masstack_python_client.resources.models.fixed_phone import FixedPhoneData
4
3
 
5
4
 
6
5
  "https://provision-inventory-network.sta.masstack.com/v1/orgs/marblanca/fixed/number"
7
6
 
8
7
 
9
- class ProvisionNetworkResource:
8
+ class ProvisionNetworkResource(BaseResource):
10
9
  """not documented"""
11
10
 
11
+ __abstract__ = True
12
12
  _api_domain = "provision-inventory-network"
13
13
 
14
14
 
@@ -16,29 +16,6 @@ class FixedPhone(ProvisionNetworkResource):
16
16
  _api_path = "fixed"
17
17
  _version = "v1"
18
18
 
19
- @classmethod
20
- def _get_endpoint(cls, subpath: str) -> str:
21
- return f"{cls._api_path}/{subpath}"
22
-
23
- @classmethod
24
- def _request(
25
- cls,
26
- method: str,
27
- subpath: str,
28
- params: Optional[dict] = None,
29
- data: Optional[dict] = None,
30
- ) -> dict:
31
- client = MasstackClient()
32
- func = getattr(client, method)
33
-
34
- return func(
35
- api=cls._api_domain,
36
- version=cls._version,
37
- endpoint=cls._get_endpoint(subpath),
38
- params=params,
39
- data=data,
40
- )
41
-
42
19
  @classmethod
43
20
  def get_number(cls, postal_code: str, state: str = "new"):
44
21
  """Obtain fixed numbering for sale.
@@ -51,9 +28,9 @@ class FixedPhone(ProvisionNetworkResource):
51
28
 
52
29
  """
53
30
  response = cls._request(
54
- "get",
55
- "number",
56
- {
31
+ method="get",
32
+ suffix="number",
33
+ params={
57
34
  "postal_code": postal_code,
58
35
  "state": state,
59
36
  },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: masstack-python-client
3
- Version: 0.0.5
3
+ Version: 0.1.0
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
@@ -25,36 +25,37 @@ This Python API client provides access to masmovil core API domains.
25
25
 
26
26
  ## Resources
27
27
 
28
- * Feasibility
29
- - Coverage - find an address
30
- - Streets:
31
- - search: returns a list of street by text
32
- - get_building_info_by_street: returns a list of building info by street id
33
- - Buildings:
34
- - search: returns a list of buildings by text
35
- - multi_search: returns a list of buildings by request body
36
- - get: returns a building by id with a list of units
37
- - Units:
38
- - get: returns a unit by id with a list of coverages
39
- - get_coverage: returns coverage info for a unit id and territory_owner
40
- - Portability - Checks if a landline portability or an access transfer is allowed
41
- - PortabilityCheck:
42
- - check: Returns whether the portability process can be carried out and whether it requires a new installation
43
-
44
- * Customers
45
- - Signups - access to signups new clients
46
- - post new client
47
- - Users
48
- - returns customer tree data associated to a given document identification, email or number of the client.
49
- - returns user data by userId
50
-
51
- * Catalogue
52
- - bundled_products - access to bundled products
53
- - get sellable bundled products
54
-
55
- * Provision inventory network
56
- - fixed - Obtain fixed numbering for sale
57
- - get number
28
+ - **Feasibility**
29
+ - Coverage - find an address
30
+ - Streets:
31
+ - *search: returns a list of street by text*
32
+ - *get_building_info_by_street: returns a list of building info by street id*
33
+ - Buildings:
34
+ - *search: returns a list of buildings by text*
35
+ - *multi_search: returns a list of buildings by request body*
36
+ - *get: returns a building by id with a list of units*
37
+ - Units:
38
+ - *get: returns a unit by id with a list of coverages*
39
+ - *get_coverage: returns coverage info for a unit id and territory_owner*
40
+ - Portability - Checks if a landline portability or an access transfer is allowed
41
+ - PortabilityCheck:
42
+ - *check: Returns whether the portability process can be carried out and whether it requires a new* installation
43
+
44
+ - **Customers**
45
+ - Signups - access to signups new clients
46
+ - *post new client*
47
+ - Users
48
+ - *returns customer tree data associated to a given document identification, email or number of the client.*
49
+ - *returns user data by userId*
50
+
51
+ - **Catalogue**
52
+ - bundled_products - access to bundled products
53
+ - Sellable:
54
+ - *get: Returns sellable bundled products*
55
+
56
+ - **Provision inventory network**
57
+ - fixed - Obtain fixed numbering for sale
58
+ - *get number*
58
59
 
59
60
 
60
61
  ## Installation
@@ -19,6 +19,7 @@ src/masstack_python_client/data/province_translation.csv
19
19
  src/masstack_python_client/data/street_type_translation.csv
20
20
  src/masstack_python_client/data/unit_translation.csv
21
21
  src/masstack_python_client/resources/__init__.py
22
+ src/masstack_python_client/resources/base.py
22
23
  src/masstack_python_client/resources/catalogue.py
23
24
  src/masstack_python_client/resources/customers.py
24
25
  src/masstack_python_client/resources/feasibility.py