mss-python 0.0.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.
- mss_python-0.0.0/.flake8 +3 -0
- mss_python-0.0.0/.github/workflows/python-publish.yml +46 -0
- mss_python-0.0.0/.gitignore +8 -0
- mss_python-0.0.0/.vscode/settings.json +4 -0
- mss_python-0.0.0/LICENSE +21 -0
- mss_python-0.0.0/PKG-INFO +99 -0
- mss_python-0.0.0/README.md +67 -0
- mss_python-0.0.0/examples/simple/main.py +42 -0
- mss_python-0.0.0/pyproject.toml +23 -0
- mss_python-0.0.0/requirements.txt +1 -0
- mss_python-0.0.0/setup.cfg +4 -0
- mss_python-0.0.0/src/mss_python/__init__.py +0 -0
- mss_python-0.0.0/src/mss_python/client.py +111 -0
- mss_python-0.0.0/src/mss_python/request/method_names.py +28 -0
- mss_python-0.0.0/src/mss_python/request/methods.py +23 -0
- mss_python-0.0.0/src/mss_python/request/types_mss.py +835 -0
- mss_python-0.0.0/src/mss_python.egg-info/PKG-INFO +99 -0
- mss_python-0.0.0/src/mss_python.egg-info/SOURCES.txt +18 -0
- mss_python-0.0.0/src/mss_python.egg-info/dependency_links.txt +1 -0
- mss_python-0.0.0/src/mss_python.egg-info/top_level.txt +1 -0
mss_python-0.0.0/.flake8
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
deploy:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
permissions:
|
|
23
|
+
id-token: write
|
|
24
|
+
|
|
25
|
+
environment:
|
|
26
|
+
name: pypi
|
|
27
|
+
url: https://pypi.org/p/mss-python
|
|
28
|
+
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
- name: Set up Python
|
|
32
|
+
uses: actions/setup-python@v3
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.x"
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install --upgrade pip
|
|
38
|
+
pip install build
|
|
39
|
+
- name: Install dependencies
|
|
40
|
+
run: |
|
|
41
|
+
python -m pip install --upgrade pip
|
|
42
|
+
pip install -r requirements.txt
|
|
43
|
+
- name: Build package
|
|
44
|
+
run: python -m build
|
|
45
|
+
- name: Publish package
|
|
46
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
mss_python-0.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Booking Südtirol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mss-python
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: MSS API wrapper for Python projects
|
|
5
|
+
Author-email: HGV <development@hgv.it>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Booking Südtirol
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Repository, https://github.com/bookingsuedtirol/mss-python
|
|
29
|
+
Requires-Python: <4,>=3.7
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
|
|
33
|
+
# mss-python
|
|
34
|
+
|
|
35
|
+
MSS API client for Python projects
|
|
36
|
+
|
|
37
|
+
<!-- ## Dependencies
|
|
38
|
+
|
|
39
|
+
This library requires an IANA Time Zone database to be present on the operating system (because it uses https://pkg.go.dev/time#LoadLocation). This database comes pre-installed with many Linux distros. If it’s unavailable (such as on Windows), https://pkg.go.dev/time/tzdata can be imported in the main program (which uses mss-go) instead. -->
|
|
40
|
+
|
|
41
|
+
## Available methods
|
|
42
|
+
|
|
43
|
+
- [x] getHotelList
|
|
44
|
+
- [x] getHotelListByFilter
|
|
45
|
+
- [x] getSpecialList
|
|
46
|
+
- [x] getRoomList
|
|
47
|
+
- [x] getWidgetConfig
|
|
48
|
+
- [x] getBooking
|
|
49
|
+
- [x] cancelBooking
|
|
50
|
+
- [x] prepareBooking
|
|
51
|
+
- [x] getAvailability
|
|
52
|
+
- [x] getRoomAvailability
|
|
53
|
+
- [x] getDayAvailability
|
|
54
|
+
- [x] getPriceList
|
|
55
|
+
- [x] createInquiry
|
|
56
|
+
- [x] getLocationList
|
|
57
|
+
- [x] getThemeList
|
|
58
|
+
- [x] getMasterpackagesList
|
|
59
|
+
- [x] notifyMasterpackages
|
|
60
|
+
- [x] getLastMinuteQuotation
|
|
61
|
+
- [x] validateCoupon
|
|
62
|
+
- [x] getHotelPictures
|
|
63
|
+
- [x] getHotelPictureGroups
|
|
64
|
+
- [x] getOptionalServices
|
|
65
|
+
|
|
66
|
+
## Example Execution
|
|
67
|
+
|
|
68
|
+
`pip install -r requirements.txt`
|
|
69
|
+
|
|
70
|
+
`python3 -m examples.simple.main`
|
|
71
|
+
|
|
72
|
+
<!-- -
|
|
73
|
+
|
|
74
|
+
TODO
|
|
75
|
+
|
|
76
|
+
- [x] getInquiry - how to find booking IDs?
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
- [x] getUserSources
|
|
80
|
+
|
|
81
|
+
-->
|
|
82
|
+
|
|
83
|
+
<!-- Warning: Only the methods with a ✓ next to them have been tested so far.
|
|
84
|
+
|
|
85
|
+
## Before running examples/tests
|
|
86
|
+
|
|
87
|
+
Set the environment variables with:
|
|
88
|
+
|
|
89
|
+
```Bash
|
|
90
|
+
export $(make env)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Examples
|
|
94
|
+
|
|
95
|
+
Run `make simple` or `make advanced`
|
|
96
|
+
|
|
97
|
+
## Tests
|
|
98
|
+
|
|
99
|
+
Run `make test` -->
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# mss-python
|
|
2
|
+
|
|
3
|
+
MSS API client for Python projects
|
|
4
|
+
|
|
5
|
+
<!-- ## Dependencies
|
|
6
|
+
|
|
7
|
+
This library requires an IANA Time Zone database to be present on the operating system (because it uses https://pkg.go.dev/time#LoadLocation). This database comes pre-installed with many Linux distros. If it’s unavailable (such as on Windows), https://pkg.go.dev/time/tzdata can be imported in the main program (which uses mss-go) instead. -->
|
|
8
|
+
|
|
9
|
+
## Available methods
|
|
10
|
+
|
|
11
|
+
- [x] getHotelList
|
|
12
|
+
- [x] getHotelListByFilter
|
|
13
|
+
- [x] getSpecialList
|
|
14
|
+
- [x] getRoomList
|
|
15
|
+
- [x] getWidgetConfig
|
|
16
|
+
- [x] getBooking
|
|
17
|
+
- [x] cancelBooking
|
|
18
|
+
- [x] prepareBooking
|
|
19
|
+
- [x] getAvailability
|
|
20
|
+
- [x] getRoomAvailability
|
|
21
|
+
- [x] getDayAvailability
|
|
22
|
+
- [x] getPriceList
|
|
23
|
+
- [x] createInquiry
|
|
24
|
+
- [x] getLocationList
|
|
25
|
+
- [x] getThemeList
|
|
26
|
+
- [x] getMasterpackagesList
|
|
27
|
+
- [x] notifyMasterpackages
|
|
28
|
+
- [x] getLastMinuteQuotation
|
|
29
|
+
- [x] validateCoupon
|
|
30
|
+
- [x] getHotelPictures
|
|
31
|
+
- [x] getHotelPictureGroups
|
|
32
|
+
- [x] getOptionalServices
|
|
33
|
+
|
|
34
|
+
## Example Execution
|
|
35
|
+
|
|
36
|
+
`pip install -r requirements.txt`
|
|
37
|
+
|
|
38
|
+
`python3 -m examples.simple.main`
|
|
39
|
+
|
|
40
|
+
<!-- -
|
|
41
|
+
|
|
42
|
+
TODO
|
|
43
|
+
|
|
44
|
+
- [x] getInquiry - how to find booking IDs?
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
- [x] getUserSources
|
|
48
|
+
|
|
49
|
+
-->
|
|
50
|
+
|
|
51
|
+
<!-- Warning: Only the methods with a ✓ next to them have been tested so far.
|
|
52
|
+
|
|
53
|
+
## Before running examples/tests
|
|
54
|
+
|
|
55
|
+
Set the environment variables with:
|
|
56
|
+
|
|
57
|
+
```Bash
|
|
58
|
+
export $(make env)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
Run `make simple` or `make advanced`
|
|
64
|
+
|
|
65
|
+
## Tests
|
|
66
|
+
|
|
67
|
+
Run `make test` -->
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from src.mss_python.client import Client
|
|
2
|
+
from src.mss_python.request.types_mss import (
|
|
3
|
+
Credentials,
|
|
4
|
+
Request,
|
|
5
|
+
Search,
|
|
6
|
+
Options,
|
|
7
|
+
HotelDetails,
|
|
8
|
+
)
|
|
9
|
+
from src.mss_python.request.methods import MethodName
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
credentials = Credentials(
|
|
14
|
+
"MSS_SERVICE_USERNAME",
|
|
15
|
+
"MSS_SERVICE_PASSWORD",
|
|
16
|
+
"MSS_SERVICE_SOURCE",
|
|
17
|
+
)
|
|
18
|
+
lang = "de"
|
|
19
|
+
client = Client(credentials, lang)
|
|
20
|
+
|
|
21
|
+
req = Request(
|
|
22
|
+
Search("de", id=["YOUR_HOTEL_ID_1", "YOUR_HOTEL_ID_2", "YOUR_HOTEL_ID_3"]),
|
|
23
|
+
Options(HotelDetails.BasicInfo | HotelDetails.Coordinates),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
|
|
28
|
+
resp = client.request(
|
|
29
|
+
"MSS_SERVICE_URL",
|
|
30
|
+
MethodName.GetHotelList,
|
|
31
|
+
req,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
hotel = resp["result"]["hotel"][0]
|
|
35
|
+
|
|
36
|
+
print(type(hotel["name"]), hotel["name"])
|
|
37
|
+
print(type(hotel["stars"]), hotel["stars"])
|
|
38
|
+
|
|
39
|
+
print(type(hotel["geolocation"]["latitude"]), hotel["geolocation"]["latitude"])
|
|
40
|
+
|
|
41
|
+
except Exception as e:
|
|
42
|
+
print(e)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "setuptools_scm>=8"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mss-python"
|
|
7
|
+
description = "MSS API wrapper for Python projects"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.7, <4"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [{ name = "HGV", email = "development@hgv.it" }]
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Repository = "https://github.com/bookingsuedtirol/mss-python"
|
|
16
|
+
|
|
17
|
+
[tool.setuptools.packages.find]
|
|
18
|
+
where = ["src"]
|
|
19
|
+
include = ["mss_python"]
|
|
20
|
+
namespaces = false
|
|
21
|
+
|
|
22
|
+
# [tool.setuptools_scm]
|
|
23
|
+
# version_file = "src/mss_python/_version.py"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
xmltodict==0.13.0
|
|
File without changes
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import xmltodict
|
|
3
|
+
import xml.etree.ElementTree as ET
|
|
4
|
+
|
|
5
|
+
from .request.methods import Method
|
|
6
|
+
from .request.types_mss import Root, BaseType, Credentials, Search, MethodName, Literal
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# maybe recursion should be used instead of doing if checks?
|
|
10
|
+
def change_structure(root: Root, child: BaseType):
|
|
11
|
+
if child.tag == "root":
|
|
12
|
+
return child
|
|
13
|
+
|
|
14
|
+
if child.tag == "request":
|
|
15
|
+
root.request = child
|
|
16
|
+
|
|
17
|
+
elif child.tag == "search":
|
|
18
|
+
root.request.search = child
|
|
19
|
+
|
|
20
|
+
elif child.tag == "order":
|
|
21
|
+
root.request.order = child
|
|
22
|
+
|
|
23
|
+
elif child.tag == "options":
|
|
24
|
+
root.request.options = child
|
|
25
|
+
|
|
26
|
+
elif child.tag == "logging":
|
|
27
|
+
root.request.logging = child
|
|
28
|
+
|
|
29
|
+
elif child.tag == "header":
|
|
30
|
+
root.header = child
|
|
31
|
+
|
|
32
|
+
return root
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Client:
|
|
36
|
+
def __init__(
|
|
37
|
+
self, cred: Credentials, lang: list, elements: list | None = None
|
|
38
|
+
) -> None:
|
|
39
|
+
self.cred = cred
|
|
40
|
+
self.lang = Search(lang)
|
|
41
|
+
|
|
42
|
+
def request(
|
|
43
|
+
self,
|
|
44
|
+
url: str,
|
|
45
|
+
method_name: MethodName,
|
|
46
|
+
data: BaseType | None = None,
|
|
47
|
+
_print: Literal[True, False] = False,
|
|
48
|
+
) -> dict:
|
|
49
|
+
"""
|
|
50
|
+
Makes a post request to the given URL with the specified data and method name.
|
|
51
|
+
|
|
52
|
+
data: ElementTree with the data required in the XML
|
|
53
|
+
url: Service URL
|
|
54
|
+
method: Method to be executed by the service
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
method = Method(method_name)
|
|
58
|
+
|
|
59
|
+
root = method.get_base_xml(self.cred, self.lang)
|
|
60
|
+
|
|
61
|
+
if data is None:
|
|
62
|
+
root = change_structure(root, data)
|
|
63
|
+
|
|
64
|
+
if _print is True:
|
|
65
|
+
print(ET.tostring(root.request.to_xml(), encoding="unicode"))
|
|
66
|
+
|
|
67
|
+
response = requests.post(
|
|
68
|
+
url,
|
|
69
|
+
data=ET.tostring(root.to_xml(), encoding="unicode"),
|
|
70
|
+
headers={"Content-Type": "application/xml"},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
responseRoot = xmltodict.parse(response.content)
|
|
74
|
+
error = responseRoot["root"]["header"]["error"]
|
|
75
|
+
if int(error["code"]) > 0:
|
|
76
|
+
raise Exception(
|
|
77
|
+
f'MSS returned an error: code {error["code"]}, message: "{error["message"]}"'
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return refine_response(responseRoot["root"], method_name)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def refine_response(resp: dict, meth: MethodName) -> dict:
|
|
84
|
+
if meth == MethodName.GetHotelList:
|
|
85
|
+
return refine_getHotelList(resp)
|
|
86
|
+
|
|
87
|
+
return resp
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def refine_getHotelList(resp: dict) -> dict:
|
|
91
|
+
if resp["result"] is None:
|
|
92
|
+
return resp
|
|
93
|
+
elif "hotel" not in resp["result"] or resp["result"]["hotel"] is None:
|
|
94
|
+
return resp
|
|
95
|
+
elif resp["result"]["hotel"] is list:
|
|
96
|
+
resp["result"]["hotel"] = [resp["result"]["hotel"]]
|
|
97
|
+
|
|
98
|
+
for hotel in resp["result"]["hotel"]:
|
|
99
|
+
ensure_list_value(hotel, "pictures", "picture")
|
|
100
|
+
ensure_list_value(hotel, "gallery", "picture")
|
|
101
|
+
ensure_list_value(hotel, "feature_view", "feature")
|
|
102
|
+
ensure_list_value(hotel, "pos", "id_pos")
|
|
103
|
+
|
|
104
|
+
return resp
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def ensure_list_value(hotel: dict, parent_fld: str, child_fld: str) -> None:
|
|
108
|
+
if parent_fld not in hotel:
|
|
109
|
+
hotel[parent_fld] = {child_fld: []}
|
|
110
|
+
elif hotel[parent_fld][child_fld] is list:
|
|
111
|
+
hotel[parent_fld][child_fld] = [hotel[parent_fld][child_fld]]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MethodName(Enum):
|
|
5
|
+
GetHotelList = "getHotelList"
|
|
6
|
+
GetHotelListByFilter = "getHotelListByFilter"
|
|
7
|
+
GetSpecialList = "getSpecialList"
|
|
8
|
+
GetRoomList = "getRoomList"
|
|
9
|
+
GetWidgetConfig = "getWidgetConfig"
|
|
10
|
+
GetPriceList = "getPriceList"
|
|
11
|
+
GetAvailability = "getAvailability"
|
|
12
|
+
GetRoomAvailability = "getRoomAvailability"
|
|
13
|
+
GetDayAvailability = "getDayAvailability"
|
|
14
|
+
PrepareBooking = "prepareBooking"
|
|
15
|
+
GetBooking = "getBooking"
|
|
16
|
+
CancelBooking = "cancelBooking"
|
|
17
|
+
CreateInquiry = "createInquiry"
|
|
18
|
+
GetInquiry = "getInquiry"
|
|
19
|
+
GetUserSources = "getUserSources"
|
|
20
|
+
GetLocationList = "getLocationList"
|
|
21
|
+
GetMasterpackagesList = "getMasterpackagesList"
|
|
22
|
+
NotifyMasterpackages = "notifyMasterpackages"
|
|
23
|
+
GetThemeList = "getThemeList"
|
|
24
|
+
GetLastminuteQuotations = "getLastminuteQuotations"
|
|
25
|
+
GetHotelPictures = "getHotelPictures"
|
|
26
|
+
GetHotelPictureGroups = "getHotelPictureGroups"
|
|
27
|
+
GetOptionalServices = "getOptionalServices"
|
|
28
|
+
ValidateCoupon = "validateCoupon"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .method_names import MethodName
|
|
4
|
+
from .types_mss import Credentials, Search, Root, Header, Request
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Method:
|
|
8
|
+
def __init__(self, name: MethodName):
|
|
9
|
+
self.name = name
|
|
10
|
+
|
|
11
|
+
def get_base_xml(self, cred: Credentials, lang: Search) -> Root:
|
|
12
|
+
"""
|
|
13
|
+
Returns an XML (ElementTree) with the mandatory elements needed for the request.
|
|
14
|
+
|
|
15
|
+
cred: XML Credentials Element (username, password, source)
|
|
16
|
+
|
|
17
|
+
lang: XML Search Element with the language element defined
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
header = Header(cred, self.name)
|
|
21
|
+
req = Request(lang)
|
|
22
|
+
root = Root(header, req)
|
|
23
|
+
return root
|