Skip to content

Commit

Permalink
Add package.json keyword, export sub files, edit README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rickypid committed Jan 3, 2022
1 parent 37dcccd commit c8f6ab2
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 14 deletions.
95 changes: 93 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,99 @@
API client to implement Iubenda Consent Solution in backend service.

## 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);
```
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iubenda-consent-solution-api",
"version": "0.1.0",
"version": "0.1.1",
"description": "API client to implement Iubenda Consent Solution in backend service",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -53,5 +53,10 @@
"eslint --fix",
"git add"
]
}
},
"keywords": [
"iubenda",
"iubenda-api",
"iubenda-consent-solution"
]
}
16 changes: 8 additions & 8 deletions src/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export interface Consent {
*/
timestamp?: string;
checksum?: string;
subject?: Subject;
subject?: ConsentSubject;
/**
* Set of key-value pairs with user preferences for the consent action
*/
preferences?: Preferences;
preferences?: ConsentPreferences;
/**
* Considered only when using a `private` key. Saves the passed IP address on the Consent. Default null
*/
Expand All @@ -86,8 +86,8 @@ export interface Consent {
autodetect_ip_address: string;
}
export interface ConsentExtended extends Consent{
legal_notices?: (LegalNoticesEntity)[] | null;
proofs?: (ProofsEntity)[] | null;
legal_notices?: (ConsentLegalNoticesEntity)[] | null;
proofs?: (ConsentProofsEntity)[] | null;
}

export interface ConsentResponse extends Consent {
Expand All @@ -105,7 +105,7 @@ export interface ConsentPostResponse extends Consent {
subject_id: string;
}

export interface Subject {
export interface ConsentSubject {
/**
* Optional, auto-filled if not provided
*/
Expand All @@ -120,11 +120,11 @@ export interface Subject {
verified?: boolean;
}

export interface Preferences {
export interface ConsentPreferences {
[key: string]: string;
}

export interface LegalNoticesEntity {
export interface ConsentLegalNoticesEntity {
/**
* privacy_policy, cookie_policy, term or a custom identifier
*/
Expand All @@ -135,7 +135,7 @@ export interface LegalNoticesEntity {
version: string;
}

export interface ProofsEntity {
export interface ConsentProofsEntity {
content: string;
form: string;
}
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {get, post, put, SuperAgentRequest} from 'superagent';
import {ConsentExtended, ConsentPostResponse, ConsentResponse, ConsentsQueryParameters} from '~/consent';
import {Subject, SubjectPostResponse, SubjectQueryParameters, SubjectResponse} from '~/subject';

export * from '~/consent';
export * from '~/subject';

export interface ResponseError {
error: boolean;
status: number;
Expand Down
4 changes: 2 additions & 2 deletions src/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export interface Subject {
}
export interface SubjectResponse extends Subject{
owner_id: string;
preferences?: Preferences;
preferences?: SubjectPreferences;
timestamp: string;
}
export interface Preferences {
export interface SubjectPreferences {
[key: string]: Preference;
}
export interface Preference {
Expand Down

0 comments on commit c8f6ab2

Please sign in to comment.