Add license, retrieve crew profile picture
This commit is contained in:
parent
fd73fce375
commit
67c06af2a8
6 changed files with 54 additions and 5 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Kumi Systems e.U. <office@kumi.systems>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -1,4 +1,5 @@
|
||||||
from urllib.request import urlopen, Request, urljoin
|
from urllib.request import urlopen, Request, urljoin
|
||||||
|
from base64 import b64decode
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -7,6 +8,8 @@ from classes.crew import Crew
|
||||||
|
|
||||||
from const import USER_AGENT
|
from const import USER_AGENT
|
||||||
|
|
||||||
|
from PIL.Image import Image
|
||||||
|
|
||||||
|
|
||||||
class Adonis:
|
class Adonis:
|
||||||
def __init__(self, crew_portal_base_url: str, login: str, password: str):
|
def __init__(self, crew_portal_base_url: str, login: str, password: str):
|
||||||
|
@ -27,7 +30,7 @@ class Adonis:
|
||||||
req.add_header("Accept", "application/json")
|
req.add_header("Accept", "application/json")
|
||||||
|
|
||||||
if add_token:
|
if add_token:
|
||||||
payload["Authentication_Token"] = self.getToken()
|
payload["Authentication_Token"] = self.getTokenCrewPortal()
|
||||||
|
|
||||||
if wrap_request:
|
if wrap_request:
|
||||||
payload = {"request": payload}
|
payload = {"request": payload}
|
||||||
|
@ -70,7 +73,25 @@ class Adonis:
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getCrew(self, pin):
|
def getCrewProfilePicture(self, pin):
|
||||||
|
data = {
|
||||||
|
"Pin": pin
|
||||||
|
}
|
||||||
|
|
||||||
|
result = self.requestCrewPortal("DG_ProfilePictureRead", data)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return result["FileBase64"]
|
||||||
|
except AdonisError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getCrew(self, pin, personal_data=True, profile_picture=True):
|
||||||
crew = Crew(pin)
|
crew = Crew(pin)
|
||||||
|
|
||||||
|
if personal_data:
|
||||||
crew._personal_data = self.getCrewPersonalData(pin)
|
crew._personal_data = self.getCrewPersonalData(pin)
|
||||||
|
|
||||||
|
if profile_picture:
|
||||||
|
crew._profile_picture = self.getCrewProfilePicture(pin)
|
||||||
|
|
||||||
return crew
|
return crew
|
|
@ -2,6 +2,7 @@ class Crew:
|
||||||
def __init__(self, pin):
|
def __init__(self, pin):
|
||||||
self.pin = pin
|
self.pin = pin
|
||||||
self._personal_data = None
|
self._personal_data = None
|
||||||
|
self._profile_picture = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def firstName(self):
|
def firstName(self):
|
||||||
|
@ -18,3 +19,7 @@ class Crew:
|
||||||
@property
|
@property
|
||||||
def birthDate(self):
|
def birthDate(self):
|
||||||
return self._personal_data["DetailsAll"]["Details"]["BirthDate"]
|
return self._personal_data["DetailsAll"]["Details"]["BirthDate"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def profilePicture(self):
|
||||||
|
return self._profile_picture
|
2
const.py
2
const.py
|
@ -1 +1 @@
|
||||||
USER_AGENT = "PyAdonis / dev (https://kumi.systems)"
|
USER_AGENT = "PyAdonis/dev (https://kumi.systems)"
|
|
@ -0,0 +1 @@
|
||||||
|
pillow
|
|
@ -24,6 +24,7 @@ if __name__ == "__main__":
|
||||||
crewdata["lastName"] = crew.lastName
|
crewdata["lastName"] = crew.lastName
|
||||||
crewdata["dob"] = crew.birthDate
|
crewdata["dob"] = crew.birthDate
|
||||||
crewdata["password"] = crew.birthDate.replace("-","")
|
crewdata["password"] = crew.birthDate.replace("-","")
|
||||||
|
crewdata["profilePicture"] = crew.profilePicture
|
||||||
|
|
||||||
data[pin] = crewdata
|
data[pin] = crewdata
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue