Skip to content

HelloAsso/helloasso-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

helloasso-node

The HelloAsso node library offers a straightforward way to interact with the HelloAsso API in node 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.

Installation

npm

Install it via:

npm install helloasso-node --save

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var helloasso = require('helloasso-node');

var defaultClient = helloasso.ApiClient.instance;
// Configure OAuth2 access token for authorization: OAuth2
var OAuth2 = defaultClient.authentications['OAuth2'];
OAuth2.accessToken = "YOUR ACCESS TOKEN"

var api = new helloasso.AnnuaireApi()
var opts = {
  'pageSize': 20, // {Number} The number of items per page
  'continuationToken': "continuationToken_example", // {String} Continuation Token from which we wish to retrieve results
  'helloAssoApiV5ModelsDirectoryListFormsRequest': new helloasso.HelloAssoApiV5ModelsDirectoryListFormsRequest() // {HelloAssoApiV5ModelsDirectoryListFormsRequest} Body which contains the filters to apply
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.directoryFormsPost(opts, callback);

Documentation for API Endpoints

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

Class Method HTTP request Description
HelloAssoApi.AnnuaireApi directoryFormsPost POST /directory/forms Récupérer les formulaires
HelloAssoApi.AnnuaireApi directoryOrganizationsPost POST /directory/organizations Récupérer les organisations
HelloAssoApi.CheckoutApi organizationsOrganizationSlugCheckoutIntentsCheckoutIntentIdGet GET /organizations/{organizationSlug}/checkout-intents/{checkoutIntentId} Récupérer une intention de paiement
HelloAssoApi.CheckoutApi organizationsOrganizationSlugCheckoutIntentsPost POST /organizations/{organizationSlug}/checkout-intents Initialisation d'un Checkout
HelloAssoApi.CommandesApi itemsItemIdGet GET /items/{itemId} Obtenir le détail d'un article contenu dans une commande
HelloAssoApi.CommandesApi ordersOrderIdCancelPost POST /orders/{orderId}/cancel Annuler les paiements futurs pour une commande (pas de remboursement).
HelloAssoApi.CommandesApi ordersOrderIdGet GET /orders/{orderId} Obtenir des informations détaillées sur une commande
HelloAssoApi.CommandesApi organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/items Obtenir une liste d'articles vendus dans un formulaire
HelloAssoApi.CommandesApi organizationsOrganizationSlugFormsFormTypeFormSlugOrdersGet GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/orders Obtenir les commandes d'un formulaire
HelloAssoApi.CommandesApi organizationsOrganizationSlugItemsGet GET /organizations/{organizationSlug}/items Obtenir une liste d'articles vendus par une organisation
HelloAssoApi.CommandesApi organizationsOrganizationSlugOrdersGet GET /organizations/{organizationSlug}/orders Obtenir les commandes d'une organisation
HelloAssoApi.FormulairesApi organizationsOrganizationSlugFormTypesGet GET /organizations/{organizationSlug}/formTypes Obtenir une liste des types de formulaires pour une organisation
HelloAssoApi.FormulairesApi organizationsOrganizationSlugFormsFormTypeActionQuickCreatePost POST /organizations/{organizationSlug}/forms/{formType}/action/quick-create Créer un événement simplifié pour un organisme
HelloAssoApi.FormulairesApi organizationsOrganizationSlugFormsFormTypeFormSlugPublicGet GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/public Obtenir des données publiques détaillées sur un formulaire
HelloAssoApi.FormulairesApi organizationsOrganizationSlugFormsGet GET /organizations/{organizationSlug}/forms Obtenir les formulaires d'une organisation
HelloAssoApi.ListeDeValeursApi valuesCompanyLegalStatusGet GET /values/company-legal-status Obtenir la liste des statuts juridiques
HelloAssoApi.ListeDeValeursApi valuesOrganizationCategoriesGet GET /values/organization/categories Obtenir la liste des catégories du JO
HelloAssoApi.ListeDeValeursApi valuesTagsGet GET /values/tags Obtenir la liste des tags publiques
HelloAssoApi.OrganisationApi organizationsLegalInformationsLegalStructuresGet GET /organizations/legal-informations/legal-structures Obtenir la structure juridique d'une organisation visible.
HelloAssoApi.OrganisationApi organizationsLegalInformationsOrganizationSlugConfigurationGet GET /organizations/legal-informations/{organizationSlug}/configuration
HelloAssoApi.OrganisationApi organizationsLegalInformationsTaxInformationTextsGet GET /organizations/legal-informations/tax-information-texts
HelloAssoApi.OrganisationApi organizationsOrganizationSlugGet GET /organizations/{organizationSlug} Obtenir le détail d'une organisation
HelloAssoApi.OrganizationLegalInformationsApi organizationsLegalInformationsOrganizationSlugConfigurationPut PUT /organizations/legal-informations/{organizationSlug}/configuration
HelloAssoApi.PaiementsApi organizationsOrganizationSlugFormsFormTypeFormSlugPaymentsGet GET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/payments Obtenir les informations des paiements effectués sur un formulaire
HelloAssoApi.PaiementsApi organizationsOrganizationSlugPaymentsGet GET /organizations/{organizationSlug}/payments Obtenir les informations des paiements effectués sur une organisation
HelloAssoApi.PaiementsApi organizationsOrganizationSlugPaymentsSearchGet GET /organizations/{organizationSlug}/payments/search Rechercher des paiements.
HelloAssoApi.PaiementsApi paymentsPaymentIdGet GET /payments/{paymentId} Obtenir les informations détaillées d'un paiement.
HelloAssoApi.PaiementsApi paymentsPaymentIdRefundPost POST /payments/{paymentId}/refund Rembourser un paiement.
HelloAssoApi.PartenairesApi partnersMeApiClientsPut PUT /partners/me/api-clients Mise Ă  jour du domaine
HelloAssoApi.PartenairesApi partnersMeApiNotificationsDelete DELETE /partners/me/api-notifications Suppression de l'URL de notification principale
HelloAssoApi.PartenairesApi partnersMeApiNotificationsOrganizationsOrganizationSlugDelete DELETE /partners/me/api-notifications/organizations/{organizationSlug} Suppression d'une URL de notification liée à une organisation
HelloAssoApi.PartenairesApi partnersMeApiNotificationsOrganizationsOrganizationSlugPut PUT /partners/me/api-notifications/organizations/{organizationSlug} Mise à jour d'une URL de notification liée à une organisation
HelloAssoApi.PartenairesApi partnersMeApiNotificationsPut PUT /partners/me/api-notifications Mise Ă  jour de l'URL de notification principale
HelloAssoApi.PartenairesApi partnersMeGet GET /partners/me Récupération des informations
HelloAssoApi.PartenairesApi partnersMeOrganizationsGet GET /partners/me/organizations Obtenir toutes les organisations
HelloAssoApi.TagsApi tagsTagNameGet GET /tags/{tagName} Obtenir le détail d'un tag interne
HelloAssoApi.TaxReceiptApi organizationsOrganizationSlugTaxReceiptConfigurationGet GET /organizations/{organizationSlug}/tax-receipt/configuration
HelloAssoApi.TaxReceiptApi organizationsOrganizationSlugTaxReceiptConfigurationPut PUT /organizations/{organizationSlug}/tax-receipt/configuration
HelloAssoApi.TaxReceiptApi organizationsOrganizationSlugTaxReceiptPreviewPost POST /organizations/{organizationSlug}/tax-receipt/preview
HelloAssoApi.UtilisateursApi usersMeOrganizationsGet 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 simple-oauth2 package

Prerequisite

Install the simple-oauth2 package:

npm i simple-oauth2

Client Credentials Flow

const { ClientCredentials } = require('simple-oauth2');

// Create the client credentials instance
const client = new ClientCredentials({
  client: {
    id: 'your_client_id',
    secret: 'your_client_secret',
  },
  auth: {
    tokenHost: 'https://api.helloasso.com',
    tokenPath: '/oauth2/token',
  },
});

// Get an access token
async function getAccessToken() {
  try {
    const token = await client.getToken();
    console.log('Access Token:', token.token);
    return token.token;
  } catch (error) {
    console.error('Error getting access token:', error.message);
  }
}

// Usage
getAccessToken();

Refresh Token Flow

const { AuthorizationCode } = require('simple-oauth2');

// Create the authorization code instance
const client = new AuthorizationCode({
  client: {
    id: 'your_client_id',
    secret: 'your_client_secret',
  },
  auth: {
    tokenHost: 'https://api.helloasso.com',
    tokenPath: '/oauth2/token',
  },
});

// Refresh the token
async function refreshAccessToken(refreshToken) {
  try {
    const tokenObject = client.createToken({ refresh_token: refreshToken });
    const newToken = await tokenObject.refresh();
    console.log('New Access Token:', newToken.token);
    return newToken.token;
  } catch (error) {
    console.error('Error refreshing token:', error.message);
  }
}

// Usage
refreshAccessToken('your_refresh_token');

Authorization Code Flow

const { AuthorizationCode } = require('simple-oauth2');
const crypto = require('crypto');

// Create the authorization code instance
const authorisationClient = new AuthorizationCode({
  client: {
    id: 'your_client_id',
    secret: 'your_client_secret',
  },
  auth: {
    tokenHost: 'https://auth.helloasso.com/',
    authorizePath: '/authorize',
  },
});

const tokenClient = new AuthorizationCode({
  client: {
    id: 'your_client_id',
    secret: 'your_client_secret',
  },
  auth: {
    tokenHost: 'https://api.helloasso.com/',
    tokenPath: '/oauth2/token'
  },
});

// Generate a Code Verifier and Code Challenge
function generatePKCE() {
  const codeVerifier = crypto.randomBytes(32).toString('hex'); // Create a random string
  const codeChallenge = crypto
    .createHash('sha256')
    .update(codeVerifier)
    .digest('base64')
    .replace(/\+/g, '-')
    .replace(/\//g, '_')
    .replace(/=+$/, ''); // Base64 URL encode

  return { codeVerifier, codeChallenge };
}

// Step 1: Generate the authorization URL
function getAuthorizationUrl() {
  const { codeVerifier, codeChallenge } = generatePKCE();
  const authorizationUri = client.authorizeURL({
    redirect_uri: 'https://your-app.com/callback',
    state: 'random_state_string',
    code_challenge: codeChallenge,
    code_challenge_method: 'S256',
  });

  console.log('Authorization URL:', authorizationUri);
  console.log('Code verifier:', codeVerifier);

  // Save the codeVerifier for later (e.g., in session or database)
  return { authorizationUri, codeVerifier };
}

// Step 2: Exchange the authorization code for an access token
async function getAccessTokenFromCode(authorizationCode, codeVerifier) {
  try {
    const token = await tokenClient.getToken({
      code: authorizationCode,
      redirect_uri: 'https://your-app.com/callback',
      code_verifier: codeVerifier
    });
    console.log('Access Token:', token.token);
    return token.token;
  } catch (error) {
    console.error('Error getting access token:', error.message);
  }
}

// Usage
const { authorizationUri, codeVerifier } = getAuthorizationUrl();
// After user authorizes, exchange the code (passed in the redirect URL callback)
// getAccessTokenFromCode('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.JavascriptClientCodegen

About

SDK node pour l'API HelloAsso

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published