Appels à l'API
Afin d’utiliser les fonctionnalités décrites dans cette page, il est impératif d’avoir initialiser la librairie comme indiqué dans la section https://fairandsmart.atlassian.net/wiki/spaces/BDC/pages/2265382918
Consent.js implémente une bibliothèque de méthodes permettant d’interfacer avec l'https://fairandsmart.atlassian.net/wiki/spaces/BDC/pages/2262139157 Right Consents.
Ces méthodes définisents des paramètres en entrée et en sortie de chaque endpoint, et utilise une fonction de requêtage HTTP.
Client HTTP
Afin que les méthodes d’appel à l’API fonctionnent correctement, un Client HTTP doit être fourni à la librairie. II en existe un par défaut, mais il ne répondra peut-être pas à tous vos besoins.
Le client HTTP doit correspondre à un objet de type RcHttpClient
, disponible depuis @fairandsmart/consent-manager/http
Voici un exemple de création d’un client HTTP compatible, suivi de l’utilisation d’une méthode d’appel à l’API.
import { RightConsents, RcHttpClientConfig } from '@fairandsmart/consent-manager';
// Création du client HTTP.
function myCustomHttpClient(config: RcHttpClientConfig): Observable<ModelEntryDto> {
// ajouter une clé API, un workflow oAuth, etc., puis effectuer l'appel HTTP.
return fromFetch(config.url, ...);
}
// Initialisation de la librairie RightConsents
RightConsents.init({
apiRoot: 'https://consent-manager.fairandsmart.com',
catalogRoot: 'https://catalog.fairandsmart.com',
httpClient: myCustomHttpClient,
});
// Appel à l'API avec un observable
ModelsResource.getEntry(entryId).subscribe((modelEntry: ModelEntryDto) => {
...
});
// ... ou avec une promesse, avec la fonction .toPromise();
const modelEntry: ModelEntryDto = await ModelsResource.getEntry(entryId).toPromise();
Endpoints
- 1 ConsentsResource
- 2 KeysResource
- 3 ModelsResource
- 3.1 listEntries
- 3.2 createEntry
- 3.3 getEntry
- 3.4 updateEntry
- 3.5 deleteEntry
- 3.6 setDefaultInfoModel
- 3.7 listVersions
- 3.8 createVersion
- 3.9 getLatestVersion
- 3.10 getActiveVersion
- 3.11 getVersion
- 3.12 updateVersion
- 3.13 updateVersionStatus
- 3.14 updateVersionType
- 3.15 getVersionPreview
- 3.16 deleteVersion
- 3.17 exportEntry
- 3.18 importEntry
- 4 ReceiptsResource
- 4.1 getReceiptPdf
- 5 RecordsResource
- 6 StatisticsResource
- 6.1 getStats
- 7 SubjectsResource
- 7.1 listSubjects
- 7.2 getSubject
- 7.3 createSubject
- 7.4 updateSubject
- 7.5 listSubjectRecords
- 8 SystemResource
- 8.1 getSupportInfo
- 8.2 getClientConfig
- 9 TokensResource
- 9.1 createToken
- 10 UsersResource
- 10.1 getMe
- 10.2 getRecordsForUser
- 10.3 getUserStatus
ConsentsResource
createTransactionJson
POST /consents
Prend un ConsentContext en entrée et créer une nouvelle transaction pour le contexte donné, dans la langue spécifiée.
Retourne le token de la transaction.
import { createTransactionJson } from '@fairandsmart/consent-manager/consents';
createTransactionJson(ctx: ConsentContext, lang: string, options?: RCApiOptions): Observable<string>
getTransactionJson
GET /consents/:transactionId
import { getTransactionJson } from '@fairandsmart/consent-manager/consents';
getTransactionJson(transactionId: string, options?: RCApiOptions): Observable<string>
postSubmissionValuesHtml
POST /consents/:transactionId/submit
getSubmitFormPreview
POST /consents/preview
KeysResource
listKeys
GET /keys
createKey
POST /keys
deleteKey
DELETE /keys/:keyId
ModelsResource
listEntries
GET /models
createEntry
POST /models
getEntry
GET /models/:modelId
updateEntry
PUT /models/:modelId
deleteEntry
DELETE /models/:modelId
setDefaultInfoModel
POST /models/defaultinfo
listVersions
GET /models/:modelId/versions
createVersion
POST /models/:modelId/versions
getLatestVersion
GET /models/:modelId/versions/latest
getActiveVersion
GET /models/:modelId/versions/active
getVersion
GET /models/:modelId/versions/:versionId
updateVersion
PUT /models/:modelId/versions/:versionId
updateVersionStatus
PUT /models/:modelId/versions/:versionId/status
updateVersionType
PUT /models/:modelId/versions/:versionId/type
getVersionPreview
POST /models/:modelId/versions/:versionId/preview
deleteVersion
DELETE /models/:modelId/versions/:versionId
exportEntry
GET /models/:modelId/export
importEntry
POST /models/import
ReceiptsResource
getReceiptPdf
GET /receipts/:transactionId
RecordsResource
listRecordsOfSubject
GET /records
extractRecords
POST /records/extraction
extractRecordsCsv
POST /records/extraction
StatisticsResource
getStats
GET /stats
SubjectsResource
listSubjects
GET /subjects
getSubject
GET /subjects/:subjectId
createSubject
POST /subjects
updateSubject
PUT /subjects/:subjectId
listSubjectRecords
GET /subjects/:subjectId/records
SystemResource
getSupportInfo
GET /system/support/infos
getClientConfig
GET /system/config
TokensResource
createToken
POST /tokens
UsersResource
getMe
GET /user
getRecordsForUser
GET /user
getUserStatus
GET /user
Options additionnelles (RcApiOptions
)
Chaque méthode d’appel à l’API prend un paramètre optionnel appelé options
et de type RcApiOptions
. Il s’agit d’un objet de configuration supplémentaire qui pourra être passé à votre client HTTP pour certains cas particuliers.