bugfix
This commit is contained in:
parent
d60ff4b2b3
commit
79c04c340e
@ -56,7 +56,7 @@ class HttpClient:
|
||||
print(f'=====domain={domain},cookies={fltered},type={type(fltered)}===')
|
||||
|
||||
async def request(self, url, method,
|
||||
resp_type=RESPONSE_TEXT,
|
||||
response_type=RESPONSE_TEXT,
|
||||
params=None,
|
||||
data=None,
|
||||
json=None,
|
||||
@ -69,7 +69,7 @@ class HttpClient:
|
||||
json=json,
|
||||
headers=headers, **kw)
|
||||
if resp.status==200:
|
||||
return await self.handleResponse(url, resp, resp_type)
|
||||
return await self.handleResp(url, resp, response_type)
|
||||
return None
|
||||
|
||||
async def get(self,url,**kw):
|
||||
|
@ -8,12 +8,12 @@ class OAuthClient:
|
||||
assert desc.get('mapis')
|
||||
self.desc = desc
|
||||
self.data = desc.get('data')
|
||||
self.mapis = desc.get(mapis)
|
||||
self.mapis = desc.get('mapis')
|
||||
self.mkeys = self.mapis.keys()
|
||||
|
||||
self.ac = ArgsConvert('${', '}')
|
||||
|
||||
aysnc def __call__(self, mapi, params):
|
||||
async def __call__(self, mapi, params):
|
||||
if mapi not in self.mkeys:
|
||||
raise Exception(f'{mapi} not defined')
|
||||
d = self.mapis[mapi]
|
||||
@ -24,21 +24,28 @@ class OAuthClient:
|
||||
headers[h.get('name')] = h.get('value')
|
||||
myparams = {}
|
||||
for p in d.get('params', {}):
|
||||
myparams[[p.get('name')] = p.get('value')
|
||||
myparams[p.get('name')] = p.get('value')
|
||||
url = d.get('url')
|
||||
_params = self.datalize(myparams, params)
|
||||
_headers = self.datalize(headers, params)
|
||||
|
||||
response_type = d.get('response_type', RESPONSE_JSON)
|
||||
hc = HttpClient()
|
||||
resp_data = hc.request(url, method, response_type=resp_type,
|
||||
params=params,
|
||||
headers=headers)
|
||||
respdesc= d.get('response', [])
|
||||
resp_data = await hc.request(url, method, response_type=response_type,
|
||||
params=_params,
|
||||
headers=_headers)
|
||||
if resp_data is None:
|
||||
raise Exception(f'request error:{url=}\n{method=}\n{response_type=}\n{_params=}\n{_headers=}')
|
||||
errfield = d.get('error_field')
|
||||
err = resp_data.get(errfield)
|
||||
if err:
|
||||
msg = resp_data.get(d.get('error_msg_field'))
|
||||
raise Exception(f'Error:{url}\n{msg}')
|
||||
|
||||
respdesc= d.get('resp_set_data', [])
|
||||
for r in respdesc:
|
||||
v = r['value']
|
||||
if v.startswith('${') and v.endswith('}'):
|
||||
k = v[2:-1]
|
||||
self.data[k] = resp_data[r['name']]
|
||||
v = resp_data[r['field']]
|
||||
k = r['name']
|
||||
self.data[k] = v
|
||||
return resp_data
|
||||
|
||||
def datalize(self, dic, data={}):
|
||||
|
Loading…
Reference in New Issue
Block a user