Skip to content

Commit

Permalink
feat: implement /me endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ustuehler committed Jun 21, 2022
1 parent 676f719 commit cd60aa1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "amazing_marvin"
version = "0.0.2"
version = "0.0.3"
authors = [
{ name="Uwe Stuehler", email="[email protected]" },
]
Expand Down
21 changes: 17 additions & 4 deletions src/amazing_marvin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import json

import requests as requests

API_URL = 'https://serv.amazingmarvin.com/api'


class AmazingMarvinAPI:
def __init__(self, api_token: str):
self._api_token = api_token
self._session = requests.Session()
self._session.headers['X-API-Token'] = api_token

def me(self) -> dict[str, any]:
return {
'email': "[email protected]"
}
return self._get_json_response_data('/me')

def _get_json_response_data(self, path: str) -> any:
response = self._session.get(f"{API_URL}{path}")
response.raise_for_status()

data = json.loads(response.content)
return data

0 comments on commit cd60aa1

Please sign in to comment.