refactor: replace requests_async w/ httpx

This commit is contained in:
Brian Berg 2020-07-12 02:40:39 +00:00
parent 74d9f14439
commit df20a0686d
3 changed files with 10 additions and 11 deletions

View File

@ -8,6 +8,6 @@
"@brianberg"
],
"requirements": [
"requests_async"
"httpx"
]
}

View File

@ -8,8 +8,8 @@ References:
from datetime import datetime
from hashlib import sha256
import hmac
import httpx
import json
import requests_async as requests
import sys
from time import mktime
import uuid
@ -75,12 +75,12 @@ class NiceHashPublicClient:
if query is not None:
url += f"?{query}"
async with requests.Session() as session:
async with httpx.AsyncClient() as client:
if body:
data = json.dumps(body)
response = await session.request(method, url, data=data)
response = await client.request(method, url, data=data)
else:
response = await session.request(method, url)
response = await client.request(method, url)
if response.status_code == 200:
return response.json()
@ -134,8 +134,8 @@ class NiceHashPrivateClient:
"X-Request-Id": str(uuid.uuid4()),
}
async with requests.Session() as session:
session.headers = headers
async with httpx.AsyncClient() as client:
client.headers = headers
url = NICEHASH_API_URL + path
if query:
@ -145,9 +145,9 @@ class NiceHashPrivateClient:
print(method, url)
if data:
response = await session.request(method, url, data=data)
response = await client.request(method, url, data=data)
else:
response = await session.request(method, url)
response = await client.request(method, url)
if response.status_code == 200:
return response.json()

View File

@ -3,6 +3,5 @@
"domains": [
"sensor"
],
"iot_class": "Cloud Polling",
"homeassistant": "0.108.0"
"iot_class": "Cloud Polling"
}