4.0.1 • Published 3 months ago

@adobe/aio-lib-target v4.0.1

Weekly downloads
216
License
-
Repository
github
Last release
3 months ago

Version Downloads/week Node.js CI License Codecov Coverage

I/O Adobe Target SDK

Node Javascript Core SDK wrapping Adobe Target APIs.

Installing

$ npm install

Target API Technical Requirements

The Adobe Target 1.0 APIs need to set an Accepts header for them to work properly. With version 2.x or greater of this SDK, we set the proper Accepts header for the calls as documented. Previous versions of this SDK may or may not work since for some Target API calls the Accepts header is not enforced consistently.

User-based OAuth Tokens and Role Requirements

For scenarios in which user-based OAuth tokens are used instead of a JWT technical account ones, the user may require specific roles/permissions to be assigned in Adobe Target in order to successfully perform API calls. Otherwise, the Adobe Target API calls performed by the API Client will result in 500 errors.

For more detailed information, please read the Adobe Target Enterprise user permissions documentation.

Usage

1) Initialize the SDK

var sdk = require('@adobe/aio-lib-target')

async function sdkTest() {
  //initialize sdk
  const targetClient = await sdk.init('<tenant>', 'x-api-key', '<valid auth token>')
}

Init method returns an Instance of Class TargetCoreAPI

2) Call methods using initialized sdk

var sdk = require('@adobe/aio-lib-target')

async function sdkTest() {
    //initialize sdk
    const targetClient = await sdk.init('<tenant>', 'x-api-key', '<valid auth token>')

    //get activities
    const activities = await targetClient.getActivities({limit:5, offset:0})
    console.log(util.inspect(activities));

    //get offers
    const offers = await targetClient.getOffers({limit:5, offset:0})
    console.log(util.inspect(offers));

     //get offer by id activity
     const offer = await targetClient.getOfferById(123)
     console.log(util.inspect(offer));
}

All Methods available under sdk are documented here

Classes

Functions

TargetCoreAPI

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

Kind: global class

targetCoreAPI.init(tenant, apiKey, token) ⇒ TargetCoreAPI

Initialize sdk.

Kind: instance method of TargetCoreAPI
Returns: TargetCoreAPI - a TargetCoreAPI instance

ParamTypeDescription
tenantstringAdobe Target tenant name
apiKeystringYour api key
tokenstringValid auth token

targetCoreAPI.getActivities(options) ⇒ Promise.<Response>

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
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDefaultDescription
optionsobjectto control activity search
options.limitnumber2147483647Defines the number of items to return
options.offsetnumber0Defines 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.sortBystringDefines the sorting criteria on the returned items
options.headersobjectheaders to pass to API call

targetCoreAPI.createABActivity(body, options) ⇒ Promise.<Response>

Create AB Activity. Creates a new AB activity with the specified contents and returns the created activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectActivity JSON.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.createXTActivity(body, options) ⇒ Promise.<Response>

Create XT Activity. Creates a new XT activity with the specified contents and returns the created activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectActivity JSON.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getABActivityById(id, options) ⇒ Promise.<Response>

Get AB activity. Fetch the current definition of an AB activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getXTActivityById(id, options) ⇒ Promise.<Response>

Get XT activity. Fetch the current definition of XT activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.updateABActivity(id, body, options) ⇒ Promise.<Response>

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.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
bodyobjectactivity JSON
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.updateXTActivity(id, body, options) ⇒ Promise.<Response>

Update XT activity. Update the current definition of XT activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
bodyobjectactivity JSON
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.setActivityName(id, name, options) ⇒ Promise.<Response>

Update activity name. Updates the name of the AB activity that is referenced by the supplied id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
namestringNew Activity name.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.setActivityState(id, state, options) ⇒ Promise.<Response>

Update Activity state. Update state of an activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
statestringNew Activity state.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.setActivityPriority(id, priority, options) ⇒ Promise.<Response>

Update Activity priority. Update priority of an activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
prioritystringNew Activity priority.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.setActivitySchedule(id, schedule, options) ⇒ Promise.<Response>

Update Activity schedule. Update schedule of an activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
schedulestringNew Activity schedule.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.deleteABActivity(id, options) ⇒ Promise.<Response>

Delete AB activity. Deletes the AB activity that is referenced by the id, if it is found.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.deleteXTActivity(id, options) ⇒ Promise.<Response>

