Skip to content

Latest commit

 

History

History
344 lines (290 loc) · 26 KB

README.md

File metadata and controls

344 lines (290 loc) · 26 KB

helloasso-python

The HelloAsso Python library offers a straightforward way to interact with the HelloAsso API in Python applications. It features a collection of pre-built classes for API resources that automatically adapt to API responses, ensuring flexibility across different versions of the HelloAsso API.

Requirements.

Python 3.8+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install helloasso-python

(you may need to run pip with root permission: sudo pip install helloasso-python)

Then import the package:

import helloasso_python

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import helloasso_python

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import helloasso_python
from helloasso_python.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.helloasso.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = helloasso_python.Configuration(
    host = "https://api.helloasso.com/v5"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]


# Enter a context with an instance of the API client
with helloasso_python.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = helloasso_python.AnnuaireApi(api_client)
    page_size = 20 # int | The number of items per page (optional) (default to 20)
    continuation_token = 'continuation_token_example' # str | Continuation Token from which we wish to retrieve results (optional)
    hello_asso_api_v5_models_directory_list_forms_request = helloasso_python.HelloAssoApiV5ModelsDirectoryListFormsRequest() # HelloAssoApiV5ModelsDirectoryListFormsRequest | Body which contains the filters to apply (optional)

    try:
        # Récupérer les formulaires
        api_response = api_instance.directory_forms_post(page_size=page_size, continuation_token=continuation_token, hello_asso_api_v5_models_directory_list_forms_request=hello_asso_api_v5_models_directory_list_forms_request)
        print("The response of AnnuaireApi->directory_forms_post:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AnnuaireApi->directory_forms_post: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.helloasso.com/v5

Class Method HTTP request Description
AnnuaireApi directory_forms_post POST /directory/forms Récupérer les formulaires
AnnuaireApi directory_organizations_post POST /directory/organizations Récupérer les organisations
CheckoutApi organizations_organization_slug_checkout_intents_checkout_intent_id_get GET /organizations/{organizationSlug}/checkout-intents/{checkoutIntentId} Récupérer une intention de paiement
CheckoutApi organizations_organization_slug_checkout_intents_post POST /organizations/{organizationSlug}/checkout-intents Initialisation d'un Checkout
CommandesApi items_item_id_get GET /items/{itemId} Obtenir le détail d'un article contenu dans une commande
CommandesApi orders_order_id_cancel_post POST /orders/{orderId}/cancel Annuler les paiements futurs pour une commande (pas de remboursement).
CommandesApi orders_order_id_get GET /orders/{orderId} Obtenir des informations détaillées sur une commande
CommandesApi organizations_organization_slug_forms_form_type_form_slug_items_get GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/items Obtenir une liste d'articles vendus dans un formulaire
CommandesApi organizations_organization_slug_forms_form_type_form_slug_orders_get GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/orders Obtenir les commandes d'un formulaire
CommandesApi organizations_organization_slug_items_get GET /organizations/{organizationSlug}/items Obtenir une liste d'articles vendus par une organisation
CommandesApi organizations_organization_slug_orders_get GET /organizations/{organizationSlug}/orders Obtenir les commandes d'une organisation
FormulairesApi organizations_organization_slug_form_types_get GET /organizations/{organizationSlug}/formTypes Obtenir une liste des types de formulaires pour une organisation
FormulairesApi organizations_organization_slug_forms_form_type_action_quick_create_post POST /organizations/{organizationSlug}/forms/{formType}/action/quick-create Créer un événement simplifié pour un organisme
FormulairesApi organizations_organization_slug_forms_form_type_form_slug_public_get GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/public Obtenir des données publiques détaillées sur un formulaire
FormulairesApi organizations_organization_slug_forms_get GET /organizations/{organizationSlug}/forms Obtenir les formulaires d'une organisation
ListeDeValeursApi values_company_legal_status_get GET /values/company-legal-status Obtenir la liste des statuts juridiques
ListeDeValeursApi values_organization_categories_get GET /values/organization/categories Obtenir la liste des catégories du JO
ListeDeValeursApi values_tags_get GET /values/tags Obtenir la liste des tags publiques
OrganisationApi organizations_legal_informations_legal_structures_get GET /organizations/legal-informations/legal-structures Obtenir la structure juridique d'une organisation visible.
OrganisationApi organizations_legal_informations_organization_slug_configuration_get GET /organizations/legal-informations/{organizationSlug}/configuration
OrganisationApi organizations_legal_informations_tax_information_texts_get GET /organizations/legal-informations/tax-information-texts
OrganisationApi organizations_organization_slug_get GET /organizations/{organizationSlug} Obtenir le détail d'une organisation
OrganizationLegalInformationsApi organizations_legal_informations_organization_slug_configuration_put PUT /organizations/legal-informations/{organizationSlug}/configuration
PaiementsApi organizations_organization_slug_forms_form_type_form_slug_payments_get GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/payments Obtenir les informations des paiements effectués sur un formulaire
PaiementsApi organizations_organization_slug_payments_get GET /organizations/{organizationSlug}/payments Obtenir les informations des paiements effectués sur une organisation
PaiementsApi organizations_organization_slug_payments_search_get GET /organizations/{organizationSlug}/payments/search Rechercher des paiements.
PaiementsApi payments_payment_id_get GET /payments/{paymentId} Obtenir les informations détaillées d'un paiement.
PaiementsApi payments_payment_id_refund_post POST /payments/{paymentId}/refund Rembourser un paiement.
PartenairesApi partners_me_api_clients_put PUT /partners/me/api-clients Mise à jour du domaine
PartenairesApi partners_me_api_notifications_delete DELETE /partners/me/api-notifications Suppression de l'URL de notification principale
PartenairesApi partners_me_api_notifications_organizations_organization_slug_delete DELETE /partners/me/api-notifications/organizations/{organizationSlug} Suppression d'une URL de notification liée à une organisation
PartenairesApi partners_me_api_notifications_organizations_organization_slug_put PUT /partners/me/api-notifications/organizations/{organizationSlug} Mise à jour d'une URL de notification liée à une organisation
PartenairesApi partners_me_api_notifications_put PUT /partners/me/api-notifications Mise à jour de l'URL de notification principale
PartenairesApi partners_me_get GET /partners/me Récupération des informations
PartenairesApi partners_me_organizations_get GET /partners/me/organizations Obtenir toutes les organisations
TagsApi tags_tag_name_get GET /tags/{tagName} Obtenir le détail d'un tag interne
TaxReceiptApi organizations_organization_slug_tax_receipt_configuration_get GET /organizations/{organizationSlug}/tax-receipt/configuration
TaxReceiptApi organizations_organization_slug_tax_receipt_configuration_put PUT /organizations/{organizationSlug}/tax-receipt/configuration
TaxReceiptApi organizations_organization_slug_tax_receipt_preview_post POST /organizations/{organizationSlug}/tax-receipt/preview
UtilisateursApi users_me_organizations_get GET /users/me/organizations Obtenir mes organisations

Documentation For Models

Authorization

We use OAuth2 for authentication, so to avoid reinventing the wheel, we recommend using the Authlib package

Prerequisite

Install the Authlib package:

pip install requests
pip install Authlib

Client Credentials Flow

from authlib.integrations.requests_client import OAuth2Session

# Configuration
client_id = 'your_client_id'
client_secret = 'your_client_secret'
token_url = 'https://api.helloasso.com/oauth2/token'

# Create an OAuth2 session
client = OAuth2Session(client_id, client_secret)

# Get an access token
def get_access_token():
    token = client.fetch_token(token_url, grant_type='client_credentials')
    print("Access Token:", token['access_token'])
    print("Expires In:", token['expires_in'])
    print("Refresh Token:", token['refresh_token'])
    return token

# Usage
get_access_token()

Refresh Token Flow

from authlib.integrations.requests_client import OAuth2Session

# Configuration
client_id = 'your_client_id'
client_secret = 'your_client_secret'
token_url = 'https://api.helloasso.com/oauth2/token'

# Refresh the token
def refresh_access_token(refresh_token):
    client = OAuth2Session(client_id, client_secret)
    token = client.refresh_token(token_url, refresh_token=refresh_token)
    print("New Access Token:", token['access_token'])
    print("Expires In:", token['expires_in'])
    print("New Refresh Token:", token['refresh_token'])
    return token

# Usage
refresh_access_token('your_refresh_token')

Authorization Code Flow

import base64
import hashlib
import os
from authlib.integrations.requests_client import OAuth2Session

# Configuration
client_id = 'your_client_id'
client_secret = 'your_client_secret'
authorize_url = 'https://auth.helloasso.com/authorize'
token_url = 'https://api.helloasso.com/oauth2/token'
redirect_uri = 'https://your-app.com/callback'

# PKCE Helper Functions
def generate_code_verifier():
    """Generate a high-entropy code_verifier."""
    return base64.urlsafe_b64encode(os.urandom(32)).rstrip(b'=').decode('utf-8')

def generate_code_challenge(code_verifier):
    """Generate a code_challenge based on the code_verifier."""
    code_challenge = hashlib.sha256(code_verifier.encode('utf-8')).digest()
    return base64.urlsafe_b64encode(code_challenge).rstrip(b'=').decode('utf-8')

# Step 1: Generate the Authorization URL
def get_authorization_url():
    # Generate PKCE parameters
    code_verifier = generate_code_verifier()
    code_challenge = generate_code_challenge(code_verifier)

    client = OAuth2Session(client_id, client_secret, redirect_uri=redirect_uri)
    authorization_url, state = client.create_authorization_url(authorize_url, code_challenge=code_challenge, code_challenge_method='S256')
    print("Authorization URL: ", authorization_url)
    print("Code verifier: ", code_verifier)

# Step 2: Exchange the authorization code for an access token
def get_access_token_from_code(authorization_response, code_verifier):
    client = OAuth2Session(client_id, client_secret, redirect_uri=redirect_uri)
    token = client.fetch_token(token_url, authorization_response=authorization_response, code_verifier=code_verifier)
    print("Access Token: ", token['access_token'])
    print("Expires In: ", token['expires_in'])
    print("Refresh Token: ", token['refresh_token'])

# Usage
get_authorization_url()
# After user authorizes, exchange the code (passed in the redirect URL callback)
#get_access_token_from_code('your_authorization_code', 'your_code_verifier')

About this package

This SDK is automatically generated by the OpenAPI Generator project:

  • Generator version: 7.10.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen