[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

adobe/aio-lib-target

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

  1. 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

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

Functions

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

Returns a Promise that resolves with a new TargetCoreAPI object.

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

Param Type Description
tenant string Adobe Target tenant name
apiKey string Your api key
token string Valid 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

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, [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

Param Type Description
body object Activity JSON.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
body object Activity JSON.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
body object activity JSON
[options] object sdk options
[options.headers] object headers 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

Param Type Description
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, [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

Param Type Description
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, [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

Param Type Description
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, [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

Param Type Description
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, [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

Param Type Description
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, [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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

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, [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

Param Type Description
id number Offer id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
body object Offer JSON.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Offer id.
body object Offer JSON
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Offer id.
[options] object sdk options
[options.headers] object headers 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

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, [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

Param Type Description
body object Audience JSON.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Audience id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Audience id.
body object audience JSON
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Audience id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Property id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
[options] object sdk options
[options.headers] object headers 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

Param Type Description
name string MBox name.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
[options] object sdk options
[options.headers] object headers 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

Param Type Description
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
id number Activity id.
[options] object sdk options
[options.headers] object headers 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

Param Type Description
body object json 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

Param Type Description
tenant string tenant Adobe Target tenant name
apiKey string apiKey Your api key
token string Valid 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.