Skip to content

Commit

Permalink
Initial version of DHL
Browse files Browse the repository at this point in the history
  • Loading branch information
arjenbos committed Oct 1, 2024
1 parent 55d13e9 commit e8e3ea2
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions custom_components/postnl/dhl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import logging

import requests
from requests.adapters import HTTPAdapter
from urllib3 import Retry

_LOGGER = logging.getLogger(__name__)


class DHL:
base_url: str = "https://my.dhlecommerce.nl/"

def __init__(self):
self.client = requests.Session()
self.client.mount(
prefix='https://',
adapter=HTTPAdapter(
max_retries=Retry(
total=5,
backoff_factor=3
)
)
)

def login(self, username: str, password: str):
return self.client.post(
url=self.base_url + 'api/user/login',
json={
'email': username,
'password': password
}
).json()

def user(self):
return self.client.get(
url=self.base_url + 'api/user',
).json()

def parcels(self):
return self.client.get(
url=self.base_url + 'receiver-parcel-api/parcels',
).json()

0 comments on commit e8e3ea2

Please sign in to comment.