diff --git a/unit/models/__init__.py b/unit/models/__init__.py index aef251e..19c3d2c 100644 --- a/unit/models/__init__.py +++ b/unit/models/__init__.py @@ -332,10 +332,11 @@ 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: @@ -343,7 +344,7 @@ def from_json_api(l: List) -> List: 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") ) ) return authorized_users diff --git a/unit/models/codecs.py b/unit/models/codecs.py index 6e78950..aed24b2 100644 --- a/unit/models/codecs.py +++ b/unit/models/codecs.py @@ -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 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} diff --git a/unit/models/customerToken.py b/unit/models/customerToken.py index 856ab64..b8a5b15 100644 --- a/unit/models/customerToken.py +++ b/unit/models/customerToken.py @@ -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): 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 = { @@ -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):