Git Product home page Git Product logo

aio-lib-target's Introduction

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.

aio-lib-target's People

Contributors

amulyakashyap09 avatar dependabot[bot] avatar greenkeeper[bot] avatar himavanth avatar meryllblanchet avatar michaelgoberling avatar moritzraho avatar purplecabbage avatar sandeep-paliwal avatar shazron avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aio-lib-target's Issues

Failing to Update A/B Activities

Expected Behaviour

Target SDK or Target API allow you to update Target A/B activities, including ones that have auto-allocate.

Actual Behaviour

Unable to update Target A/B activities with SDK or API.

Reproduce Scenario (including but not limited to)

Using this SDK

// Get and update single activity
const response = await targetClient.getABActivityById(395705);
const body = response.body;
await targetClient.updateABActivity(395705, body);

throws this error

error
[TargetSDK:ERROR_UPDATE_AB_ACTIVITY] Error: Conflict
    at _callee$ (C:\Git\TargetAPI\node_modules\swagger-client\dist\index.js:623:816)
    at tryCatch (C:\Git\TargetAPI\node_modules\regenerator-runtime\runtime.js:63:40)
    at Generator.invoke [as _invoke] (C:\Git\TargetAPI\node_modules\regenerator-runtime\runtime.js:293:22)
    at Generator.next (C:\Git\TargetAPI\node_modules\regenerator-runtime\runtime.js:118:21)
    at asyncGeneratorStep (C:\Git\TargetAPI\node_modules\@babel\runtime-corejs2\helpers\asyncToGenerator.js:5:24)
    at _next (C:\Git\TargetAPI\node_modules\@babel\runtime-corejs2\helpers\asyncToGenerator.js:27:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  status: 409,
  statusCode: 409,
  response: [Object]
}

Using HTTP API

In Postman, with this request https://mc.adobe.io/{{tenant}}/target/activities/ab/395705 that was given to me by your Postman collection from the documentation (no modifications made besides filling in variables), with body being the exact response from the corresponding Get request for ab activity, gives this error

error
{
    "httpStatus": 409,
    "requestId": "YqYAZftfoxjPU3F1ZKJHsGyPuzK2NAJo",
    "requestTime": "2021-04-16T19:47:29.076182Z",
    "errors": [
        {
            "errorCode": "VersionConflict.Resource",
            "message": "Cannot create/update auto-allocate activity with this version of API"
        }
    ]
}

Steps to Reproduce

Platform and Version

SDK
"@adobe/aio-lib-target": "^2.1.1"

API
application/vnd.adobe.target.v3+json

Node.js
v14.15.4

Sample Code that illustrates the problem

Here's the whole Node.js file reproducing it:

code
const sdk = require('@adobe/aio-lib-target');

(async () => {
    const client = await sdk.init('tenant', 'key', 'token');

    try {
      // Get single and update activity
      const response = await client.getABActivityById(395705);
      const body = response.body;
      await client.updateABActivity(395705, body);
    } catch(e) {
      console.log(e.message);
    }
})();

Logs taken while reproducing problem

An in-range update of eslint-plugin-jest is breaking the build 🚨

The devDependency eslint-plugin-jest was updated from 23.1.0 to 23.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-jest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v23.1.1

23.1.1 (2019-11-30)

