helloasso-paheko-adapter/helloasso_paheko_adapter/sandbox/sandbox1.py

44 lines
1.4 KiB
Python
Raw Permalink Normal View History

2023-11-06 10:14:16 +00:00
import os
from paheko_helloasso_adapter.helloasso import HelloassoClient, Organization
from pprint import pprint
class Env:
HELLOASSO_API_CLIENT_ID: str
HELLOASSO_API_CLIENT_SECRET: str
def __init__(self):
attr_keys = list(self.__class__.__dict__.keys()) + list(self.__annotations__.keys())
for k in attr_keys:
if k.startswith('__'): continue
from_env = None
if k in os.environ:
from_env = os.environ[k]
setattr(self, k, from_env)
def main():
env = Env()
# api_client = ApiV5Client(
# api_base='api.helloasso.com',
# client_id=env.HELLOASSO_API_CLIENT_ID,
# client_secret=env.HELLOASSO_API_CLIENT_SECRET,
# timeout=60
# )
# class OrganizationApi(object):
# def __init__(self, client):
# self._client = client
# def list(self) -> dict:
# return self._client.call(f"/organizations").json()
# def get_by_slug(self, slug: str) -> dict:
# return self._client.call(f"/organizations/{slug}").json()
# org_api = OrganizationApi(api_client)
org_slug = "l-etoile-de-bethleem-association-des-amis-de-la-chapelle-de-bethleem-d-aubevoye"
client = HelloassoClient(env.HELLOASSO_API_CLIENT_ID, env.HELLOASSO_API_CLIENT_SECRET)
o = Organization(client, org_slug)
pprint(o.list_payments())