Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions unit/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,19 @@ def from_json_api(l: List):


class AuthorizedUser(UnitDTO):
def __init__(self, full_name: FullName, email: str, phone: Phone):
def __init__(self, full_name: FullName, email: str, phone: Phone, jwt_subject: Optional[str] = None):
self.full_name = full_name
self.email = email
self.phone = phone
self.jwt_subject = jwt_subject

@staticmethod
def from_json_api(l: List) -> List:
authorized_users = []
for data in l:
authorized_users.append(
AuthorizedUser(
data.get("fullName"), data.get("email"), data.get("phone")
data.get("fullName"), data.get("email"), data.get("phone"), data.get("jwtSubject")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

)
)
return authorized_users
Expand Down
5 changes: 4 additions & 1 deletion unit/models/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ def default(self, obj):
if isinstance(obj, BusinessContact):
return {"fullName": obj.full_name, "email": obj.email, "phone": obj.phone}
if isinstance(obj, AuthorizedUser):
return {"fullName": obj.full_name, "email": obj.email, "phone": obj.phone}
authorized_user = {"fullName": obj.full_name, "email": obj.email, "phone": obj.phone}
if obj.jwt_subject is not None:
authorized_user["jwtSubject"] = obj.jwt_subject
return authorized_user
Comment on lines +462 to +465
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎈

if isinstance(obj, Officer):
officer = {"fullName": obj.full_name, "dateOfBirth": date_utils.to_date_str(obj.date_of_birth),
"address": obj.address, "phone": obj.phone, "email": obj.email}
Expand Down
6 changes: 5 additions & 1 deletion unit/models/customerToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def from_json_api(_id, _type, attributes, relationships):

class CreateCustomerToken(UnitRequest):
def __init__(self, customer_id: str, scope: str, verification_token: Optional[str] = None,
verification_code: Optional[str] = None, expires_in: Optional[int] = None):
verification_code: Optional[str] = None, expires_in: Optional[int] = None, jwt_token: Optional[str] = None):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

self.customer_id = customer_id
self.scope = scope
self.verification_token = verification_token
self.verification_code = verification_code
self.expires_in = expires_in
self.jwt_token = jwt_token

def to_json_api(self) -> Dict:
payload = {
Expand All @@ -47,6 +48,9 @@ def to_json_api(self) -> Dict:
if self.verification_code:
payload["data"]["attributes"]["verificationCode"] = self.verification_code

if self.jwt_token:
payload["data"]["attributes"]["jwtToken"] = self.jwt_token

return payload

def __repr__(self):
Expand Down
Loading