Delete XT activity. Delete the current definition of an XT activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getActivityChangeLog(id, options) ⇒ Promise.<Response>

Get Activity changelog. Returns the changelog for a given activity id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getOffers(options) ⇒ Promise.<Response>

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
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDefaultDescription
optionsobjectto control offer search.
options.limitnumber2147483647Defines the number of items to return
options.offsetnumber0Defines 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.sortBystringDefines the sorting criteria on the returned items.
options.headersobjectheaders to pass to API call

targetCoreAPI.getOfferById(id, options) ⇒ Promise.<Response>

Get Offer. Retrieves the contents of an offer given an offer id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberOffer id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.createOffer(body, options) ⇒ Promise.<Response>

Create Offer. Creates a new content offer as defined by the request data.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectOffer JSON.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.updateOffer(id, body, options) ⇒ Promise.<Response>

Update Offer. Updates the content offer referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberOffer id.
bodyobjectOffer JSON
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.deleteOffer(id, options) ⇒ Promise.<Response>

Delete Offer. Deletes the content offer referenced by the provided id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberOffer id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getAudiences(options) ⇒ Promise.<Response>

List Audiences. List all available audiences with options to filter and sort by each available field.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDefaultDescription
optionsobjectoptions to control audience search.
options.limitnumber2147483647Defines the number of items to return. Default value is 2147483647
options.offsetnumber0Defines 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.sortBystringDefines the sorting criteria on the returned items.
options.headersobjectheaders to pass to API call

targetCoreAPI.createAudience(body, options) ⇒ Promise.<Response>

Create Audience. Create a new audience as specified by the contents of the request and return the newly-created audience definition.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectAudience JSON.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getAudienceById(id, options) ⇒ Promise.<Response>

Get Audience. Get the audience definition specified by the provided id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberAudience id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.updateAudience(id, body, options) ⇒ Promise.<Response>

Update Audience. Update an audience with the new rules specified by the request data.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberAudience id.
bodyobjectaudience JSON
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.deleteAudience(id, options) ⇒ Promise.<Response>

Delete Audience. Delete the audience referenced by the specified id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberAudience id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getProperties(options) ⇒ Promise.<Response>

List Properties. Get a list of properties.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getPropertyById(id, options) ⇒ Promise.<Response>

Get Property. Retrieve property by property Id..

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberProperty id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getMBoxes(options) ⇒ Promise.<Response>

List MBoxes. List all available mboxes for a specific client with the options to filter and sort.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getMBoxByName(name, options) ⇒ Promise.<Response>

Get MBox by name. Get the list of mbox parameters.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
namestringMBox name.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getMBoxProfileAttributes(options) ⇒ Promise.<Response>

Get Profile Attributes. Retrieve the list of available profile attributes and mbox parameters of type profile.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getEnvironments(options) ⇒ Promise.<Response>

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
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getABActivityPerformance(id, options) ⇒ Promise.<Response>

Get AB activity performance. Retrieve property by property Id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getXTActivityPerformance(id, options) ⇒ Promise.<Response>

Get activity performance. Retrieve property by property Id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getActivityPerformance(id, options) ⇒ Promise.<Response>

Get activity performance. Retrieve the performance report data for the Automated Personalization activity referenced by the provided id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.getOrdersReport(id, options) ⇒ Promise.<Response>

Get Orders report. Retrieve the orders/audit report data for an AB, XT or Autotmated Personalization Activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
optionsobjectsdk options
options.headersobjectheaders to pass to API call

targetCoreAPI.executeBatch(body) ⇒ Promise.<Response>

Execute Batch APIs. Multiple Admin APIs can be executed as a single batch request.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectjson to execute batch

init(tenant, apiKey, token) ⇒ Promise.<TargetCoreAPI>

Returns a Promise that resolves with a new TargetCoreAPI object.

Kind: global function
Returns: Promise.<TargetCoreAPI> - Promise resolving to a TargetCoreAPI instance

ParamTypeDescription
tenantstringtenant Adobe Target tenant name
apiKeystringapiKey Your api key
tokenstringValid auth token

Debug Logs

LOG_LEVEL=debug <your_call_here>

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

4.0.1

3 months ago

4.0.0

4 months ago

3.0.3

8 months ago

3.0.2

8 months ago

3.0.1

10 months ago

3.0.0

2 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago