iubenda-consent-solution-api
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -73,7 +73,7 @@ export interface ConsentsQueryParameters { | ||
checksum?: string; | ||
subject?: Subject; | ||
subject?: ConsentSubject; | ||
/** | ||
* Set of key-value pairs with user preferences for the consent action | ||
*/ | ||
preferences?: Preferences; | ||
preferences?: ConsentPreferences; | ||
/** | ||
@@ -89,4 +89,4 @@ * Considered only when using a `private` key. Saves the passed IP address on the Consent. Default null | ||
export interface ConsentExtended extends Consent { | ||
legal_notices?: (LegalNoticesEntity)[] | null; | ||
proofs?: (ProofsEntity)[] | null; | ||
legal_notices?: (ConsentLegalNoticesEntity)[] | null; | ||
proofs?: (ConsentProofsEntity)[] | null; | ||
} | ||
@@ -106,3 +106,3 @@ export interface ConsentResponse extends Consent { | ||
} | ||
export interface Subject { | ||
export interface ConsentSubject { | ||
/** | ||
@@ -121,6 +121,6 @@ * Optional, auto-filled if not provided | ||
} | ||
export interface Preferences { | ||
export interface ConsentPreferences { | ||
[key: string]: string; | ||
} | ||
export interface LegalNoticesEntity { | ||
export interface ConsentLegalNoticesEntity { | ||
/** | ||
@@ -135,5 +135,5 @@ * privacy_policy, cookie_policy, term or a custom identifier | ||
} | ||
export interface ProofsEntity { | ||
export interface ConsentProofsEntity { | ||
content: string; | ||
form: string; | ||
} |
import { ConsentExtended, ConsentPostResponse, ConsentResponse, ConsentsQueryParameters } from '~/consent'; | ||
import { Subject, SubjectPostResponse, SubjectQueryParameters, SubjectResponse } from '~/subject'; | ||
export * from '~/consent'; | ||
export * from '~/subject'; | ||
export interface ResponseError { | ||
@@ -4,0 +6,0 @@ error: boolean; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -41,2 +51,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
var superagent_1 = require("superagent"); | ||
__exportStar(require("./consent"), exports); | ||
__exportStar(require("./subject"), exports); | ||
var IubendaConsentSolution = /** @class */ (function () { | ||
@@ -43,0 +55,0 @@ function IubendaConsentSolution(options) { |
@@ -68,6 +68,6 @@ export interface SubjectQueryParameters { | ||
owner_id: string; | ||
preferences?: Preferences; | ||
preferences?: SubjectPreferences; | ||
timestamp: string; | ||
} | ||
export interface Preferences { | ||
export interface SubjectPreferences { | ||
[key: string]: Preference; | ||
@@ -74,0 +74,0 @@ } |
{ | ||
"name": "iubenda-consent-solution-api", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "API client to implement Iubenda Consent Solution in backend service", | ||
@@ -56,3 +56,8 @@ "main": "dist/index.js", | ||
] | ||
} | ||
}, | ||
"keywords": [ | ||
"iubenda", | ||
"iubenda-api", | ||
"iubenda-consent-solution" | ||
] | ||
} |
@@ -6,6 +6,97 @@ # iubenda-consent-solution-api | ||
## Install | ||
``` | ||
```bash | ||
npm install iubenda-consent-solution-api | ||
``` | ||
This library implements all methods described in Official Iubenda [Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation). | ||
This library implements all methods described in Official | ||
Iubenda [Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation). | ||
## Usage | ||
### Instance client | ||
```ts | ||
import {IubendaConsentSolution} from 'iubenda-consent-solution-api'; | ||
const validApiKey = 'YOUR-VALID-IUBENDA-API-KEY'; | ||
const client = new IubendaConsentSolution({apiKey: validApiKey}); | ||
``` | ||
### Request response error | ||
if the request returns an error you will get an object like the following: | ||
```ts | ||
interface ResponseError { | ||
error: boolean; | ||
status: number; | ||
message: string; | ||
} | ||
``` | ||
### Consents | ||
#### Get Consents | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#list-consents)) | ||
```ts | ||
const result = await client.getConsents(); | ||
``` | ||
#### Get Consent | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#get-consent)) | ||
```ts | ||
const id = 'consent-id' | ||
const result = await client.getConsent(id); | ||
``` | ||
#### Create Consent | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#create-consent)) | ||
```ts | ||
const consent: ConsentExtended = {};//Set your fields | ||
const result = await client.createConsent(consent); | ||
``` | ||
### Subjects | ||
#### Get Subjects | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#list-subjects)) | ||
```ts | ||
const result = await client.getSubjects(); | ||
``` | ||
#### Get Subject | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#get-subjects)) | ||
```ts | ||
const id = 'subject-id' | ||
const result = await client.getSubject(id); | ||
``` | ||
#### Create Subject | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#create-subjects)) | ||
```ts | ||
const subject: Subject = {};//Set your fields | ||
const result = await client.createSubject(subject); | ||
``` | ||
#### Update Subject | ||
Look Iubenda ([Official Guide](https://www.iubenda.com/en/help/6484-consent-solution-http-api-documentation#update-subjects)) | ||
```ts | ||
const id = 'subject-id' | ||
const subject: Subject = {};//Set your fields | ||
const result = await client.updateSubject(subject, id); | ||
``` |
@@ -74,7 +74,7 @@ export interface ConsentsQueryParameters { | ||
checksum?: string; | ||
subject?: Subject; | ||
subject?: ConsentSubject; | ||
/** | ||
* Set of key-value pairs with user preferences for the consent action | ||
*/ | ||
preferences?: Preferences; | ||
preferences?: ConsentPreferences; | ||
/** | ||
@@ -90,4 +90,4 @@ * Considered only when using a `private` key. Saves the passed IP address on the Consent. Default null | ||
export interface ConsentExtended extends Consent{ | ||
legal_notices?: (LegalNoticesEntity)[] | null; | ||
proofs?: (ProofsEntity)[] | null; | ||
legal_notices?: (ConsentLegalNoticesEntity)[] | null; | ||
proofs?: (ConsentProofsEntity)[] | null; | ||
} | ||
@@ -110,3 +110,3 @@ | ||
export interface Subject { | ||
export interface ConsentSubject { | ||
/** | ||
@@ -126,7 +126,7 @@ * Optional, auto-filled if not provided | ||
export interface Preferences { | ||
export interface ConsentPreferences { | ||
[key: string]: string; | ||
} | ||
export interface LegalNoticesEntity { | ||
export interface ConsentLegalNoticesEntity { | ||
/** | ||
@@ -142,5 +142,5 @@ * privacy_policy, cookie_policy, term or a custom identifier | ||
export interface ProofsEntity { | ||
export interface ConsentProofsEntity { | ||
content: string; | ||
form: string; | ||
} |
@@ -5,2 +5,5 @@ import {get, post, put, SuperAgentRequest} from 'superagent'; | ||
export * from '~/consent'; | ||
export * from '~/subject'; | ||
export interface ResponseError { | ||
@@ -7,0 +10,0 @@ error: boolean; |
@@ -68,6 +68,6 @@ export interface SubjectQueryParameters { | ||
owner_id: string; | ||
preferences?: Preferences; | ||
preferences?: SubjectPreferences; | ||
timestamp: string; | ||
} | ||
export interface Preferences { | ||
export interface SubjectPreferences { | ||
[key: string]: Preference; | ||
@@ -74,0 +74,0 @@ } |
44760
922
102