Bug Fixes

  • no-focused-tests: detect table format uage of .only.each (#489) (d03bcf4)
Commits

The new version differs by 2 commits.

  • 6ffb998 chore(release): 23.1.1 [skip ci]
  • d03bcf4 fix(no-focused-tests): detect table format uage of .only.each (#489)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add badges

Build badges etc, as required via the internal wiki checklist

v3 Target API calls not working

Expected Behaviour

Target API Calls that use the v3 Accept-header ('Accept: application/vnd.adobe.target.v3+json') should be successful.

Actual Behaviour

When I try to call getABActivityById from my code, I get this error:

[TargetSDK:ERROR_GET_AB_ACTIVITY_BY_ID] Error: Conflict
    at _callee$ (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/swagger-client/dist/index.js:581:816)
    at tryCatch (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)
    at _next (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9)
    at processTicksAndRejections (internal/process/task_queues.js:94:5) {
  status: 409,
  statusCode: 409,
  response: [Object]
}

Reproduce Scenario (including but not limited to)

I have code that leverages the adobe-io-target lib, and that makes calls to getActivities, getABActivityById, getXTActivityById as well as update activity API calls.

Steps to Reproduce

I have tried to fix the issue by changing the code to make another request intercept and add the necessary Accept headers. After this, it works. I am attaching the modified code here
index.js.zip
to give you an idea. Please have a look at getActivities, getABActivityById and getXTActivityById.

If the solution seems acceptable to you, I can create a PR to cover all API calls, otherwise please have a look and let me know your opinion.

Platform and Version

Current version

Sample Code that illustrates the problem

const exportActivity = (activity) => {
  return targetApi.initApi().then((sdk) => {
    if (activity.type === 'abt') {
      console.warn(chalk.red("Skipping activity"), activity)
      return Promise.resolve(() => { })
    }
    if (activity.type === 'ab') {
      return sdk.getABActivityById(activity.id);
    }
    if (activity.type === 'xt') {
      return sdk.getXTActivityById(activity.id);
    }
  })
}

Logs taken while reproducing problem

Target SDK get calls failing with swagger client update

Expected Behaviour

Actual Behaviour

Error for GET calls - ' Request with GET/HEAD method cannot have body'
This is because of swagger client update to 3.10.2

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version

Sample Code that illustrates the problem

Logs taken while reproducing problem

Add FAQ to Doc Section

We've been seeing some issues raised here that's actually attributed to a permission issue in Admin Console. We should add this to our docs, likely in an FAQ session, as part of the doc to enable users to self-help.

Target API calls retuning HTTP 500 in Firefly Apps

Expected Behaviour

API calls from the AIO Target SDK shall work as expected when used in Firefly Apps.

Actual Behaviour

API calls like getOffers, getActivities are consistently sending Internal Server Error (HTTP 500) when invoked from Firefly Apps.

Reproduce Scenario (including but not limited to)

  • Use default code generated by Firefly App for Adobe Target actions.
  • Tried initializing the SDK directly from @adobe/aio-lib-target instead of @adobe/aio-sdk; didn't help.
  • I haven't verified this issue outside of a Firefly App yet but all direct Target REST APIs are working for my environment (double cheked via postman) as I have been using them earlier too.

Steps to Reproduce

  1. Create a new app in AIO Runtime using Firefly.
  2. Add Adobe Target API to the workspace in AIO with standard steps.
  3. Select "Adobe Target" when asked, "Which type of sample actions do you want to create?"
    ❯ ◉ Adobe Target
    ◉ Generic
  4. Make changes for required values like Target Tenant, etc. in the .env file.
  5. Invoke the Target API action which calls getActivities() by default and notice the response.
  6. Try a few more methods like getOffers, etc. and the response will be the same (500 Internal Server Error)

Platform and Version

AIO JS SDK for Target in Firefly Apps.

Sample Code that illustrates the problem

// Here's the default invocation code generated from Firefly:

const { Target } = require('@adobe/aio-sdk')
const targetClient = await Target.init(params.tenant, params.apiKey, token) 
const offers = await targetClient.getOffers({limit:5, offset:0})
const activities = await targetClient.getActivities({ limit: 5, offset: 0 })

Logs taken while reproducing problem

error: [TargetSDK:ERROR_GET_ACTIVITIES] Error: Internal Server Error
error: [TargetSDK:ERROR_GET_OFFERS] Error: Internal Server Error

Node.js TargetSDK:ERROR_GET_OFFER_BY_ID

While we are working on Adobe IO to get/update the offer in Adobe Target through Adobe IO Target library

Expected Behaviour

When calling getOfferById() function, the following error occurred:

Actual Behaviour

we are getting the below errors.
[TargetSDK: ERROR_GET_OFFER_BY_ID] Error: Not Acceptable
Target SDK error

Reproduce Scenario (including but not limited to)

Can be easily reproduced in the following steps

Steps to Reproduce

Download the zip file and keep the js file in a folder. (see attached targetInit.zip)
targetInit.zip
You will need to replace the access token to a valid access token in the targetInit.js file, the problem can be reproduced with any Target company with json offers in the Offer library.

Open a command prompt in the folder the targetInit.js file exists. Run the below command.
npm install @adobe/aio-lib-target
Post that run the below command.
node targetInit.js
Replicate the issue with the above steps.

We are trying to give solution using Adobe IO serverless architecture to update the Target Activity/Offers through Adobe IO Target library.

Platform and Version

Node.js latest version

Sample Code that illustrates the problem

see targetInit.js
const offer = await targetClient.getOfferById(offerID)

Logs taken while reproducing problem

It seems the root cause is the get Offer Content call. which fails with a 406.

curl --location --request GET 'https://mc.adobe.io/tatadigital/target/offers/content/458563'
--header 'Authorization: Bearer '
--header 'x-api-key: '

Returns
{
"httpStatus": 406,
"requestId": "KsYtjLDzfFsvvcG9DiYAmPMibqnHEC3I",
"requestTime": "2021-06-11T00:12:22.634272Z",
"errors": [
{
"errorCode": "Unsupported.Feature",
"message": "Unsupported offer type. The only supported type is: content",
"meta": {}
}
]
}

All the offers returned when listing the offers are of Type = json

Changing the URL above to https://mc.adobe.io/tatadigital/target/offers/json/458563'

returns
{
"id": 458563,
"name": "/birthday_offers/experiences/0/pages/0/zones/0/1623150537848",
"content":

{ "ShowOffers": "true", "count": "5" }
,
"modifiedAt": "2021-06-08T12:26:30Z"
}

The JAVAScript code needs to examine the type of the offer and make the appropriate backend API call.

The Swagger spec seems to have support for content but not for a variable to take the type.

There seems to be a discrepancy in the SDK function targetClient.getOfferById(offersArray[i].id) call in that, it also needs type to construct the correct URL to fetch the offer.

Workaround is to maybe call the adobe.io rest API directly, since that works fine as mentioned above.

Permalink
shete
Aditi Shete added a comment - 6 days ago - edited
Withe the token and api key provided for tatadigital, with Accepts set to application/vnd.adobe.target.v2+json

I was able to run the adobe.io call successfully to get offers.

curl -X GET
'https://mc.adobe.io/tatadigital/target/offers?limit=10'
-H 'authorization: Bearer '
-H 'cache-control: no-cache'
*-H 'Accept: application/vnd.adobe.target.v2+json' *
-H 'x-api-key: '

Please investigate the the node.js side code which uses the Swagger client to make the above call (which seems to be succeeding with the apikey and token provided.)

An in-range update of fetch-mock is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency fetch-mock was updated from 9.3.1 to 9.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fetch-mock is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 10 commits.

  • 3cdc7ba fixed broken tests
  • b1f33ec fix linting
  • 87a2758 Merge pull request #532 from chet-manley/feat-return-node-fetch-interface
  • d7a6577 feat: mock node-fetch's export pattern
  • 3500688 Merge pull request #526 from pabloosso/patch-1
  • 8c231ac Fixed typo
  • e25f30a Merge pull request #525 from willheslam/patch-1
  • 5817bbf Fix typo in mock_response.md
  • 41b238f Update cheatsheet.md
  • aa8311e Update cheatsheet.md

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Node 14 no longer supported

Expected Behaviour

Using Node 14

Given the following code:

const aiolibtarget = require('@adobe/aio-lib-target')

console.log('Hi')

The following result should be produced:

Hi

Actual Behaviour

Using Node 14

Given the following code:

const aiolibtarget = require('@adobe/aio-lib-target')

console.log('Hi')

The following result is produced:

/Users/mgoberling/repos/adobe/my-utils/utils/api-mesh-test/node_modules/@swagger-api/apidom-error/cjs/ApiDOMAggregateError.cjs:7
class ApiDOMAggregateError extends AggregateError {
                                   ^

ReferenceError: AggregateError is not defined
    at Object.<anonymous> (/Users/mgoberling/repos/adobe/my-utils/utils/api-mesh-test/node_modules/@swagger-api/apidom-error/cjs/ApiDOMAggregateError.cjs:7:36)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.<anonymous> (/Users/mgoberling/repos/adobe/my-utils/utils/api-mesh-test/node_modules/@swagger-api/apidom-error/cjs/ApiDOMError.cjs:8:52)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  • Use Node 14
  • Install @adobe/aio-lib-target in project
  • Create index.js like above
  • Try to run

Platform and Version

Node 14.21.3

Notes

AggregateError was introduced in Node 15

getActivities returns 0 results

Using the sample code:
const activities = await targetClient.getActivities({limit:5, offset:0})
I always get 0 results:
{ total: 0, offset: 0, limit: 5 }

An in-range update of fetch-mock is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency fetch-mock was updated from 9.1.0 to 9.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fetch-mock is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 2 commits.

  • cdfb3a9 Merge pull request #512 from wheresrhys/body-inspecting
  • 0806bfc inspect based on body

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.