masstack-python-client 0.0.4__py3-none-any.whl → 0.0.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,4 +1,4 @@
1
- __version__ = "0.0.4"
1
+ __version__ = "0.0.5"
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,7 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Technology(Enum):
5
+ ADSL = "ADSL"
6
+ FTTH = "FTTH"
7
+ MIFIJO = "MIFIJO"
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  from typing import Optional, List
3
3
  from masstack_python_client.client import MasstackClient
4
+ from masstack_python_client.resources.enums.technology import Technology
4
5
  from masstack_python_client.resources.models.address import (
5
6
  BuildingData,
6
7
  ClarifierData,
@@ -8,6 +9,18 @@ from masstack_python_client.resources.models.address import (
8
9
  StreetData,
9
10
  UnitData,
10
11
  )
12
+ from masstack_python_client.resources.models.portability import PortabilityData
13
+
14
+
15
+ """
16
+ FeasibilityResource
17
+ ├── Coverage
18
+ │ ├── Streets
19
+ │ ├── Buildings
20
+ │ └── Units
21
+ └── Portability
22
+ └── PortabilityCheck
23
+ """
11
24
 
12
25
 
13
26
  class FeasibilityResource:
@@ -17,6 +30,79 @@ class FeasibilityResource:
17
30
 
18
31
  _api_domain = "feasibility"
19
32
 
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
+
60
+ class Portability(FeasibilityResource):
61
+
62
+ _api_path = "portability"
63
+ _version = "v2"
64
+
65
+
66
+ class PortabilityCheck(Portability):
67
+
68
+ _api_subpath = "portabilityCheck"
69
+
70
+ @classmethod
71
+ def check(
72
+ cls,
73
+ number: str,
74
+ address_id: str,
75
+ territory_owner: Optional[str] = None,
76
+ technical_id: Optional[str] = None,
77
+ technology: Technology = Technology.FTTH,
78
+ ) -> PortabilityData:
79
+ """Returns whether the portability process can be carried out
80
+ and whether it requires a new installation
81
+
82
+ Args:
83
+ number (str): Fixed number to be ported
84
+ address_id (str): Unique address ID
85
+ territory_owner (str): Territory owner. Not mandatory if technology is MIFIJO
86
+ technical_id (str): Technical id. Not mandatory if technology is MIFIJO. g17 or g37
87
+ technology (Technology): Technology to be provided
88
+
89
+ Returns:
90
+ PortabilityData
91
+
92
+ """
93
+
94
+ portability = cls._request(
95
+ method="post",
96
+ data={
97
+ "number": number,
98
+ "territoryOwner": territory_owner,
99
+ "technicalId": technical_id,
100
+ "addressId": address_id,
101
+ "technology": technology.value,
102
+ },
103
+ )
104
+ return PortabilityData.from_dict(**portability)
105
+
20
106
 
21
107
  class Coverage(FeasibilityResource):
22
108
 
@@ -31,10 +117,6 @@ class Coverage(FeasibilityResource):
31
117
  def _sf_channel() -> str:
32
118
  return os.environ.get("MASSTACK_COVERAGE_CHANNEL", "")
33
119
 
34
- @classmethod
35
- def _get_endpoint(cls, subpath: str) -> str:
36
- return f"{cls._api_path}/{subpath}"
37
-
38
120
  @classmethod
39
121
  def _get_header(cls, uuid: str) -> dict:
40
122
  return {
@@ -44,25 +126,8 @@ class Coverage(FeasibilityResource):
44
126
  }
45
127
 
46
128
  @classmethod
47
- def _request(
48
- cls,
49
- method: str,
50
- subpath: str,
51
- uuid: str,
52
- data: Optional[dict] = None,
53
- params: Optional[dict] = None,
54
- ) -> dict:
55
- client = MasstackClient()
56
- func = getattr(client, method)
57
-
58
- return func(
59
- api=cls._api_domain,
60
- version=cls._version,
61
- endpoint=cls._get_endpoint(subpath),
62
- params=params,
63
- data=data,
64
- header=cls._get_header(uuid),
65
- )
129
+ def _request(cls, *, uuid: str, **kwargs) -> dict | list:
130
+ return super()._request(header=cls._get_header(uuid), **kwargs)
66
131
 
67
132
 
68
133
  class Streets(Coverage):
@@ -83,9 +148,8 @@ class Streets(Coverage):
83
148
 
84
149
  """
85
150
  streets = cls._request(
86
- "get",
87
- cls._api_subpath,
88
- uuid,
151
+ method="get",
152
+ uuid=uuid,
89
153
  params={"search": text},
90
154
  )
91
155
  return [StreetData.from_dict(uuid, lang, **street) for street in streets]
@@ -104,9 +168,9 @@ class Streets(Coverage):
104
168
  ClarifierData
105
169
  """
106
170
  clarifiers = cls._request(
107
- "get",
108
- f"{cls._api_subpath}/clarifiers/{street_id}",
109
- uuid,
171
+ method="get",
172
+ suffix=f"/clarifiers/{street_id}",
173
+ uuid=uuid,
110
174
  )
111
175
 
112
176
  return [ClarifierData(uuid, **clarifier) for clarifier in clarifiers]
@@ -129,9 +193,8 @@ class Buildings(Coverage):
129
193
  BuildingData
130
194
  """
131
195
  buildings = cls._request(
132
- "get",
133
- cls._api_subpath,
134
- uuid,
196
+ method="get",
197
+ uuid=uuid,
135
198
  params={"search": text},
136
199
  )
137
200
  return [
@@ -154,9 +217,9 @@ class Buildings(Coverage):
154
217
  BuildingData
155
218
  """
156
219
  building = cls._request(
157
- "get",
158
- f"{cls._api_subpath}/{id}",
159
- uuid,
220
+ method="get",
221
+ suffix=f"/{id}",
222
+ uuid=uuid,
160
223
  params={"unit_to_data": unit_to_data},
161
224
  )
162
225
  return BuildingData.from_dict(
@@ -193,9 +256,9 @@ class Buildings(Coverage):
193
256
  """
194
257
 
195
258
  buildings = cls._request(
196
- "post",
197
- f"{cls._api_subpath}/search",
198
- uuid,
259
+ method="post",
260
+ suffix="/search",
261
+ uuid=uuid,
199
262
  data={
200
263
  "way_name": way_name,
201
264
  "number": number,
@@ -229,9 +292,9 @@ class Units(Coverage):
229
292
  UnitData
230
293
  """
231
294
  unit = cls._request(
232
- "get",
233
- f"{cls._api_subpath}/{unit_id}",
234
- uuid,
295
+ method="get",
296
+ suffix=f"/{unit_id}",
297
+ uuid=uuid,
235
298
  params={"parent_coverage": parent_coverage},
236
299
  )
237
300
  return UnitData.from_dict(
@@ -257,9 +320,9 @@ class Units(Coverage):
257
320
  CoverageData
258
321
  """
259
322
  unit = cls._request(
260
- "get",
261
- f"{cls._api_subpath}/extra",
262
- uuid,
323
+ method="get",
324
+ suffix="/extra",
325
+ uuid=uuid,
263
326
  params={"id": unit_id, "territory_owner": territory_owner},
264
327
  )
265
328
  return CoverageData.from_dict(
@@ -0,0 +1,6 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class FixedPhoneData:
6
+ number: str
@@ -0,0 +1,39 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class InstallationInfoData:
6
+ internalAccess: bool
7
+ iua: str
8
+ brand: str
9
+ number: str
10
+ documentNumber: str
11
+ gescal: str
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class OperatorData:
16
+ code: str
17
+ name: str
18
+
19
+
20
+ @dataclass(frozen=True)
21
+ class PortabilityData:
22
+ internalPortability: bool
23
+ isPortable: bool
24
+ installationRequired: bool
25
+ operator: OperatorData
26
+ installationInfo: InstallationInfoData
27
+
28
+ @classmethod
29
+ def from_dict(
30
+ cls,
31
+ operator,
32
+ installationInformation,
33
+ **kwargs,
34
+ ):
35
+ return cls(
36
+ operator=OperatorData(**operator),
37
+ installationInfo=InstallationInfoData(**installationInformation),
38
+ **kwargs,
39
+ )
@@ -0,0 +1,61 @@
1
+ from typing import Optional
2
+ from masstack_python_client.client import MasstackClient
3
+ from masstack_python_client.resources.models.fixed_phone import FixedPhoneData
4
+
5
+
6
+ "https://provision-inventory-network.sta.masstack.com/v1/orgs/marblanca/fixed/number"
7
+
8
+
9
+ class ProvisionNetworkResource:
10
+ """not documented"""
11
+
12
+ _api_domain = "provision-inventory-network"
13
+
14
+
15
+ class FixedPhone(ProvisionNetworkResource):
16
+ _api_path = "fixed"
17
+ _version = "v1"
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
+ @classmethod
43
+ def get_number(cls, postal_code: str, state: str = "new"):
44
+ """Obtain fixed numbering for sale.
45
+
46
+ Args:
47
+ postal_code (str): postal code
48
+ state (str): state
49
+ Returns:
50
+ FixedPhoneData
51
+
52
+ """
53
+ response = cls._request(
54
+ "get",
55
+ "number",
56
+ {
57
+ "postal_code": postal_code,
58
+ "state": state,
59
+ },
60
+ )
61
+ return FixedPhoneData(response["number"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: masstack-python-client
3
- Version: 0.0.4
3
+ Version: 0.0.5
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
@@ -37,6 +37,9 @@ This Python API client provides access to masmovil core API domains.
37
37
  - Units:
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
+ - 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
40
43
 
41
44
  * Customers
42
45
  - Signups - access to signups new clients
@@ -49,6 +52,11 @@ This Python API client provides access to masmovil core API domains.
49
52
  - bundled_products - access to bundled products
50
53
  - get sellable bundled products
51
54
 
55
+ * Provision inventory network
56
+ - fixed - Obtain fixed numbering for sale
57
+ - get number
58
+
59
+
52
60
  ## Installation
53
61
 
54
62
  ```commandline
@@ -1,4 +1,4 @@
1
- masstack_python_client/__init__.py,sha256=6TDc7ulFeITzFwqtn2Uqj3pBTqGRHYGHN43zbbpu5aY,154
1
+ masstack_python_client/__init__.py,sha256=LglbAMxBWseiHlWgcEl_eDDUXuK1sHtH-Rx6_y6YVbU,154
2
2
  masstack_python_client/client.py,sha256=5b52Q2ekABi7DlZPsNobcmaJXOKzZfhKE_kHvNEqE9Q,2496
3
3
  masstack_python_client/exceptions.py,sha256=HkX1cP4Ryeas59CzIVW8N5gmnRE1x0yQUQwS3tm9QZQ,2115
4
4
  masstack_python_client/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -12,7 +12,8 @@ masstack_python_client/data/unit_translation.csv,sha256=34FPfaCC1eSmBfV0BbHSHJ-t
12
12
  masstack_python_client/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  masstack_python_client/resources/catalogue.py,sha256=6evwB75NC2jRsTQ6Zz3-qmzNo9dFsQhdtAtYhwW9Zu0,4002
14
14
  masstack_python_client/resources/customers.py,sha256=9GTXQ5fiVosbAzK__uydZOBu9wXC9yO4pHufseHqD38,2924
15
- masstack_python_client/resources/feasibility.py,sha256=DbiPwWa9orSmITgcID7RVPKf7b50Pk8h1XQh0xxGYhw,7119
15
+ masstack_python_client/resources/feasibility.py,sha256=WSPprQFMoJAJFzlI65YLnt6AfErnfoziMbBqxpZYqGE,8974
16
+ masstack_python_client/resources/provision.py,sha256=EkSgYz7xaAWPrILTcrDATK3spBCOdEKwnV4-TvRzLg4,1525
16
17
  masstack_python_client/resources/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
18
  masstack_python_client/resources/enums/bundled_product_category.py,sha256=0rEsOud4kyDVX07DQ15C_DPcw8hZy84bAVj8j7nT22k,388
18
19
  masstack_python_client/resources/enums/commercial_segment_name.py,sha256=94yOXfHNCcZNCoR9ELQ-x2tarNin7gdYBVZ-CTzJsGA,101
@@ -20,18 +21,21 @@ masstack_python_client/resources/enums/customer_segment_name.py,sha256=NSQUUSUGL
20
21
  masstack_python_client/resources/enums/customer_type_name.py,sha256=mMdZh0D7qLDMxe6QYVQLGMqHqQMBAnZaPkjgE8q_D9Q,99
21
22
  masstack_python_client/resources/enums/document_type_search.py,sha256=pniXpUA_odqeKyxS6yYiN2uje0-F1kKXXBLOk0F8UTQ,136
22
23
  masstack_python_client/resources/enums/sale_type_name.py,sha256=NWl5j_SkbysOGVBn4-c7gVbzynOiE44Aqj34n_1v_sU,183
24
+ masstack_python_client/resources/enums/technology.py,sha256=ipHLhdY2EMQgmeDzJ0LnvWvdiG_Oq-JHuEb5ZIx5x3g,106
23
25
  masstack_python_client/resources/enums/technology_name.py,sha256=7h8LUyZ-2XHAxOZXelUkkFifmk9dCcwmBbWueFABfQ4,90
24
26
  masstack_python_client/resources/models/address.py,sha256=hKnEUVVz8AfGjhaDngzQ0HuR4_Z6zhK6Xe8Aj6xJR7I,5451
25
27
  masstack_python_client/resources/models/bundled.py,sha256=1zhWZFrQh15slaGSEZIDa1rURU76gRH5czppXYNSyow,1480
26
28
  masstack_python_client/resources/models/client_address.py,sha256=7WBiPTce2X6uZUVVZvZlTMgiohbVITUzmKgYYPvpM-w,204
27
29
  masstack_python_client/resources/models/client_attribute.py,sha256=rZlLjJeBVD6IpXbSEucujTqcmHhqoJGRTOV1wqyStak,697
28
30
  masstack_python_client/resources/models/client_payment.py,sha256=yMGMTuk_07-TzXWO89sCaaZv8soTO9cT0TzfV3xQa1o,262
31
+ masstack_python_client/resources/models/fixed_phone.py,sha256=ihF-iICz89eVhkeyRsX3pXYkODlXRpYPGJLiFiTBilM,98
32
+ masstack_python_client/resources/models/portability.py,sha256=ZO7la2BDabw6aLQhTxW0d9TZ3Iu9Cc4Kvf1WxrliiJo,775
29
33
  masstack_python_client/resources/models/products.py,sha256=cIuUlEKs0OfvBXtYxxUwG4vibfAlZL4uVBK7-nAL9rw,1831
30
34
  masstack_python_client/resources/models/signup.py,sha256=Hvo5nZce1ikpUUMEoLt_2g2HipHwh4XRIz344X8_IJk,2018
31
35
  masstack_python_client/resources/models/user.py,sha256=N5mwuZN0Saxiro2UXYcCxLL6jrpIU83crHhmrdAcgE8,1080
32
36
  masstack_python_client/resources/utils/serialize.py,sha256=F6JxqR2M9HH0TpYKaJritnppWkYlpPztZ9ZC43FdPLg,251
33
- masstack_python_client-0.0.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
34
- masstack_python_client-0.0.4.dist-info/METADATA,sha256=GJo4SVII_bljYCjkMAjrpbXHGYrX0YGSZk4Fz7uLYZ0,3818
35
- masstack_python_client-0.0.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
36
- masstack_python_client-0.0.4.dist-info/top_level.txt,sha256=q_iYlqJq22lhg_2O2iktARr7Mzz3QfjaW4l6J4vwyE8,23
37
- masstack_python_client-0.0.4.dist-info/RECORD,,
37
+ masstack_python_client-0.0.5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
38
+ masstack_python_client-0.0.5.dist-info/METADATA,sha256=I_UMFcemF9efNV1wjDrsrT5Di2e6nhy9jA6CPuQBttk,4154
39
+ masstack_python_client-0.0.5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
40
+ masstack_python_client-0.0.5.dist-info/top_level.txt,sha256=q_iYlqJq22lhg_2O2iktARr7Mzz3QfjaW4l6J4vwyE8,23
41
+ masstack_python_client-0.0.5.dist-info/RECORD,,