|
@@ -383,3 +383,44 @@ class TelecomObject:
|
|
LOGGER.info('***TelecomObject.query_traffic_by_date:errLine:{}, errMsg:{}'
|
|
LOGGER.info('***TelecomObject.query_traffic_by_date:errLine:{}, errMsg:{}'
|
|
.format(e.__traceback__.tb_lineno, repr(e)))
|
|
.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return None
|
|
return None
|
|
|
|
+
|
|
|
|
+ def query_product_information(self, access_number):
|
|
|
|
+ """
|
|
|
|
+ 产品资料查询接口
|
|
|
|
+ :param access_number: 接入号码access_number。
|
|
|
|
+ :return: SIM卡的产品资料,包含基础信息、套餐、状态及 断网类型等
|
|
|
|
+ :raises ValueError: 如果响应为空或HTTP请求失败。
|
|
|
|
+ """
|
|
|
|
+ try:
|
|
|
|
+ if not access_number:
|
|
|
|
+ raise ValueError("*****TelecomObject.query_product_information error****access_number不能为空")
|
|
|
|
+ method = 'prodInstQuery'
|
|
|
|
+ arr = [method, self.user_id, access_number, self.password]
|
|
|
|
+ re_params = self.get_params_dict_by_access_number(method, access_number, arr)
|
|
|
|
+ response = self.session.get(self.url, params=re_params)
|
|
|
|
+
|
|
|
|
+ if response.status_code != 200:
|
|
|
|
+ LOGGER.info(f"*****TelecomObject.query_product_information error HTTP请求失败,状态码: {response.status_code}")
|
|
|
|
+ return None
|
|
|
|
+
|
|
|
|
+ msg = response.text
|
|
|
|
+ if not msg:
|
|
|
|
+ return None
|
|
|
|
+
|
|
|
|
+ content_type = response.headers.get('Content-Type', '')
|
|
|
|
+ if 'application/xml' in content_type or 'text/xml' in content_type:
|
|
|
|
+ result = xmltodict.parse(msg)
|
|
|
|
+ elif 'application/json' in content_type or 'text/json' in content_type:
|
|
|
|
+ result = json.loads(msg)
|
|
|
|
+ LOGGER.info(f"***TelecomObject.query_product_information 查询产品资料异常:{access_number},error{result}")
|
|
|
|
+ return None
|
|
|
|
+ else:
|
|
|
|
+ LOGGER.info("***TelecomObject.query_product_information 无法识别的响应类型: {}".format(content_type))
|
|
|
|
+ return None
|
|
|
|
+ return result
|
|
|
|
+
|
|
|
|
+ except Exception as e:
|
|
|
|
+ LOGGER.info('***TelecomObject.query_product_information:errLine:{}, errMsg:{}'
|
|
|
|
+ .format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+ return None
|
|
|
|
+
|