Add license, retrieve crew profile picture

This commit is contained in:
Kumi 2022-04-08 11:45:05 +02:00
parent fd73fce375
commit 67c06af2a8
Signed by: kumi
GPG key ID: 5D1CE6AF1805ECA2
6 changed files with 54 additions and 5 deletions

21
LICENSE Normal file
View 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.

View file

@ -1,4 +1,5 @@
from urllib.request import urlopen, Request, urljoin
from base64 import b64decode
import json
@ -7,6 +8,8 @@ from classes.crew import Crew
from const import USER_AGENT
from PIL.Image import Image
class Adonis:
def __init__(self, crew_portal_base_url: str, login: str, password: str):
@ -27,7 +30,7 @@ class Adonis:
req.add_header("Accept", "application/json")
if add_token:
payload["Authentication_Token"] = self.getToken()
payload["Authentication_Token"] = self.getTokenCrewPortal()
if wrap_request:
payload = {"request": payload}
@ -70,7 +73,25 @@ class Adonis:
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._personal_data = self.getCrewPersonalData(pin)
if personal_data:
crew._personal_data = self.getCrewPersonalData(pin)
if profile_picture:
crew._profile_picture = self.getCrewProfilePicture(pin)
return crew

View file

@ -2,6 +2,7 @@ class Crew:
def __init__(self, pin):
self.pin = pin
self._personal_data = None
self._profile_picture = None
@property
def firstName(self):
@ -17,4 +18,8 @@ class Crew:
@property
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

View file

@ -1 +1 @@
USER_AGENT = "PyAdonis / dev (https://kumi.systems)"
USER_AGENT = "PyAdonis/dev (https://kumi.systems)"

View file

@ -0,0 +1 @@
pillow

View file

@ -24,6 +24,7 @@ if __name__ == "__main__":
crewdata["lastName"] = crew.lastName
crewdata["dob"] = crew.birthDate
crewdata["password"] = crew.birthDate.replace("-","")
crewdata["profilePicture"] = crew.profilePicture
data[pin] = crewdata