Skip to content
Open
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
82 changes: 82 additions & 0 deletions com/alipay/ams/api/model/payment_quote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import json




class PaymentQuote:
def __init__(self):

self.__buy_currency = None # type: str
self.__sell_currency = None # type: str
self.__quote_id = None # type: str
self.__exchange_rate = None # type: float


@property
def buy_currency(self):
"""
商户视角下买入的币种 - 商户订单定价币种
"""
return self.__buy_currency

@buy_currency.setter
def buy_currency(self, value):
self.__buy_currency = value
@property
def sell_currency(self):
"""
商户视角下卖出的币种 - 用户支付币种
"""
return self.__sell_currency

@sell_currency.setter
def sell_currency(self, value):
self.__sell_currency = value
@property
def quote_id(self):
"""
蚂蚁为此次报价颁发的唯一id
"""
return self.__quote_id

@quote_id.setter
def quote_id(self, value):
self.__quote_id = value
@property
def exchange_rate(self):
"""
商户可直接用于乘法计算的最终汇率值,精度统一为15位decimal place
"""
return self.__exchange_rate

@exchange_rate.setter
def exchange_rate(self, value):
self.__exchange_rate = value




def to_ams_dict(self):
params = dict()
if hasattr(self, "buy_currency") and self.buy_currency is not None:
params['buyCurrency'] = self.buy_currency
if hasattr(self, "sell_currency") and self.sell_currency is not None:
params['sellCurrency'] = self.sell_currency
if hasattr(self, "quote_id") and self.quote_id is not None:
params['quoteId'] = self.quote_id
if hasattr(self, "exchange_rate") and self.exchange_rate is not None:
params['exchangeRate'] = self.exchange_rate
return params


def parse_rsp_body(self, response_body):
if isinstance(response_body, str):
response_body = json.loads(response_body)
if 'buyCurrency' in response_body:
self.__buy_currency = response_body['buyCurrency']
if 'sellCurrency' in response_body:
self.__sell_currency = response_body['sellCurrency']
if 'quoteId' in response_body:
self.__quote_id = response_body['quoteId']
if 'exchangeRate' in response_body:
self.__exchange_rate = response_body['exchangeRate']
24 changes: 24 additions & 0 deletions com/alipay/ams/api/model/rate_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from enum import Enum, unique
@unique
class RateType(Enum):
"""RateType枚举类"""

TRADE = "TRADE"
REFERENCE = "REFERENCE"
REFERENCE_TRADE = "REFERENCE_TRADE"

def to_ams_dict(self) -> str:
return self.name

@staticmethod
def value_of(value):
if not value:
return None

if RateType.TRADE.value == value:
return RateType.TRADE
if RateType.REFERENCE.value == value:
return RateType.REFERENCE
if RateType.REFERENCE_TRADE.value == value:
return RateType.REFERENCE_TRADE
return None
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from com.alipay.ams.api.model.currency_pair import CurrencyPair
from com.alipay.ams.api.model.product_code_type import ProductCodeType
from com.alipay.ams.api.model.rate_type import RateType



Expand All @@ -16,6 +17,7 @@ def __init__(self):
self.__sell_currency = None # type: str
self.__buy_currency = None # type: str
self.__product_code = None # type: ProductCodeType
self.__rate_type = None # type: RateType


@property
Expand Down Expand Up @@ -78,6 +80,16 @@ def product_code(self):
@product_code.setter
def product_code(self, value):
self.__product_code = value
@property
def rate_type(self):
"""Gets the rate_type of this AlipayInquireExchangeRateRequest.

"""
return self.__rate_type

@rate_type.setter
def rate_type(self, value):
self.__rate_type = value


def to_ams_json(self):
Expand All @@ -99,6 +111,8 @@ def to_ams_dict(self):
params['buyCurrency'] = self.buy_currency
if hasattr(self, "product_code") and self.product_code is not None:
params['productCode'] = self.product_code
if hasattr(self, "rate_type") and self.rate_type is not None:
params['rateType'] = self.rate_type
return params


Expand All @@ -122,3 +136,6 @@ def parse_rsp_body(self, response_body):
if 'productCode' in response_body:
product_code_temp = ProductCodeType.value_of(response_body['productCode'])
self.__product_code = product_code_temp
if 'rateType' in response_body:
rate_type_temp = RateType.value_of(response_body['rateType'])
self.__rate_type = rate_type_temp