当前位置: 首页>>代码示例>>Python>>正文


Python Validator.isValidPhoneRequest方法代码示例

本文整理汇总了Python中validator.Validator.isValidPhoneRequest方法的典型用法代码示例。如果您正苦于以下问题:Python Validator.isValidPhoneRequest方法的具体用法?Python Validator.isValidPhoneRequest怎么用?Python Validator.isValidPhoneRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator.Validator的用法示例。


在下文中一共展示了Validator.isValidPhoneRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from validator import Validator [as 别名]
# 或者: from validator.Validator import isValidPhoneRequest [as 别名]

#.........这里部分代码省略.........
				self.apiRoot = self.PROD_ENDPOINT
			elif (env == "test" or env == "sandbox"):
				self.apiRoot = self.TEST_ENDPOINT
			else: 
				raise ValueError('Something is wrong with your requested API Environment. Please verify it and try again.')
		return

	def getDefaultHttpHeaders(self): 
		"""Return the default Headers object common to all API calls"""
		return {
				'User-Agent': 'Wealthengine Python SDK', 
				'Content-type': 'application/json', 
				'Accept': 'application/json',
				'Cache-control': 'none',
				'Authorization': 'APIKey ' + self.apiKey
			}

	def returnAPIResponse(self, r): 
		"""Append the http status code to the response object and return to caller

			:param r - <object> a handle to the last completed request

		"""
		return { "status_code": r.status_code, "response": r.text }

	def getProfileByEmail(self, params_dict):
		"""Attempt to lookup a WealthEngine Profile by email

			:param params_dict - <dictionary> A dict containing the POST fields and their data

		"""
		#Ensure request parameters are properly formed
		if (self.Validator.isValidEmailRequest(params_dict)):
			endpoint = self.apiRoot + 'profile/find_one/by_email/basic'

			#Make the POST Request - setting headers and POST body
			r = requests.post(endpoint, headers=self.getDefaultHttpHeaders(), data=json.dumps(params_dict))

			return self.returnAPIResponse(r); 
		else: 
			return self.raiseParamsException('getProfileByEmail')
	
	def getProfileByAddress(self, params_dict):
		"""Attempt to lookup a WealthEngine Profile by address

			:param params_dict - <dictionary> A dict containing the POST fields and their data

		"""
		#Ensure request parameters are properly formed
		if (self.Validator.isValidAddressRequest(params_dict)): 
			endpoint = self.apiRoot + 'profile/find_one/by_address/basic'

			#Make the POST Request - setting headers and POST body
			r = requests.post(endpoint, headers=self.getDefaultHttpHeaders(), data=json.dumps(params_dict))

			return self.returnAPIResponse(r); 
		else:
			return self.raiseParamsException('getProfileByAddress')

	def getProfileByPhone(self, params_dict): 
		"""Attempt to lookup a WealthEngine Profile by phone

			:param params_dict - <dictionary> A dict containing the POST fields and their data

		"""
		#Ensure request parameters are properly formed
		if (self.Validator.isValidPhoneRequest(params_dict)): 
			endpoint = self.apiRoot + 'profile/find_one/by_phone/basic'

			#Make the POST Request - setting headers and POST body
			r = requests.post(endpoint, headers = self.getDefaultHttpHeaders(), data=json.dumps(params_dict))

			return self.returnAPIResponse(r); 
		else: 
			return self.raiseParamsException('getProfileByPhone');

	def createSession(self, params_dict):
		"""Attempt to create a session to authenticate future calls to the WealthEngine API

			:param params_dict - <dictionary> A dict containing the POST fields and their data

		""" 
		#Ensure request parameters are properly formed
		if (self.Validator.isAValidSessionRequest(params_dict)): 

			endpoint = self.apiRoot + 'session/create'

			r = requests.post(endpoint, headers=self.getDefaultHttpHeaders(), data=json.dumps(params_dict))
		
			return self.returnAPIResponse(r); 
		else: 
			return self.raiseParamsException('createSession'); 

	def raiseParamsException(endpoint_name): 
		"""Raise an exception due to API call parameters being mis-configured

			:param endpoint_name - <string> The name of the endpoint that is raising the exception

		"""
		raise ValueException('Your ' + endpoint_name + ' params were improperly formatted. Please check them and try again')
开发者ID:Eagles0607,项目名称:WealthEngine-Python-SDK,代码行数:104,代码来源:__init__.py


注:本文中的validator.Validator.isValidPhoneRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。