diff --git a/.eslintrc b/.eslintrc
index de5abdf..71e6224 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,4 +1,4 @@
{
"plugins": ["jest"],
- "extends": ["standard", "plugin:jest/recommended"]
+ "extends": "@adobe/eslint-config-aio-lib-config"
}
diff --git a/README.md b/README.md
index 530c292..30f6c2c 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ governing permissions and limitations under the License.
[![Version](https://img.shields.io/npm/v/@adobe/aio-lib-target.svg)](https://npmjs.org/package/@adobe/aio-lib-target)
[![Downloads/week](https://img.shields.io/npm/dw/@adobe/aio-lib-target.svg)](https://npmjs.org/package/@adobe/aio-lib-target)
[![Build Status](https://travis-ci.com/adobe/aio-lib-target.svg?branch=master)](https://travis-ci.com/adobe/aio-lib-target)
-[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
+[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/adobe/aio-lib-target/master.svg?style=flat-square)](https://codecov.io/gh/adobe/aio-lib-target/)
# I/O Adobe Target SDK
@@ -96,41 +96,41 @@ with valid tenant, apiKey and auth token
* [TargetCoreAPI](#TargetCoreAPI)
* [.init(tenant, apiKey, token)](#TargetCoreAPI+init) ⇒ [TargetCoreAPI
](#TargetCoreAPI)
- * [.getActivities(options)](#TargetCoreAPI+getActivities)
- * [.createABActivity(body)](#TargetCoreAPI+createABActivity)
- * [.createXTActivity(body)](#TargetCoreAPI+createXTActivity)
- * [.getABActivityById(id)](#TargetCoreAPI+getABActivityById)
- * [.getXTActivityById(id)](#TargetCoreAPI+getXTActivityById)
- * [.updateABActivity(id)](#TargetCoreAPI+updateABActivity)
- * [.updateXTActivity(id)](#TargetCoreAPI+updateXTActivity)
- * [.setActivityName(id, name)](#TargetCoreAPI+setActivityName)
- * [.setActivityState(id, state)](#TargetCoreAPI+setActivityState)
- * [.setActivityPriority(id, priority)](#TargetCoreAPI+setActivityPriority)
- * [.setActivitySchedule(id, schedule)](#TargetCoreAPI+setActivitySchedule)
- * [.deleteABActivity(id)](#TargetCoreAPI+deleteABActivity)
- * [.deleteXTActivity(id)](#TargetCoreAPI+deleteXTActivity)
- * [.getActivityChangeLog(id)](#TargetCoreAPI+getActivityChangeLog)
- * [.getOffers(options)](#TargetCoreAPI+getOffers)
- * [.getOfferById(id)](#TargetCoreAPI+getOfferById)
- * [.createOffer(body)](#TargetCoreAPI+createOffer)
- * [.updateOffer(id)](#TargetCoreAPI+updateOffer)
- * [.deleteOffer(id)](#TargetCoreAPI+deleteOffer)
- * [.getAudiences(options)](#TargetCoreAPI+getAudiences)
- * [.createAudience(body)](#TargetCoreAPI+createAudience)
- * [.getAudienceById(id)](#TargetCoreAPI+getAudienceById)
- * [.updateAudience(id)](#TargetCoreAPI+updateAudience)
- * [.deleteAudience(id)](#TargetCoreAPI+deleteAudience)
- * [.getProperties()](#TargetCoreAPI+getProperties)
- * [.getPropertyById(id)](#TargetCoreAPI+getPropertyById)
- * [.getMBoxes()](#TargetCoreAPI+getMBoxes)
- * [.getMBoxByName(name)](#TargetCoreAPI+getMBoxByName)
- * [.getMBoxProfileAttributes()](#TargetCoreAPI+getMBoxProfileAttributes)
- * [.getEnvironments()](#TargetCoreAPI+getEnvironments)
- * [.getABActivityPerformance(id)](#TargetCoreAPI+getABActivityPerformance)
- * [.getXTActivityPerformance(id)](#TargetCoreAPI+getXTActivityPerformance)
- * [.getActivityPerformance(id)](#TargetCoreAPI+getActivityPerformance)
- * [.getOrdersReport(id)](#TargetCoreAPI+getOrdersReport)
- * [.executeBatch()](#TargetCoreAPI+executeBatch)
+ * [.getActivities([options])](#TargetCoreAPI+getActivities)
+ * [.createABActivity(body, [options])](#TargetCoreAPI+createABActivity)
+ * [.createXTActivity(body, [options])](#TargetCoreAPI+createXTActivity)
+ * [.getABActivityById(id, [options])](#TargetCoreAPI+getABActivityById)
+ * [.getXTActivityById(id, [options])](#TargetCoreAPI+getXTActivityById)
+ * [.updateABActivity(id, body, [options])](#TargetCoreAPI+updateABActivity)
+ * [.updateXTActivity(id, body, [options])](#TargetCoreAPI+updateXTActivity)
+ * [.setActivityName(id, name, [options])](#TargetCoreAPI+setActivityName)
+ * [.setActivityState(id, state, [options])](#TargetCoreAPI+setActivityState)
+ * [.setActivityPriority(id, priority, [options])](#TargetCoreAPI+setActivityPriority)
+ * [.setActivitySchedule(id, schedule, [options])](#TargetCoreAPI+setActivitySchedule)
+ * [.deleteABActivity(id, [options])](#TargetCoreAPI+deleteABActivity)
+ * [.deleteXTActivity(id, [options])](#TargetCoreAPI+deleteXTActivity)
+ * [.getActivityChangeLog(id, [options])](#TargetCoreAPI+getActivityChangeLog)
+ * [.getOffers([options])](#TargetCoreAPI+getOffers)
+ * [.getOfferById(id, [options])](#TargetCoreAPI+getOfferById)
+ * [.createOffer(body, [options])](#TargetCoreAPI+createOffer)
+ * [.updateOffer(id, body, [options])](#TargetCoreAPI+updateOffer)
+ * [.deleteOffer(id, [options])](#TargetCoreAPI+deleteOffer)
+ * [.getAudiences([options])](#TargetCoreAPI+getAudiences)
+ * [.createAudience(body, [options])](#TargetCoreAPI+createAudience)
+ * [.getAudienceById(id, [options])](#TargetCoreAPI+getAudienceById)
+ * [.updateAudience(id, body, [options])](#TargetCoreAPI+updateAudience)
+ * [.deleteAudience(id, [options])](#TargetCoreAPI+deleteAudience)
+ * [.getProperties([options])](#TargetCoreAPI+getProperties)
+ * [.getPropertyById(id, [options])](#TargetCoreAPI+getPropertyById)
+ * [.getMBoxes([options])](#TargetCoreAPI+getMBoxes)
+ * [.getMBoxByName(name, [options])](#TargetCoreAPI+getMBoxByName)
+ * [.getMBoxProfileAttributes([options])](#TargetCoreAPI+getMBoxProfileAttributes)
+ * [.getEnvironments([options])](#TargetCoreAPI+getEnvironments)
+ * [.getABActivityPerformance(id, [options])](#TargetCoreAPI+getABActivityPerformance)
+ * [.getXTActivityPerformance(id, [options])](#TargetCoreAPI+getXTActivityPerformance)
+ * [.getActivityPerformance(id, [options])](#TargetCoreAPI+getActivityPerformance)
+ * [.getOrdersReport(id, [options])](#TargetCoreAPI+getOrdersReport)
+ * [.executeBatch(body)](#TargetCoreAPI+executeBatch)
@@ -141,28 +141,29 @@ Initialize sdk.
| Param | Type | Description |
| --- | --- | --- |
-| tenant | string
| Adobe Target tenant name. |
+| tenant | string
| Adobe Target tenant name |
| apiKey | string
| Your api key |
| token | string
| Valid auth token |
-### targetCoreAPI.getActivities(options)
+### targetCoreAPI.getActivities([options])
List activities.
Get a list of activities created in your Target account, with the ability to filter and sort by attributes.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
-| Param | Type | Description |
-| --- | --- | --- |
-| options | Object
| to control activity search. |
-| options.limit | | Defines the number of items to return. Default value is 2147483647 |
-| options.offset | | Defines the first activity to return from the list of total activities. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of activities. |
-| options.sortBy | | Defines the sorting criteria on the returned items. |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options] | object
| | to control activity search |
+| [options.limit] | number
| 2147483647
| Defines the number of items to return |
+| [options.offset] | number
| 0
| Defines the first activity to return from the list of total activities. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of activities. |
+| [options.sortBy] | string
| | Defines the sorting criteria on the returned items |
+| [options.headers] | object
| | headers to pass to API call |
-### targetCoreAPI.createABActivity(body)
+### targetCoreAPI.createABActivity(body, [options])
Create AB Activity.
Creates a new AB activity with the specified contents and returns the created activity.
@@ -170,11 +171,13 @@ Creates a new AB activity with the specified contents and returns the created ac
| Param | Type | Description |
| --- | --- | --- |
-| body | Object
| Activity JSON. |
+| body | object
| Activity JSON. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.createXTActivity(body)
+### targetCoreAPI.createXTActivity(body, [options])
Create XT Activity.
Creates a new XT activity with the specified contents and returns the created activity.
@@ -182,11 +185,13 @@ Creates a new XT activity with the specified contents and returns the created ac
| Param | Type | Description |
| --- | --- | --- |
-| body | Object
| Activity JSON. |
+| body | object
| Activity JSON. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getABActivityById(id)
+### targetCoreAPI.getABActivityById(id, [options])
Get AB activity.
Fetch the current definition of an AB activity if it is found as referenced by the id.
@@ -194,11 +199,13 @@ Fetch the current definition of an AB activity if it is found as referenced by t
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getXTActivityById(id)
+### targetCoreAPI.getXTActivityById(id, [options])
Get XT activity.
Fetch the current definition of XT activity if it is found as referenced by the id.
@@ -206,11 +213,13 @@ Fetch the current definition of XT activity if it is found as referenced by the
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.updateABActivity(id)
+### targetCoreAPI.updateABActivity(id, body, [options])
Update AB activity.
Updates the AB activity definition with the contents as provided in the request. This can change the state and behaviour of an existing activity.
@@ -218,11 +227,14 @@ Updates the AB activity definition with the contents as provided in the request.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| body | object
| activity JSON |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.updateXTActivity(id)
+### targetCoreAPI.updateXTActivity(id, body, [options])
Update XT activity.
Update the current definition of XT activity if it is found as referenced by the id.
@@ -230,11 +242,14 @@ Update the current definition of XT activity if it is found as referenced by the
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| body | object
| activity JSON |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.setActivityName(id, name)
+### targetCoreAPI.setActivityName(id, name, [options])
Update activity name.
Updates the name of the AB activity that is referenced by the supplied id.
@@ -242,12 +257,14 @@ Updates the name of the AB activity that is referenced by the supplied id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
| name | string
| New Activity name. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.setActivityState(id, state)
+### targetCoreAPI.setActivityState(id, state, [options])
Update Activity state.
Update state of an activity if it is found as referenced by the id.
@@ -255,12 +272,14 @@ Update state of an activity if it is found as referenced by the id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
| state | string
| New Activity state. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.setActivityPriority(id, priority)
+### targetCoreAPI.setActivityPriority(id, priority, [options])
Update Activity priority.
Update priority of an activity if it is found as referenced by the id.
@@ -268,12 +287,14 @@ Update priority of an activity if it is found as referenced by the id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
| priority | string
| New Activity priority. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.setActivitySchedule(id, schedule)
+### targetCoreAPI.setActivitySchedule(id, schedule, [options])
Update Activity schedule.
Update schedule of an activity if it is found as referenced by the id.
@@ -281,12 +302,14 @@ Update schedule of an activity if it is found as referenced by the id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
| schedule | string
| New Activity schedule. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.deleteABActivity(id)
+### targetCoreAPI.deleteABActivity(id, [options])
Delete AB activity.
Deletes the AB activity that is referenced by the id, if it is found.
@@ -294,11 +317,13 @@ Deletes the AB activity that is referenced by the id, if it is found.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.deleteXTActivity(id)
+### targetCoreAPI.deleteXTActivity(id, [options])
Delete XT activity.
Delete the current definition of an XT activity if it is found as referenced by the id.
@@ -306,11 +331,13 @@ Delete the current definition of an XT activity if it is found as referenced by
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getActivityChangeLog(id)
+### targetCoreAPI.getActivityChangeLog(id, [options])
Get Activity changelog.
Returns the changelog for a given activity id.
@@ -318,26 +345,29 @@ Returns the changelog for a given activity id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getOffers(options)
+### targetCoreAPI.getOffers([options])
List Offers.
Retrieve the list of previously-created content offers. The parameters passed through the query string are optional and are used to indicate the sorting and filtering options.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
-| Param | Type | Description |
-| --- | --- | --- |
-| options | Object
| to control offer search. |
-| options.limit | | Defines the number of items to return. Default value is 2147483647 |
-| options.offset | | Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers. |
-| options.sortBy | | Defines the sorting criteria on the returned items. |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options] | object
| | to control offer search. |
+| [options.limit] | number
| 2147483647
| Defines the number of items to return |
+| [options.offset] | number
| 0
| Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers. |
+| [options.sortBy] | string
| | Defines the sorting criteria on the returned items. |
+| [options.headers] | object
| | headers to pass to API call |
-### targetCoreAPI.getOfferById(id)
+### targetCoreAPI.getOfferById(id, [options])
Get Offer.
Retrieves the contents of an offer given an offer id.
@@ -345,11 +375,13 @@ Retrieves the contents of an offer given an offer id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Offer id. |
+| id | number
| Offer id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.createOffer(body)
+### targetCoreAPI.createOffer(body, [options])
Create Offer.
Creates a new content offer as defined by the request data.
@@ -357,11 +389,13 @@ Creates a new content offer as defined by the request data.
| Param | Type | Description |
| --- | --- | --- |
-| body | Object
| Offer JSON. |
+| body | object
| Offer JSON. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.updateOffer(id)
+### targetCoreAPI.updateOffer(id, body, [options])
Update Offer.
Updates the content offer referenced by the id.
@@ -369,11 +403,14 @@ Updates the content offer referenced by the id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Offer id. |
+| id | number
| Offer id. |
+| body | object
| Offer JSON |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.deleteOffer(id)
+### targetCoreAPI.deleteOffer(id, [options])
Delete Offer.
Deletes the content offer referenced by the provided id.
@@ -381,26 +418,29 @@ Deletes the content offer referenced by the provided id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Offer id. |
+| id | number
| Offer id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getAudiences(options)
+### targetCoreAPI.getAudiences([options])
List Audiences.
List all available audiences with options to filter and sort by each available field.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
-| Param | Type | Description |
-| --- | --- | --- |
-| options | Object
| to control audience search. |
-| options.limit | | Defines the number of items to return. Default value is 2147483647 |
-| options.offset | | Defines the first audience to return from the list of total offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers. |
-| options.sortBy | | Defines the sorting criteria on the returned items. |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| [options] | object
| | options to control audience search. |
+| [options.limit] | number
| 2147483647
| Defines the number of items to return. Default value is 2147483647 |
+| [options.offset] | number
| 0
| Defines the first audience to return from the list of total offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers. |
+| [options.sortBy] | string
| | Defines the sorting criteria on the returned items. |
+| [options.headers] | object
| | headers to pass to API call |
-### targetCoreAPI.createAudience(body)
+### targetCoreAPI.createAudience(body, [options])
Create Audience.
Create a new audience as specified by the contents of the request and return the newly-created audience definition.
@@ -408,11 +448,13 @@ Create a new audience as specified by the contents of the request and return the
| Param | Type | Description |
| --- | --- | --- |
-| body | Object
| Audience JSON. |
+| body | object
| Audience JSON. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getAudienceById(id)
+### targetCoreAPI.getAudienceById(id, [options])
Get Audience.
Get the audience definition specified by the provided id.
@@ -420,11 +462,13 @@ Get the audience definition specified by the provided id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Audience id. |
+| id | number
| Audience id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.updateAudience(id)
+### targetCoreAPI.updateAudience(id, body, [options])
Update Audience.
Update an audience with the new rules specified by the request data.
@@ -432,11 +476,14 @@ Update an audience with the new rules specified by the request data.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Audience id. |
+| id | number
| Audience id. |
+| body | object
| audience JSON |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.deleteAudience(id)
+### targetCoreAPI.deleteAudience(id, [options])
Delete Audience.
Delete the audience referenced by the specified id.
@@ -444,18 +491,26 @@ Delete the audience referenced by the specified id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Audience id. |
+| id | number
| Audience id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getProperties()
+### targetCoreAPI.getProperties([options])
List Properties.
Get a list of properties.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
+
-### targetCoreAPI.getPropertyById(id)
+### targetCoreAPI.getPropertyById(id, [options])
Get Property.
Retrieve property by property Id..
@@ -463,18 +518,26 @@ Retrieve property by property Id..
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Property id. |
+| id | number
| Property id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getMBoxes()
+### targetCoreAPI.getMBoxes([options])
List MBoxes.
List all available mboxes for a specific client with the options to filter and sort.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
+
-### targetCoreAPI.getMBoxByName(name)
+### targetCoreAPI.getMBoxByName(name, [options])
Get MBox by name.
Get the list of mbox parameters.
@@ -482,25 +545,39 @@ Get the list of mbox parameters.
| Param | Type | Description |
| --- | --- | --- |
-| name | integer
| MBox name. |
+| name | number
| MBox name. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getMBoxProfileAttributes()
+### targetCoreAPI.getMBoxProfileAttributes([options])
Get Profile Attributes.
Retrieve the list of available profile attributes and mbox parameters of type profile.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
+
-### targetCoreAPI.getEnvironments()
+### targetCoreAPI.getEnvironments([options])
Get Environments.
List all available environments with the options to filter and sort. Use the Environments API to retrieve the environment IDs corresponding to the various host groups set for the client.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
+
-### targetCoreAPI.getABActivityPerformance(id)
+### targetCoreAPI.getABActivityPerformance(id, [options])
Get AB activity performance.
Retrieve property by property Id.
@@ -508,11 +585,13 @@ Retrieve property by property Id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getXTActivityPerformance(id)
+### targetCoreAPI.getXTActivityPerformance(id, [options])
Get activity performance.
Retrieve property by property Id.
@@ -520,11 +599,13 @@ Retrieve property by property Id.
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getActivityPerformance(id)
+### targetCoreAPI.getActivityPerformance(id, [options])
Get activity performance.
Retrieve the performance report data for the Automated Personalization activity referenced by the provided id.
@@ -532,11 +613,13 @@ Retrieve the performance report data for the Automated Personalization activity
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.getOrdersReport(id)
+### targetCoreAPI.getOrdersReport(id, [options])
Get Orders report.
Retrieve the orders/audit report data for an AB, XT or Autotmated Personalization Activity.
@@ -544,15 +627,22 @@ Retrieve the orders/audit report data for an AB, XT or Autotmated Personalizatio
| Param | Type | Description |
| --- | --- | --- |
-| id | integer
| Activity id. |
+| id | number
| Activity id. |
+| [options] | object
| sdk options |
+| [options.headers] | object
| headers to pass to API call |
-### targetCoreAPI.executeBatch()
+### targetCoreAPI.executeBatch(body)
Execute Batch APIs.
Multiple Admin APIs can be executed as a single batch request.
**Kind**: instance method of [TargetCoreAPI
](#TargetCoreAPI)
+
+| Param | Type | Description |
+| --- | --- | --- |
+| body | object
| json to execute batch |
+
## init(tenant, apiKey, token) ⇒ [Promise.<TargetCoreAPI>
](#TargetCoreAPI)
@@ -562,8 +652,8 @@ Returns a Promise that resolves with a new TargetCoreAPI object.
| Param | Type | Description |
| --- | --- | --- |
-| tenant | string
| Adobe Target tenant name. |
-| apiKey | string
| Your api key |
+| tenant | string
| tenant Adobe Target tenant name |
+| apiKey | string
| apiKey Your api key |
| token | string
| Valid auth token |
### Debug Logs
diff --git a/docs/readme_template.md b/docs/readme_template.md
index 69a0f0f..b9f1440 100644
--- a/docs/readme_template.md
+++ b/docs/readme_template.md
@@ -13,7 +13,7 @@ governing permissions and limitations under the License.
[![Version](https://img.shields.io/npm/v/@adobe/aio-lib-target.svg)](https://npmjs.org/package/@adobe/aio-lib-target)
[![Downloads/week](https://img.shields.io/npm/dw/@adobe/aio-lib-target.svg)](https://npmjs.org/package/@adobe/aio-lib-target)
[![Build Status](https://travis-ci.com/adobe/aio-lib-target.svg?branch=master)](https://travis-ci.com/adobe/aio-lib-target)
-[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Greenkeeper badge](https://badges.greenkeeper.io/adobe/aio-lib-target.svg)](https://greenkeeper.io/)
+[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/adobe/aio-lib-target/master.svg?style=flat-square)](https://codecov.io/gh/adobe/aio-lib-target/)
# I/O Adobe Target SDK
diff --git a/e2e/e2e.js b/e2e/e2e.js
index c43d88d..9af6189 100644
--- a/e2e/e2e.js
+++ b/e2e/e2e.js
@@ -14,6 +14,7 @@ const sdk = require('../src/index')
const path = require('path')
// load .env values in the e2e folder, if any
+/* eslint-disable-next-line node/no-unpublished-require */
require('dotenv').config({ path: path.join(__dirname, '.env') })
var sdkClient = {}
diff --git a/package.json b/package.json
index 9091b54..70ce59f 100644
--- a/package.json
+++ b/package.json
@@ -19,16 +19,18 @@
"@adobe/aio-lib-core-logging": "1.1.0"
},
"devDependencies": {
+ "@adobe/eslint-config-aio-lib-config": "^1.2.0",
"codecov": "^3.6.1",
"dotenv": "^8.1.0",
- "eslint": "^6.2.2",
- "eslint-config-standard": "^14.1.0",
- "eslint-plugin-import": "^2.18.0",
- "eslint-plugin-jest": "^23.0.2",
- "eslint-plugin-node": "^11.0.0",
+ "eslint": "^6.0.0",
+ "eslint-config-standard": "^14.1.1",
+ "eslint-plugin-import": "^2.22.0",
+ "eslint-plugin-jest": "^23.18.0",
+ "eslint-plugin-jsdoc": "^21.0.0",
+ "eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
- "eslint-plugin-standard": "^4.0.0",
- "fetch-mock": "^9.0.0",
+ "eslint-plugin-standard": "^4.0.1",
+ "fetch-mock": "^9.10.3",
"jest": "^24.1.0",
"jest-cli": "^24.8.0",
"jest-junit": "^10.0.0",
diff --git a/src/index.js b/src/index.js
index 9c9a11f..e33c7d4 100644
--- a/src/index.js
+++ b/src/index.js
@@ -22,13 +22,13 @@ const ACCEPT_HEADERS = {
}
/**
- * Returns a Promise that resolves with a new TargetCoreAPI object.
- *
- * @param tenant {string} Adobe Target tenant name.
- * @param apiKey {string} Your api key
- * @param token {string} Valid auth token
- * @returns {Promise}
- */
+ * Returns a Promise that resolves with a new TargetCoreAPI object.
+ *
+ * @param {string} tenant tenant Adobe Target tenant name
+ * @param {string} apiKey apiKey Your api key
+ * @param {string} token Valid auth token
+ * @returns {Promise}
+ */
function init (tenant, apiKey, token) {
return new Promise((resolve, reject) => {
const clientWrapper = new TargetCoreAPI()
@@ -46,18 +46,18 @@ function init (tenant, apiKey, token) {
}
/**
-* This class provides methods to call Adobe Target APIs.
-* Before calling any method initialize the instance by calling init method on it
-* with valid tenant, apiKey and auth token
-*/
+ * This class provides methods to call Adobe Target APIs.
+ * Before calling any method initialize the instance by calling init method on it
+ * with valid tenant, apiKey and auth token
+ */
class TargetCoreAPI {
/** Initialize sdk.
- *
- * @param tenant {string} Adobe Target tenant name.
- * @param apiKey {string} Your api key
- * @param token {string} Valid auth token
- * @returns {TargetCoreAPI}
- */
+ *
+ * @param tenant {string} Adobe Target tenant name
+ * @param apiKey {string} Your api key
+ * @param token {string} Valid auth token
+ * @returns {TargetCoreAPI}
+ */
async init (tenant, apiKey, token) {
const initErrors = []
if (!tenant) {
@@ -89,17 +89,19 @@ class TargetCoreAPI {
}
/** List activities.
- * Get a list of activities created in your Target account, with the ability to filter and sort by attributes.
- *
- * @param options {Object} to control activity search.
- * @param options.limit Defines the number of items to return. Default value is 2147483647
- * @param options.offset Defines the first activity to return from the list of total activities. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of activities.
- * @param options.sortBy Defines the sorting criteria on the returned items.
- */
- getActivities ({ limit = 2147483647, offset = 0, sortBy } = {}) {
- const sdkDetails = arguments[0]
+ * Get a list of activities created in your Target account, with the ability to filter and sort by attributes.
+ *
+ * @param {object} [options] to control activity search
+ * @param {number} [options.limit = 2147483647] Defines the number of items to return
+ * @param {number} [options.offset = 0] Defines the first activity to return from the list of total activities. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of activities.
+ * @param {string} [options.sortBy] Defines the sorting criteria on the returned items
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getActivities (options = { limit: 2147483647, offset: 0 }) {
+ const sdkDetails = options
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.activities.getActivities(arguments[0], this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.activities.getActivities(arguments[0], this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -110,14 +112,17 @@ class TargetCoreAPI {
}
/** Create AB Activity.
- * Creates a new AB activity with the specified contents and returns the created activity.
- *
- * @param body {Object} Activity JSON.
- */
- createABActivity (body) {
+ * Creates a new AB activity with the specified contents and returns the created activity.
+ *
+ * @param {object} body Activity JSON.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ createABActivity (body, options = {}) {
const sdkDetails = body
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.abactivity.createABActivity({}, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.abactivity.createABActivity({}, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -128,14 +133,17 @@ class TargetCoreAPI {
}
/** Create XT Activity.
- * Creates a new XT activity with the specified contents and returns the created activity.
- *
- * @param body {Object} Activity JSON.
- */
- createXTActivity (body) {
+ * Creates a new XT activity with the specified contents and returns the created activity.
+ *
+ * @param {object} body Activity JSON.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ createXTActivity (body, options = {}) {
const sdkDetails = body
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.xtactivity.createXTActivity({}, this.__createRequest(body), this.__getContentTypeHeader(ACCEPT_HEADERS.V3))
+ this.sdk.apis.xtactivity.createXTActivity({}, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -146,16 +154,19 @@ class TargetCoreAPI {
}
/** Get AB activity.
- * Fetch the current definition of an AB activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- */
- getABActivityById (id) {
+ * Fetch the current definition of an AB activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getABActivityById (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.abactivity.getABActivity(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.abactivity.getABActivity(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -166,16 +177,19 @@ class TargetCoreAPI {
}
/** Get XT activity.
- * Fetch the current definition of XT activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- */
- getXTActivityById (id) {
+ * Fetch the current definition of XT activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getXTActivityById (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.xtactivity.getXTActivity(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.xtactivity.getXTActivity(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -186,16 +200,20 @@ class TargetCoreAPI {
}
/** Update AB activity.
- * Updates the AB activity definition with the contents as provided in the request. This can change the state and behaviour of an existing activity.
- *
- * @param id {integer} Activity id.
- */
- updateABActivity (id, body) {
+ * Updates the AB activity definition with the contents as provided in the request. This can change the state and behaviour of an existing activity.
+ *
+ * @param {number} id Activity id.
+ * @param {object} body activity JSON
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ updateABActivity (id, body, options = {}) {
var params = {}
params.id = id
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.abactivity.updateABActivity(params, this.__createRequest(body))
+ this.sdk.apis.abactivity.updateABActivity(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -206,16 +224,20 @@ class TargetCoreAPI {
}
/** Update XT activity.
- * Update the current definition of XT activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- */
- updateXTActivity (id, body) {
+ * Update the current definition of XT activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} body activity JSON
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ updateXTActivity (id, body, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.xtactivity.updateXTActivity(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.xtactivity.updateXTActivity(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -226,20 +248,23 @@ class TargetCoreAPI {
}
/** Update activity name.
- * Updates the name of the AB activity that is referenced by the supplied id.
- *
- * @param id {integer} Activity id.
- * @param name {string} New Activity name.
- */
- setActivityName (id, name) {
+ * Updates the name of the AB activity that is referenced by the supplied id.
+ *
+ * @param {number} id Activity id.
+ * @param {string} name New Activity name.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ setActivityName (id, name, options = {}) {
var params = {}
params.id = id
var body = {
name: name
}
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.activity.setName(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.activity.setName(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -250,12 +275,14 @@ class TargetCoreAPI {
}
/** Update Activity state.
- * Update state of an activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- * @param state {string} New Activity state.
- */
- setActivityState (id, state) {
+ * Update state of an activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {string} state New Activity state.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ setActivityState (id, state, options = {}) {
var params = {}
params.id = id
@@ -263,8 +290,9 @@ class TargetCoreAPI {
state: state
}
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.activity.setState(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.activity.setState(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -275,12 +303,14 @@ class TargetCoreAPI {
}
/** Update Activity priority.
- * Update priority of an activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- * @param priority {string} New Activity priority.
- */
- setActivityPriority (id, priority) {
+ * Update priority of an activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {string} priority New Activity priority.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ setActivityPriority (id, priority, options = {}) {
var params = {}
params.id = id
@@ -288,8 +318,9 @@ class TargetCoreAPI {
priority: priority
}
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.activity.setPriority(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.activity.setPriority(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -300,12 +331,14 @@ class TargetCoreAPI {
}
/** Update Activity schedule.
- * Update schedule of an activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- * @param schedule {string} New Activity schedule.
- */
- setActivitySchedule (id, schedule) {
+ * Update schedule of an activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {string} schedule New Activity schedule.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ setActivitySchedule (id, schedule, options = {}) {
var params = {}
params.id = id
@@ -313,8 +346,9 @@ class TargetCoreAPI {
schedule: schedule
}
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.activity.setSchedule(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.activity.setSchedule(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -325,16 +359,19 @@ class TargetCoreAPI {
}
/** Delete AB activity.
- * Deletes the AB activity that is referenced by the id, if it is found.
- *
- * @param id {integer} Activity id.
- */
- deleteABActivity (id) {
+ * Deletes the AB activity that is referenced by the id, if it is found.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ deleteABActivity (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.abactivity.deleteABActivity(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.abactivity.deleteABActivity(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -345,16 +382,19 @@ class TargetCoreAPI {
}
/** Delete XT activity.
- * Delete the current definition of an XT activity if it is found as referenced by the id.
- *
- * @param id {integer} Activity id.
- */
- deleteXTActivity (id) {
+ * Delete the current definition of an XT activity if it is found as referenced by the id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ deleteXTActivity (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.xtactivity.deleteXTActivity(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.xtactivity.deleteXTActivity(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -365,16 +405,19 @@ class TargetCoreAPI {
}
/** Get Activity changelog.
- * Returns the changelog for a given activity id.
- *
- * @param id {integer} Activity id.
- */
- getActivityChangeLog (id) {
+ * Returns the changelog for a given activity id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getActivityChangeLog (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.activity.getChangeLog(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.activity.getChangeLog(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -385,17 +428,19 @@ class TargetCoreAPI {
}
/** List Offers.
- * Retrieve the list of previously-created content offers. The parameters passed through the query string are optional and are used to indicate the sorting and filtering options.
- *
- * @param options {Object} to control offer search.
- * @param options.limit Defines the number of items to return. Default value is 2147483647
- * @param options.offset Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
- * @param options.sortBy Defines the sorting criteria on the returned items.
- */
- getOffers ({ limit = 2147483647, offset = 0, sortBy } = {}) {
- const sdkDetails = arguments[0]
+ * Retrieve the list of previously-created content offers. The parameters passed through the query string are optional and are used to indicate the sorting and filtering options.
+ *
+ * @param {object} [options] to control offer search.
+ * @param {number} [options.limit = 2147483647] Defines the number of items to return
+ * @param {number} [options.offset = 0] Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
+ * @param {string} [options.sortBy] Defines the sorting criteria on the returned items.
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getOffers (options = { limit: 2147483647, offset: 0 }) {
+ const sdkDetails = options
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.offers.getOffers(arguments[0], this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V2)))
+ this.sdk.apis.offers.getOffers(arguments[0], this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V2)))
.then(response => {
resolve(response)
})
@@ -406,16 +451,19 @@ class TargetCoreAPI {
}
/** Get Offer.
- * Retrieves the contents of an offer given an offer id.
- *
- * @param id {integer} Offer id.
- */
- getOfferById (id) {
+ * Retrieves the contents of an offer given an offer id.
+ *
+ * @param {number} id Offer id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getOfferById (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.offer.getOfferById(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V2)))
+ this.sdk.apis.offer.getOfferById(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V2)))
.then(response => {
resolve(response)
})
@@ -426,14 +474,17 @@ class TargetCoreAPI {
}
/** Create Offer.
- * Creates a new content offer as defined by the request data.
- *
- * @param body {Object} Offer JSON.
- */
- createOffer (body) {
+ * Creates a new content offer as defined by the request data.
+ *
+ * @param {object} body Offer JSON.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ createOffer (body, options = {}) {
const sdkDetails = body
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.offers.createOffer({}, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V2)))
+ this.sdk.apis.offers.createOffer({}, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V2)))
.then(response => {
resolve(response)
})
@@ -443,17 +494,22 @@ class TargetCoreAPI {
})
}
- /** Update Offer.
- * Updates the content offer referenced by the id.
- *
- * @param id {integer} Offer id.
- */
- updateOffer (id, body) {
+ /**
+ * Update Offer.
+ * Updates the content offer referenced by the id.
+ *
+ * @param {number} id Offer id.
+ * @param {object} body Offer JSON
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ updateOffer (id, body, options = {}) {
var params = {}
params.id = id
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.offer.updateOffer(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V2)))
+ this.sdk.apis.offer.updateOffer(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V2)))
.then(response => {
resolve(response)
})
@@ -464,16 +520,19 @@ class TargetCoreAPI {
}
/** Delete Offer.
- * Deletes the content offer referenced by the provided id.
- *
- * @param id {integer} Offer id.
- */
- deleteOffer (id) {
+ * Deletes the content offer referenced by the provided id.
+ *
+ * @param {number} id Offer id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ deleteOffer (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.offer.deleteOffer(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V2)))
+ this.sdk.apis.offer.deleteOffer(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V2)))
.then(response => {
resolve(response)
})
@@ -484,17 +543,19 @@ class TargetCoreAPI {
}
/** List Audiences.
- * List all available audiences with options to filter and sort by each available field.
- *
- * @param options {Object} to control audience search.
- * @param options.limit Defines the number of items to return. Default value is 2147483647
- * @param options.offset Defines the first audience to return from the list of total offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
- * @param options.sortBy Defines the sorting criteria on the returned items.
- */
- getAudiences ({ limit = 2147483647, offset = 0, sortBy } = {}) {
- const sdkDetails = arguments[0]
+ * List all available audiences with options to filter and sort by each available field.
+ *
+ * @param {object} [options] options to control audience search.
+ * @param {number } [options.limit = 2147483647] Defines the number of items to return. Default value is 2147483647
+ * @param {number} [options.offset = 0] Defines the first audience to return from the list of total offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
+ * @param {string} [options.sortBy] Defines the sorting criteria on the returned items.
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getAudiences (options = { limit: 2147483647, offset: 0 }) {
+ const sdkDetails = options
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.audiences.getAudiences(arguments[0], this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.audiences.getAudiences(arguments[0], this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -505,14 +566,17 @@ class TargetCoreAPI {
}
/** Create Audience.
- * Create a new audience as specified by the contents of the request and return the newly-created audience definition.
- *
- * @param body {Object} Audience JSON.
- */
- createAudience (body) {
+ * Create a new audience as specified by the contents of the request and return the newly-created audience definition.
+ *
+ * @param {object} body Audience JSON.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ createAudience (body, options = {}) {
const sdkDetails = body
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.audiences.createAudience({}, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.audiences.createAudience({}, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -523,16 +587,19 @@ class TargetCoreAPI {
}
/** Get Audience.
- * Get the audience definition specified by the provided id.
- *
- * @param id {integer} Audience id.
- */
- getAudienceById (id) {
+ * Get the audience definition specified by the provided id.
+ *
+ * @param {number} id Audience id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getAudienceById (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.audiences.getAudienceById(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.audiences.getAudienceById(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -543,16 +610,20 @@ class TargetCoreAPI {
}
/** Update Audience.
- * Update an audience with the new rules specified by the request data.
- *
- * @param id {integer} Audience id.
- */
- updateAudience (id, body) {
+ * Update an audience with the new rules specified by the request data.
+ *
+ * @param {number} id Audience id.
+ * @param {object }body audience JSON
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ updateAudience (id, body, options = {}) {
var params = {}
params.id = id
const sdkDetails = { params, body }
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.audience.updateAudience(params, this.__createRequest(body, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.audience.updateAudience(params, this.__createRequest(body, headers, this.__getContentTypeHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -563,16 +634,19 @@ class TargetCoreAPI {
}
/** Delete Audience.
- * Delete the audience referenced by the specified id.
- *
- * @param id {integer} Audience id.
- */
- deleteAudience (id) {
+ * Delete the audience referenced by the specified id.
+ *
+ * @param {number} id Audience id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ deleteAudience (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.audience.deleteAudience(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
+ this.sdk.apis.audience.deleteAudience(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -583,12 +657,16 @@ class TargetCoreAPI {
}
/** List Properties.
- * Get a list of properties.
- */
- getProperties () {
- const sdkDetails = {}
+ * Get a list of properties.
+ *
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getProperties (options = {}) {
+ const sdkDetails = options
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.properties.getProperties({}, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.properties.getProperties({}, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -599,16 +677,19 @@ class TargetCoreAPI {
}
/** Get Property.
- * Retrieve property by property Id..
- *
- * @param id {integer} Property id.
- */
- getPropertyById (id) {
+ * Retrieve property by property Id..
+ *
+ * @param {number} id Property id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getPropertyById (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.properties.getAPropertyById(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.properties.getAPropertyById(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -619,12 +700,16 @@ class TargetCoreAPI {
}
/** List MBoxes.
- * List all available mboxes for a specific client with the options to filter and sort.
- */
- getMBoxes () {
+ * List all available mboxes for a specific client with the options to filter and sort.
+ *
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getMBoxes (options = {}) {
const sdkDetails = {}
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.mboxes.getMBoxes({}, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.mboxes.getMBoxes({}, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -635,16 +720,19 @@ class TargetCoreAPI {
}
/** Get MBox by name.
- * Get the list of mbox parameters.
- *
- * @param name {integer} MBox name.
- */
- getMBoxByName (name) {
+ * Get the list of mbox parameters.
+ *
+ * @param {string} name MBox name.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getMBoxByName (name, options = {}) {
var params = {}
params.mboxName = name
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.mboxes.getMBoxByName(params, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.mboxes.getMBoxByName(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -655,12 +743,16 @@ class TargetCoreAPI {
}
/** Get Profile Attributes.
- * Retrieve the list of available profile attributes and mbox parameters of type profile.
- */
- getMBoxProfileAttributes () {
- const sdkDetails = {}
+ * Retrieve the list of available profile attributes and mbox parameters of type profile.
+ *
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getMBoxProfileAttributes (options = {}) {
+ const sdkDetails = options
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.mbox.getProfileAttributes({}, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.mbox.getProfileAttributes({}, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -671,12 +763,16 @@ class TargetCoreAPI {
}
/** Get Environments.
- * List all available environments with the options to filter and sort. Use the Environments API to retrieve the environment IDs corresponding to the various host groups set for the client.
- */
- getEnvironments () {
- const sdkDetails = {}
+ * List all available environments with the options to filter and sort. Use the Environments API to retrieve the environment IDs corresponding to the various host groups set for the client.
+ *
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getEnvironments (options = {}) {
+ const sdkDetails = options
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.environments.getEnvironments({}, this.__createRequest({}, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
+ this.sdk.apis.environments.getEnvironments({}, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V1)))
.then(response => {
resolve(response)
})
@@ -687,16 +783,19 @@ class TargetCoreAPI {
}
/** Get AB activity performance.
- * Retrieve property by property Id.
- *
- * @param id {integer} Activity id.
- */
- getABActivityPerformance (id) {
+ * Retrieve property by property Id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getABActivityPerformance (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.reports.getABPerformance(params, this.__createRequest({}))
+ this.sdk.apis.reports.getABPerformance(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -707,16 +806,19 @@ class TargetCoreAPI {
}
/** Get activity performance.
- * Retrieve property by property Id.
- *
- * @param id {integer} Activity id.
- */
- getXTActivityPerformance (id) {
+ * Retrieve property by property Id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getXTActivityPerformance (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.reports.getXTPerformance(params, this.__createRequest({}))
+ this.sdk.apis.reports.getXTPerformance(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -727,16 +829,19 @@ class TargetCoreAPI {
}
/** Get activity performance.
- * Retrieve the performance report data for the Automated Personalization activity referenced by the provided id.
- *
- * @param id {integer} Activity id.
- */
- getActivityPerformance (id) {
+ * Retrieve the performance report data for the Automated Personalization activity referenced by the provided id.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getActivityPerformance (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.reports.getABTPerformance(params, this.__createRequest({}))
+ this.sdk.apis.reports.getABTPerformance(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -747,16 +852,19 @@ class TargetCoreAPI {
}
/** Get Orders report.
- * Retrieve the orders/audit report data for an AB, XT or Autotmated Personalization Activity.
- *
- * @param id {integer} Activity id.
- */
- getOrdersReport (id) {
+ * Retrieve the orders/audit report data for an AB, XT or Autotmated Personalization Activity.
+ *
+ * @param {number} id Activity id.
+ * @param {object} [options] sdk options
+ * @param {object} [options.headers] headers to pass to API call
+ */
+ getOrdersReport (id, options = {}) {
var params = {}
params.id = id
const sdkDetails = params
+ const headers = options.headers ? options.headers : {}
return new Promise((resolve, reject) => {
- this.sdk.apis.reports.getAuditReport(params, this.__createRequest({}))
+ this.sdk.apis.reports.getAuditReport(params, this.__createRequest({}, headers, this.__getAcceptHeader(ACCEPT_HEADERS.V3)))
.then(response => {
resolve(response)
})
@@ -766,9 +874,12 @@ class TargetCoreAPI {
})
}
- /** Execute Batch APIs.
- * Multiple Admin APIs can be executed as a single batch request.
- */
+ /**
+ * Execute Batch APIs.
+ * Multiple Admin APIs can be executed as a single batch request.
+ *
+ * @param {object} body json to execute batch
+ */
executeBatch (body) {
const sdkDetails = body
return new Promise((resolve, reject) => {
@@ -782,7 +893,8 @@ class TargetCoreAPI {
})
}
- __createRequest (body, headers) {
+ __createRequest (body, headers, defaultHeaders = {}) {
+ const finalHeaders = Object.assign(defaultHeaders, headers)
return {
requestBody: body,
server: 'https://mc.adobe.io/{tenant-name}/target',
@@ -790,7 +902,7 @@ class TargetCoreAPI {
'tenant-name': this.tenant
},
requestInterceptor: req => {
- this.__setHeaders(req, this, headers)
+ this.__setHeaders(req, this, finalHeaders)
}
}
}
@@ -806,11 +918,9 @@ class TargetCoreAPI {
if (!req.headers['Content-Type']) {
req.headers['Content-Type'] = 'application/json'
}
- if ((headers !== undefined)) {
- Object.keys(headers).forEach(function (key) {
- req.headers[key] = headers[key]
- })
- }
+ Object.keys(headers).forEach(function (key) {
+ req.headers[key] = headers[key]
+ })
}
__getAcceptHeader (value) {
diff --git a/test/index.test.js b/test/index.test.js
index c93c4af..6f78cc5 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -8,6 +8,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
+/* eslint-disable-next-line node/no-unpublished-require */
const fetchMock = require('fetch-mock')
const mock = require('./mock')
const sdk = require('../src')
@@ -15,8 +16,18 @@ const errorSDK = require('../src/SDKErrors')
const tenant = 'test-tenant'
const apiKey = 'test-apikey'
const token = 'test-token'
+const ACCEPT_HEADERS = {
+ V1: 'application/vnd.adobe.target.v1+json',
+ V2: 'application/vnd.adobe.target.v2+json',
+ V3: 'application/vnd.adobe.target.v3+json'
+}
var sdkClient = {}
+/**
+ * @param url
+ * @param method
+ * @param response
+ */
function mockResponseWithMethod (url, method, response) {
fetchMock.reset()
fetchMock.mock((u, opts) => u === url && opts.method === method, response)
@@ -54,6 +65,11 @@ test('test getActivities', async () => {
expect(res.body.limit).toBe(10)
expect(res.body.activities.length).toBe(2)
+ res = await sdkClient.getActivities({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(2)
+ expect(res.body.limit).toBe(10)
+ expect(res.body.activities.length).toBe(2)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_ACTIVITIES())
@@ -92,6 +108,9 @@ test('test createABActivity', async () => {
var res = await sdkClient.createABActivity(obj)
expect(res.body.id).toBe(123)
+ res = await sdkClient.createABActivity(obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_CREATE_AB_ACTIVITY())
@@ -130,6 +149,9 @@ test('test createXTActivity', async () => {
var res = await sdkClient.createXTActivity(obj)
expect(res.body.id).toBe(321)
+ res = await sdkClient.createXTActivity(obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(321)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_CREATE_XT_ACTIVITY())
@@ -149,6 +171,9 @@ test('test getABActivityById', async () => {
var res = await sdkClient.getABActivityById(123)
expect(res.body.id).toBe(123)
+ res = await sdkClient.getABActivityById(123, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_AB_ACTIVITY_BY_ID(), [123])
@@ -170,6 +195,9 @@ test('test getXTActivityById', async () => {
var res = await sdkClient.getXTActivityById(321)
expect(res.body.id).toBe(321)
+ res = await sdkClient.getXTActivityById(321, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(321)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_XT_ACTIVITY_BY_ID(), [321])
@@ -211,6 +239,9 @@ test('test updateABActivity', async () => {
var res = await sdkClient.updateABActivity(123, obj)
expect(res.body.id).toBe(123)
+ res = await sdkClient.updateABActivity(123, obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_UPDATE_AB_ACTIVITY(), [123, obj])
@@ -250,6 +281,9 @@ test('test updateXTActivity', async () => {
var res = await sdkClient.updateXTActivity(321, obj)
expect(res.body.id).toBe(321)
+ res = await sdkClient.updateXTActivity(321, obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(321)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_UPDATE_XT_ACTIVITY(), [321, obj])
@@ -270,6 +304,10 @@ test('test setActivityName', async () => {
expect(res.body.id).toBe(123)
expect(res.body.name).toBe('new name')
+ res = await sdkClient.setActivityName(123, 'new name', { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+ expect(res.body.name).toBe('new name')
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_SET_ACTIVITY_NAME(), [123, 'new name'])
@@ -290,6 +328,10 @@ test('test setActivityState', async () => {
expect(res.body.id).toBe(123)
expect(res.body.state).toBe('activated')
+ res = await sdkClient.setActivityState(123, 'activated', { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+ expect(res.body.state).toBe('activated')
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_SET_ACTIVITY_STATE(), [123, 'activated'])
@@ -310,6 +352,10 @@ test('test setActivityPriority', async () => {
expect(res.body.id).toBe(123)
expect(res.body.priority).toBe('5')
+ res = await sdkClient.setActivityPriority(123, '5', { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+ expect(res.body.priority).toBe('5')
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_SET_ACTIVITY_PRIORITY(), [123, '5'])
@@ -336,6 +382,11 @@ test('test setActivitySchedule', async () => {
expect(res.body.startsAt).toBe('2017-05-01T08:00Z')
expect(res.body.endsAt).toBe('2017-09-01T07:59:59Z')
+ res = await sdkClient.setActivitySchedule(123, obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+ expect(res.body.startsAt).toBe('2017-05-01T08:00Z')
+ expect(res.body.endsAt).toBe('2017-09-01T07:59:59Z')
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_SET_ACTIVITY_SCHEDULE(), [123, obj])
@@ -355,6 +406,9 @@ test('test deleteABActivity', async () => {
var res = await sdkClient.deleteABActivity(123)
expect(res.body.id).toBe(123)
+ res = await sdkClient.deleteABActivity(123, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_DELETE_AB_ACTIVITY(), [123])
@@ -376,6 +430,9 @@ test('test deleteXTActivity', async () => {
var res = await sdkClient.deleteXTActivity(321)
expect(res.body.id).toBe(321)
+ res = await sdkClient.deleteXTActivity(321, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(321)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_DELETE_XT_ACTIVITY(), [321])
@@ -398,6 +455,10 @@ test('test getActivityChangeLog', async () => {
expect(res.body.total).toBe(2)
expect(res.body.activityChangelogs.length).toBe(2)
+ res = await sdkClient.getActivityChangeLog(123, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(2)
+ expect(res.body.activityChangelogs.length).toBe(2)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_ACTIVITY_CHANGELOG(), [123])
@@ -421,6 +482,11 @@ test('test getOffers', async () => {
expect(res.body.limit).toBe(10)
expect(res.body.offers.length).toBe(2)
+ res = await sdkClient.getOffers({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(2)
+ expect(res.body.limit).toBe(10)
+ expect(res.body.offers.length).toBe(2)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_OFFERS())
@@ -440,6 +506,9 @@ test('test getOfferById', async () => {
var res = await sdkClient.getOfferById(111)
expect(res.body.id).toBe(111)
+ res = await sdkClient.getOfferById(111, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(111)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_OFFER_BY_ID(), [111])
@@ -467,6 +536,9 @@ test('test createOffer', async () => {
var res = await sdkClient.createOffer(obj)
expect(res.body.id).toBe(123)
+ res = await sdkClient.createOffer(obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_CREATE_OFFER(), [obj])
@@ -491,6 +563,9 @@ test('test updateOffer', async () => {
var res = await sdkClient.updateOffer(123, obj)
expect(res.body.content).toBe('Updated content
')
+ res = await sdkClient.updateOffer(123, obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.content).toBe('Updated content
')
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_UPDATE_OFFER(), [123, obj])
@@ -510,6 +585,9 @@ test('test deleteOffer', async () => {
var res = await sdkClient.deleteOffer(111)
expect(res.body.id).toBe(111)
+ res = await sdkClient.deleteOffer(111, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(111)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_DELETE_OFFER(), [111])
@@ -533,6 +611,11 @@ test('test getAudiences', async () => {
expect(res.body.limit).toBe(10)
expect(res.body.audiences.length).toBe(2)
+ res = await sdkClient.getAudiences({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(2)
+ expect(res.body.limit).toBe(10)
+ expect(res.body.audiences.length).toBe(2)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_AUDIENCES())
@@ -574,6 +657,9 @@ test('test createAudience', async () => {
var res = await sdkClient.createAudience(obj)
expect(res.body.id).toBe(123)
+ res = await sdkClient.createAudience(obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(123)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_CREATE_AUDIENCE(), [obj])
@@ -593,6 +679,9 @@ test('test getAudienceById', async () => {
var res = await sdkClient.getAudienceById(111)
expect(res.body.id).toBe(111)
+ res = await sdkClient.getAudienceById(111, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(111)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_AUDIENCE_BY_ID(), [111])
@@ -619,6 +708,9 @@ test('test updateAudience', async () => {
var res = await sdkClient.updateAudience(123, obj)
expect(res.body.name).toBe('Updated Gold Members in Califo-1495136673062')
+ res = await sdkClient.updateAudience(123, obj, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.name).toBe('Updated Gold Members in Califo-1495136673062')
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_UPDATE_AUDIENCE(), [123, obj])
@@ -638,6 +730,9 @@ test('test deleteAudience', async () => {
var res = await sdkClient.deleteAudience(111)
expect(res.body.id).toBe(111)
+ res = await sdkClient.deleteAudience(111, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(111)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_DELETE_AUDIENCE(), [111])
@@ -661,6 +756,11 @@ test('test getProperties', async () => {
expect(res.body.limit).toBe(10)
expect(res.body.properties.length).toBe(2)
+ res = await sdkClient.getProperties({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(2)
+ expect(res.body.limit).toBe(10)
+ expect(res.body.properties.length).toBe(2)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_PROPERTIES())
@@ -680,6 +780,9 @@ test('test getPropertyById', async () => {
var res = await sdkClient.getPropertyById(111)
expect(res.body.id).toBe(111)
+ res = await sdkClient.getPropertyById(111, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.id).toBe(111)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_PROPERTY_BY_ID(), [111])
@@ -703,6 +806,11 @@ test('test getMBoxes', async () => {
expect(res.body.limit).toBe(5)
expect(res.body.mboxes.length).toBe(2)
+ res = await sdkClient.getMBoxes({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(2)
+ expect(res.body.limit).toBe(5)
+ expect(res.body.mboxes.length).toBe(2)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_MBOXES())
@@ -723,6 +831,10 @@ test('test getMBoxByName', async () => {
expect(res.body.name).toBe('a1-mobile-mboxparams')
expect(res.body.mboxParameters.length).toBe(3)
+ res = await sdkClient.getMBoxByName('a1-mobile-mboxparams', { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.name).toBe('a1-mobile-mboxparams')
+ expect(res.body.mboxParameters.length).toBe(3)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_MBOX_BY_NAME(), ['a1-mobile-mboxparams'])
@@ -744,6 +856,9 @@ test('test getMBoxProfileAttributes', async () => {
var res = await sdkClient.getMBoxProfileAttributes()
expect(res.body.mboxParameters.length).toBe(3)
+ res = await sdkClient.getMBoxProfileAttributes({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.mboxParameters.length).toBe(3)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_MBOX_PROFILE_ATTRIBUTES())
@@ -765,6 +880,11 @@ test('test getEnvironments', async () => {
expect(res.body.limit).toBe(2147483647)
expect(res.body.environments.length).toBe(3)
+ res = await sdkClient.getEnvironments({ headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.total).toBe(3)
+ expect(res.body.limit).toBe(2147483647)
+ expect(res.body.environments.length).toBe(3)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_ENVIRONMENTS())
@@ -786,6 +906,11 @@ test('test getABActivityPerformance', async () => {
expect(res.body.activity.metrics.length).toBe(1)
expect(res.body.activity.experiences.length).toBe(1)
+ res = await sdkClient.getABActivityPerformance(111, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.reportParameters.activityId).toBe(111)
+ expect(res.body.activity.metrics.length).toBe(1)
+ expect(res.body.activity.experiences.length).toBe(1)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_AB_ACTIVITY_PERFORMANCE(), [111])
@@ -807,6 +932,11 @@ test('test getXTActivityPerformance', async () => {
expect(res.body.activity.metrics.length).toBe(1)
expect(res.body.activity.experiences.length).toBe(1)
+ res = await sdkClient.getXTActivityPerformance(123, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.reportParameters.activityId).toBe(123)
+ expect(res.body.activity.metrics.length).toBe(1)
+ expect(res.body.activity.experiences.length).toBe(1)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_XT_ACTIVITY_PERFORMANCE(), [123])
@@ -828,6 +958,11 @@ test('test getActivityPerformance', async () => {
expect(res.body.activity.metrics.length).toBe(1)
expect(res.body.activity.experiences.length).toBe(1)
+ res = await sdkClient.getActivityPerformance(123, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.reportParameters.activityId).toBe(123)
+ expect(res.body.activity.metrics.length).toBe(1)
+ expect(res.body.activity.experiences.length).toBe(1)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_ACTIVITY_PERFORMANCE(), [123])
@@ -849,6 +984,11 @@ test('test getOrdersReport', async () => {
expect(res.body.activity.metrics.length).toBe(1)
expect(res.body.activity.experiences.length).toBe(1)
+ res = await sdkClient.getOrdersReport(123, { headers: { accept: ACCEPT_HEADERS.V1 } })
+ expect(res.body.reportParameters.activityId).toBe(123)
+ expect(res.body.activity.metrics.length).toBe(1)
+ expect(res.body.activity.experiences.length).toBe(1)
+
// check error responses
mockResponseWithMethod(url, method, mock.errors.Unauthorized_Request.err)
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_GET_ORDERS_REPORT(), [123])
@@ -910,6 +1050,13 @@ test('test executeBatch', async () => {
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_EXECUTE_BATCH(), [obj])
})
+/**
+ * @param fn
+ * @param url
+ * @param method
+ * @param error
+ * @param args
+ */
function checkErrorResponse (fn, url, method, error, args = []) {
const client = sdkClient
return new Promise((resolve, reject) => {