diff --git a/README.md b/README.md
index eb2235c..4d144c9 100644
--- a/README.md
+++ b/README.md
@@ -109,6 +109,10 @@ and max number of retries
- EventsCoreAPIOptions :
object
+- ProviderFilterOptions :
object
+
+- ProviderOptions :
object
+
- ProviderInputModel :
object
- EventMetadataInputModel :
object
@@ -145,11 +149,12 @@ and max number of retries
* [.apiKey](#EventsCoreAPI+apiKey)
* [.accessToken](#EventsCoreAPI+accessToken)
* [.init(organizationId, apiKey, accessToken, [httpOptions])](#EventsCoreAPI+init) ⇒ [Promise.<EventsCoreAPI>
](#EventsCoreAPI)
- * [.getAllProviders(consumerOrgId)](#EventsCoreAPI+getAllProviders) ⇒ Promise.<object>
+ * [.getAllProviders(consumerOrgId, providerOptions)](#EventsCoreAPI+getAllProviders) ⇒ Promise.<object>
* [.getProvider(providerId, [fetchEventMetadata])](#EventsCoreAPI+getProvider) ⇒ Promise.<object>
* [.createProvider(consumerOrgId, projectId, workspaceId, body)](#EventsCoreAPI+createProvider) ⇒ Promise.<object>
* [.updateProvider(consumerOrgId, projectId, workspaceId, providerId, body)](#EventsCoreAPI+updateProvider) ⇒ Promise.<object>
* [.deleteProvider(consumerOrgId, projectId, workspaceId, providerId)](#EventsCoreAPI+deleteProvider) ⇒ Promise.<object>
+ * [.getProviderMetadata()](#EventsCoreAPI+getProviderMetadata) ⇒ Promise.<object>
* [.getAllEventMetadataForProvider(providerId)](#EventsCoreAPI+getAllEventMetadataForProvider) ⇒ Promise.<object>
* [.getEventMetadataForProvider(providerId, eventCode)](#EventsCoreAPI+getEventMetadataForProvider) ⇒ Promise.<object>
* [.createEventMetadataForProvider(consumerOrgId, projectId, workspaceId, providerId, body)](#EventsCoreAPI+createEventMetadataForProvider) ⇒ Promise.<object>
@@ -208,7 +213,7 @@ Initialize SDK.
-### eventsCoreAPI.getAllProviders(consumerOrgId) ⇒ Promise.<object>
+### eventsCoreAPI.getAllProviders(consumerOrgId, providerOptions) ⇒ Promise.<object>
Fetch all the providers
**Kind**: instance method of [EventsCoreAPI
](#EventsCoreAPI)
@@ -217,6 +222,7 @@ Fetch all the providers
| Param | Type | Description |
| --- | --- | --- |
| consumerOrgId | string
| Consumer Org Id from the console |
+| providerOptions | [ProviderOptions
](#ProviderOptions) | Provider options |
@@ -277,6 +283,11 @@ Delete a provider given the id
| workspaceId | string
| Workspace Id from the console |
| providerId | string
| The id that uniquely identifies the provider to be deleted |
+
+
+### eventsCoreAPI.getProviderMetadata() ⇒ Promise.<object>
+**Kind**: instance method of [EventsCoreAPI
](#EventsCoreAPI)
+**Returns**: Promise.<object>
- Returns the list of all entitled provider metadata for the org
### eventsCoreAPI.getAllEventMetadataForProvider(providerId) ⇒ Promise.<object>
@@ -544,6 +555,29 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| [eventsBaseURL] | string
| Base URL for Events Default https://api.adobe.io (optional) |
| [eventsIngressURL] | string
| Ingress URL for Events. Default https://eventsingress.adobe.io (optional) |
+
+
+## ProviderFilterOptions : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| [providerMetadataId] | string
| Fetch by providerMetadataId for the consumer org |
+| [instanceId] | string
| For Self registered providers, instanceId is a must while fetching by providerMetadataId |
+| [providerMetadataIds] | Array.<string>
| Fetch all providers ( and all instances ) for the list of provider metadata ids |
+
+
+
+## ProviderOptions : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| fetchEventMetadata | boolean
| Option to fetch event metadata for each of the the providers in the list |
+| filterBy | [ProviderFilterOptions
](#ProviderFilterOptions) | Provider filtering options based on either (providerMetadataId and instanceId) or list of providerMetadataIds |
+
## ProviderInputModel : object
diff --git a/src/SDKErrors.js b/src/SDKErrors.js
index 02f353b..9d01aa3 100644
--- a/src/SDKErrors.js
+++ b/src/SDKErrors.js
@@ -50,6 +50,7 @@ E('ERROR_GET_PROVIDER', '%s')
E('ERROR_CREATE_PROVIDER', '%s')
E('ERROR_UPDATE_PROVIDER', '%s')
E('ERROR_DELETE_PROVIDER', '%s')
+E('ERROR_GET_ALL_PROVIDER_METADATA', '%s')
E('ERROR_GET_ALL_EVENTMETADATA', '%s')
E('ERROR_GET_EVENTMETADATA', '%s')
E('ERROR_CREATE_EVENTMETADATA', '%s')
diff --git a/src/helpers.js b/src/helpers.js
index e017a49..44046b0 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -30,21 +30,19 @@ function reduceError (error = {}) {
* Appends querystring key/value pairs to a url
*
* @param {string} url URL
- * @param {object} qs Object/map with all the query paratemers as key value pairs
+ * @param {object} qs Object/map with all the query parameters as key value pairs
* @returns {string} URL with appended querystring key/value pairs
*/
function appendQueryParams (url, qs) {
let result = url
- if (qs) {
- let separator = (url.indexOf('?') >= 0) ? '&' : '?'
- for (const key of Object.getOwnPropertyNames(qs)) {
- if (qs[key]) {
- const escKey = querystring.escape(key)
- const escValue = querystring.escape(qs[key])
- result += `${separator}${escKey}=${escValue}`
- separator = '&'
- }
+ if (qs && !(Object.keys(qs).length === 0)) {
+ const filteredQs = Object.entries(qs).filter(([k, v]) => !(v === null || v === undefined))
+ if (Object.keys(filteredQs).length === 0) {
+ return result
}
+ const separator = (url.indexOf('?') >= 0) ? '&' : '?'
+ const queryParams = querystring.stringify(Object.fromEntries(filteredQs))
+ result += `${separator}${queryParams}`
}
return result
}
diff --git a/src/index.js b/src/index.js
index 4a26b51..25200a6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -111,17 +111,35 @@ class EventsCoreAPI {
* =========================================================================
*/
+ /**
+ * @typedef {object} ProviderFilterOptions
+ * @property {string} [providerMetadataId] Fetch by providerMetadataId for the consumer org
+ * @property {string} [instanceId] For Self registered providers, instanceId is a must while fetching by providerMetadataId
+ * @property {Array.} [providerMetadataIds] Fetch all providers ( and all instances ) for the list of provider metadata ids
+ */
+ /**
+ * @typedef {object} ProviderOptions
+ * @property {boolean} fetchEventMetadata Option to fetch event metadata for each of the the providers in the list
+ * @property {ProviderFilterOptions} filterBy Provider filtering options based on either (providerMetadataId and instanceId) or list of providerMetadataIds
+ */
/**
* Fetch all the providers
*
* @param {string} consumerOrgId Consumer Org Id from the console
+ * @param {ProviderOptions} providerOptions Provider options
* @returns {Promise