|
| 1 | +import json |
| 2 | + |
| 3 | +from com.alipay.ams.api.model.agreement_info import AgreementInfo |
| 4 | +from com.alipay.ams.api.model.antom_path_constants import AntomPathConstants |
| 5 | +from com.alipay.ams.api.model.payment_method import PaymentMethod |
| 6 | +from com.alipay.ams.api.model.product_code_type import ProductCodeType |
| 7 | +from com.alipay.ams.api.model.scope_type import ScopeType |
| 8 | +from com.alipay.ams.api.request.alipay_request import AlipayRequest |
| 9 | + |
| 10 | + |
| 11 | +class AlipayAuthCreateSessionRequest(AlipayRequest): |
| 12 | + def __init__(self): |
| 13 | + super(AlipayAuthCreateSessionRequest, self).__init__(AntomPathConstants.CREATE_SESSION_PATH) |
| 14 | + self.__product_code = None # type:ProductCodeType |
| 15 | + self.__agreement_info = None # type:AgreementInfo |
| 16 | + self.__scopes = None # type:list[ScopeType] |
| 17 | + self.__payment_method = None # type:PaymentMethod |
| 18 | + self.__payment_redirect_url = None |
| 19 | + |
| 20 | + @property |
| 21 | + def product_code(self): |
| 22 | + return self.__product_code |
| 23 | + |
| 24 | + @product_code.setter |
| 25 | + def product_code(self, value: ProductCodeType): |
| 26 | + self.__product_code = value |
| 27 | + |
| 28 | + @property |
| 29 | + def agreement_info(self): |
| 30 | + return self.__agreement_info |
| 31 | + |
| 32 | + @agreement_info.setter |
| 33 | + def agreement_info(self, value: AgreementInfo): |
| 34 | + self.__agreement_info = value |
| 35 | + |
| 36 | + @property |
| 37 | + def scopes(self): |
| 38 | + return self.__scopes |
| 39 | + |
| 40 | + @scopes.setter |
| 41 | + def scopes(self, value: list[ScopeType]): |
| 42 | + self.__scopes = value |
| 43 | + |
| 44 | + @property |
| 45 | + def payment_method(self): |
| 46 | + return self.__payment_method |
| 47 | + |
| 48 | + @payment_method.setter |
| 49 | + def payment_method(self, value: PaymentMethod): |
| 50 | + self.__payment_method = value |
| 51 | + |
| 52 | + @property |
| 53 | + def payment_redirect_url(self): |
| 54 | + return self.__payment_redirect_url |
| 55 | + |
| 56 | + @payment_redirect_url.setter |
| 57 | + def payment_redirect_url(self, value: str): |
| 58 | + self.__payment_redirect_url = value |
| 59 | + |
| 60 | + def to_ams_json(self): |
| 61 | + json_str = json.dumps(obj=self.__to_ams_dict(), default=lambda o: o.to_ams_dict(), indent=3) |
| 62 | + return json_str |
| 63 | + |
| 64 | + def __to_ams_dict(self): |
| 65 | + params = dict() |
| 66 | + if hasattr(self, "product_code") and self.product_code: |
| 67 | + params['productCodeType'] = self.product_code |
| 68 | + |
| 69 | + if hasattr(self, "agreement_info") and self.agreement_info: |
| 70 | + params['agreementInfo'] = self.agreement_info.to_ams_json() |
| 71 | + |
| 72 | + if hasattr(self, "scopes") and self.scopes: |
| 73 | + scopes_list = [] |
| 74 | + for scope in self.scopes: |
| 75 | + scopes_list.append(scope.value) |
| 76 | + params['scopes'] = scopes_list |
| 77 | + |
| 78 | + if hasattr(self, "payment_method") and self.payment_method: |
| 79 | + params['paymentMethod'] = self.payment_method.to_ams_dict() |
| 80 | + |
| 81 | + if hasattr(self, "payment_redirect_url") and self.payment_redirect_url: |
| 82 | + params['paymentRedirectUrl'] = self.payment_redirect_url |
| 83 | + |
| 84 | + return params |
0 commit comments