You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SOP/sop-sdk/sdk-python/request/BaseRequest.py

54 lines
1.2 KiB

4 years ago
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from response.BaseResponse import BaseResponse
class BaseRequest:
"""请求类的父类"""
biz_model = None
"""请求参数"""
files = None
"""上传文件"""
def __init__(self):
pass
def get_method(self):
"""返回接口名
:return: 返回接口名
:rtype: str
"""
raise Exception('未实现BaseRequest.get_method()方法')
def get_version(self):
"""返回接口版本号
:return: 返回版本号1.0
:rtype: str
"""
raise Exception('未实现BaseRequest.get_version()方法')
def get_request_type(self):
"""返回请求类型
:return: 返回RequestType类实例
:rtype: common.RequestType
"""
raise Exception('未实现BaseRequest.get_request_type()方法')
def parse_response(self, response_dict):
response_data = response_dict.get('error_response')
if response_data is None:
data_name = self.get_method().replace('.', '_') + '_response'
response_data = response_dict.get(data_name)
4 years ago
return response_data
4 years ago