Skip to content

Commit

Permalink
add registration create and update model typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeetha5491 committed Sep 29, 2022
1 parent 7b949aa commit fdc7bf9
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 6 deletions.
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ and max number of retries</p>
<dl>
<dt><a href="#EventsCoreAPIOptions">EventsCoreAPIOptions</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#EventsOfInterest">EventsOfInterest</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#RegistrationCreateModel">RegistrationCreateModel</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#RegistrationUpdateModel">RegistrationUpdateModel</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#Page">Page</a> : <code>object</code></dt>
<dd></dd>
<dt><a href="#EventsJournalOptions">EventsJournalOptions</a> : <code>object</code></dt>
Expand Down Expand Up @@ -369,7 +375,7 @@ Create a webhook or journal registration
| consumerOrgId | <code>string</code> | Consumer Org Id from the console |
| projectId | <code>string</code> | Project Id from the console |
| workspaceId | <code>string</code> | Workspace Id from the console |
| body | <code>object</code> | Json data contains details of the registration |
| body | [<code>RegistrationCreateModel</code>](#RegistrationCreateModel) | Json data contains details of the registration |

<a name="EventsCoreAPI+updateRegistration"></a>

Expand All @@ -385,7 +391,7 @@ Update a webhook or journal registration
| projectId | <code>string</code> | Project Id from the console |
| workspaceId | <code>string</code> | Workspace Id from the console |
| registrationId | <code>string</code> | Registration id whose details are to be fetched |
| body | <code>object</code> | Json data contains details of the registration |
| body | [<code>RegistrationUpdateModel</code>](#RegistrationUpdateModel) | Json data contains details of the registration |

<a name="EventsCoreAPI+getRegistration"></a>

Expand Down Expand Up @@ -534,6 +540,48 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| [eventsBaseURL] | <code>string</code> | Base URL for Events Default https://api.adobe.io (optional) |
| [eventsIngressURL] | <code>string</code> | Ingress URL for Events. Default https://eventsingress.adobe.io (optional) |

<a name="EventsOfInterest"></a>

## EventsOfInterest : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| provider_id | <code>string</code> | The id of the provider of the events to be subscribed |
| event_code | <code>string</code> | The requested valid event code belonging to the provider |

<a name="RegistrationCreateModel"></a>

## RegistrationCreateModel : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| client_id | <code>string</code> | Client id for which the registration is created |
| name | <code>string</code> | The name of the registration |
| description | <code>string</code> | The description of the registration |
| [webhook_url] | <code>string</code> | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type |
| events_of_interest | [<code>Array.&lt;EventsOfInterest&gt;</code>](#EventsOfInterest) | The events for which the registration is to be subscribed to |
| delivery_type | <code>string</code> | Delivery type can either be webhook|webhook_batch|journal. |
| [enabled] | <code>string</code> | Enable or disable the registration. Default true. |

<a name="RegistrationUpdateModel"></a>

## RegistrationUpdateModel : <code>object</code>
**Kind**: global typedef
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| name | <code>string</code> | The name of the registration |
| description | <code>string</code> | The description of the registration |
| [webhook_url] | <code>string</code> | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type |
| events_of_interest | [<code>Array.&lt;EventsOfInterest&gt;</code>](#EventsOfInterest) | The events for which the registration is to be subscribed to |
| delivery_type | <code>string</code> | Delivery type can either be webhook|webhook_batch|journal. |
| [enabled] | <code>string</code> | Enable or disable the registration. Default true. |

<a name="Page"></a>

## Page : <code>object</code>
Expand Down
28 changes: 26 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,28 @@ class EventsCoreAPI {
* =========================================================================
*/

/**
* @typedef {object} EventsOfInterest
* @property {string} provider_id The id of the provider of the events to be subscribed
* @property {string} event_code The requested valid event code belonging to the provider
*/
/**
* @typedef {object} RegistrationCreateModel
* @property {string} client_id Client id for which the registration is created
* @property {string} name The name of the registration
* @property {string} description The description of the registration
* @property {string} [webhook_url] A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type
* @property {Array.<EventsOfInterest>} events_of_interest The events for which the registration is to be subscribed to
* @property {string} delivery_type Delivery type can either be webhook|webhook_batch|journal.
* @property {string} [enabled] Enable or disable the registration. Default true.
*/
/**
* Create a webhook or journal registration
*
* @param {string} consumerOrgId Consumer Org Id from the console
* @param {string} projectId Project Id from the console
* @param {string} workspaceId Workspace Id from the console
* @param {object} body Json data contains details of the registration
* @param {RegistrationCreateModel} body Json data contains details of the registration
* @returns {Promise<object>} Details of the webhook/journal registration created
*/
createRegistration (consumerOrgId, projectId, workspaceId, body) {
Expand All @@ -324,14 +339,23 @@ class EventsCoreAPI {
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_REGISTRATION)
}

/**
* @typedef {object} RegistrationUpdateModel
* @property {string} name The name of the registration
* @property {string} description The description of the registration
* @property {string} [webhook_url] A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type
* @property {Array.<EventsOfInterest>} events_of_interest The events for which the registration is to be subscribed to
* @property {string} delivery_type Delivery type can either be webhook|webhook_batch|journal.
* @property {string} [enabled] Enable or disable the registration. Default true.
*/
/**
* Update a webhook or journal registration
*
* @param {string} consumerOrgId Consumer Org Id from the console
* @param {string} projectId Project Id from the console
* @param {string} workspaceId Workspace Id from the console
* @param {string} registrationId Registration id whose details are to be fetched
* @param {object} body Json data contains details of the registration
* @param {RegistrationUpdateModel} body Json data contains details of the registration
* @returns {Promise<object>} Details of the webhook/journal registration to be updated
*/
updateRegistration (consumerOrgId, projectId, workspaceId, registrationId, body) {
Expand Down
49 changes: 47 additions & 2 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ declare class EventsCoreAPI {
* @param body - Json data contains details of the registration
* @returns Details of the webhook/journal registration created
*/
createRegistration(consumerOrgId: string, projectId: string, workspaceId: string, body: any): Promise<object>;
createRegistration(consumerOrgId: string, projectId: string, workspaceId: string, body: RegistrationCreateModel): Promise<object>;
/**
* Update a webhook or journal registration
* @param consumerOrgId - Consumer Org Id from the console
Expand All @@ -164,7 +164,7 @@ declare class EventsCoreAPI {
* @param body - Json data contains details of the registration
* @returns Details of the webhook/journal registration to be updated
*/
updateRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string, body: any): Promise<object>;
updateRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string, body: RegistrationUpdateModel): Promise<object>;
/**
* Get registration details for a given registration
* @param consumerOrgId - Consumer Org Id from the console
Expand Down Expand Up @@ -241,6 +241,51 @@ declare class EventsCoreAPI {
verifyDigitalSignatureForEvent(event: any, recipientClientId: string, signatureOptions?: SignatureOptions): boolean;
}

/**
* @property provider_id - The id of the provider of the events to be subscribed
* @property event_code - The requested valid event code belonging to the provider
*/
declare type EventsOfInterest = {
provider_id: string;
event_code: string;
};

/**
* @property client_id - Client id for which the registration is created
* @property name - The name of the registration
* @property description - The description of the registration
* @property [webhook_url] - A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type
* @property events_of_interest - The events for which the registration is to be subscribed to
* @property delivery_type - Delivery type can either be webhook|webhook_batch|journal.
* @property [enabled] - Enable or disable the registration. Default true.
*/
declare type RegistrationCreateModel = {
client_id: string;
name: string;
description: string;
webhook_url?: string;
events_of_interest: EventsOfInterest[];
delivery_type: string;
enabled?: string;
};

/**
* @property name - The name of the registration
* @property description - The description of the registration
* @property [webhook_url] - A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type
* @property events_of_interest - The events for which the registration is to be subscribed to
* @property delivery_type - Delivery type can either be webhook|webhook_batch|journal.
* @property [enabled] - Enable or disable the registration. Default true.
*/
declare type RegistrationUpdateModel = {
name: string;
description: string;
webhook_url?: string;
events_of_interest: EventsOfInterest[];
delivery_type: string;
enabled?: string;
};

/**
* @property [page] - page number to be fetched. Default 0 (optional)
* @property [size] - size of each page. Default 10 (optional)
Expand Down

0 comments on commit fdc7bf9

Please sign in to comment.