Giter Club home page Giter Club logo

aio-lib-campaign-standard's Introduction

Version Downloads/week Node.js CI License Codecov Coverage

Adobe I/O Adobe Campaign Standard SDK

Node Javascript SDK wrapping the Adobe Campaign Standard APIs.

Installing

$ npm install

Usage

  1. Initialize the SDK
const sdk = require('@adobe/aio-lib-campaign-standard')

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

Init method returns an instance of the Class CampaignStandardCoreAPI

  1. Call methods using the initialized SDK
const sdk = require('@adobe/aio-lib-campaign-standard')

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

  // call methods
  try {
    // get profiles by custom filters
    result = await campaignStandardClient.getAllProfiles({
      filters: [
        'byCRMId'
      ],
      hasCustomFilter: true
    })
    console.log(result)

    // get a workflow
    result = await campaignStandardClient.getWorkflow('myWkfId')
    console.log(result)

  } catch (e) {
    console.error(e)
  }
}

All methods available under the SDK are documented here

Classes

CampaignStandardCoreAPI

This class provides methods to call Adobe Campaign Standard APIs. Before calling any method initialize the instance by calling the init method on it with valid values for tenantId, apiKey and accessToken

Functions

init(tenantId, apiKey, accessToken)Promise.<CampaignStandardCoreAPI>

Returns a Promise that resolves with a new CampaignStandardCoreAPI object.

CampaignStandardCoreAPI

This class provides methods to call Adobe Campaign Standard APIs. Before calling any method initialize the instance by calling the init method on it with valid values for tenantId, apiKey and accessToken

Kind: global class

campaignStandardCoreAPI.tenantId

the tenant id (your personal organization in Campaign Standard)

Kind: instance property of CampaignStandardCoreAPI

campaignStandardCoreAPI.apiKey

the api key from your Adobe I/O Campaign Standard integration

Kind: instance property of CampaignStandardCoreAPI

campaignStandardCoreAPI.accessToken

the access token from your Adobe I/O Campaign Standard integration

Kind: instance property of CampaignStandardCoreAPI

campaignStandardCoreAPI.init(tenantId, apiKey, accessToken) ⇒ CampaignStandardCoreAPI

Initializes this object.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
tenantId string the tenant id (your personal organization in Campaign Standard)
apiKey string the API key for your Adobe I/O Campaign Standard Integration
accessToken string the access token for your Adobe I/O Campaign Standard Integration

campaignStandardCoreAPI.getAllProfiles([parameters])

Get all Profile records

Kind: instance method of CampaignStandardCoreAPI
See: getMetadataForResource

Param Type Default Description
[parameters] Object {} parameters to pass
[parameters.filters] Array [] apply the filters to the results. List of filters for a resource can be retrieved via a getMetadataForResource call
[parameters.hasCustomFilter] Boolean false set to true if you have a custom filter. Defaults to false.
[parameters.lineCount] integer 25 limit the number of records to return (default is 25)
[parameters.order] string the field to order your records by (see the fields of a Profile)
[parameters.descendingSort] boolean false set to true to get results in descending order (default is ascending)

campaignStandardCoreAPI.createProfile(profileObject)

Create a Profile record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
profileObject Object see profile properties

campaignStandardCoreAPI.updateProfile(profilePKey, profileObject)

Update a Profile record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
profilePKey string the PKey property of a Profile record
profileObject Object see profile properties. Only set the properties you want to update.

campaignStandardCoreAPI.getProfile(profilePKey)

Get a Profile record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
profilePKey string the PKey property of a Profile record

campaignStandardCoreAPI.getAllServices([parameters])

Get all Service records

Kind: instance method of CampaignStandardCoreAPI
See: getMetadataForResource

Param Type Default Description
[parameters] Object {} parameters to pass
[parameters.filters] Array [] apply the filters to the results. List of filters for a resource can be retrieved via a getMetadataForResource call
[parameters.hasCustomFilter] Boolean false set to true if you have a custom filter. Defaults to false.
[parameters.lineCount] integer 25 limit the number of records to return (default is 25)
[parameters.order] string the field to order your records by (see the fields of a Service)
[parameters.descendingSort] descendingSort false set to true to get results in descending order (default is ascending)

campaignStandardCoreAPI.createService(serviceObject)

Create a Service record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
serviceObject Object see service properties

campaignStandardCoreAPI.getService(servicePKey)

Get a Service record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
servicePKey string the PKey property of a Service record

campaignStandardCoreAPI.getHistoryOfProfile(profilePKey)

Get the marketing history of a Profile

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
profilePKey string the PKey property of a Profile record

campaignStandardCoreAPI.getMetadataForResource(resource)

Get the metadata information for a resource.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
resource string one of profile, service, history

campaignStandardCoreAPI.getMetadataForResourceExt(resource)

Retrieve custom resource linked to the Profile table

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
resource string any custom resource

campaignStandardCoreAPI.getCustomResources()

Get all the custom resource collections linked to the Profile table.

Kind: instance method of CampaignStandardCoreAPI

campaignStandardCoreAPI.createGDPRRequest(gdprRequest)

Create a new GDPR request.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
gdprRequest Object see the properties that are needed.

campaignStandardCoreAPI.getGDPRRequest()

Get data about the current GDPR request.

Kind: instance method of CampaignStandardCoreAPI

campaignStandardCoreAPI.getGDPRDataFile(privacyRequestDataUrl, requestInternalName)

Get the GDPR data file.

Kind: instance method of CampaignStandardCoreAPI
See: getGDPRRequest

Param Type Description
privacyRequestDataUrl string this is acquired from a getGDPRRequest call
requestInternalName string the request internal name

campaignStandardCoreAPI.sendTransactionalEvent(eventId, eventBody)

Deprecated

Send a transactional event. Deprecated since 2.1.0. use sendTransactionalEventForMacTenantId instead.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
eventId string the type of event you want to send. This depends on the event definition.
eventBody Object the event data to send. This depends on the event definition.

campaignStandardCoreAPI.sendTransactionalEventForMacTenantId(macTenantId, eventId, eventBody)

Send a transactional event for a Marketing Cloud Tenant ID

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
macTenantId string the Marketing Cloud Tenant ID
eventId string the type of event you want to send. This depends on the event definition.
eventBody Object the event data to send. This depends on the event definition.

campaignStandardCoreAPI.getTransactionalEvent(eventId, eventPKey)

Deprecated

Gets data about a transactional event (status, properties) Deprecated since 2.1.0. use getTransactionalEventForMacTenantId instead.

Kind: instance method of CampaignStandardCoreAPI
See: sendTransactionalEvent

Param Type Description
eventId string the type of event you want to send
eventPKey string the PKey of an event (you get this from a sendTransactionalEvent call)

campaignStandardCoreAPI.getTransactionalEventForMacTenantId(macTenantId, eventId, eventPKey)

Gets data about a transactional event for a Marketing Cloud Tenant ID (status, properties)

Kind: instance method of CampaignStandardCoreAPI
See: sendTransactionalEvent

Param Type Description
macTenantId string the Marketing Cloud Tenant ID
eventId string the type of event you want to send
eventPKey string the PKey of an event (you get this from a sendTransactionalEvent call)

campaignStandardCoreAPI.getWorkflow(workflowId)

Gets the properties of a workflow.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
workflowId string the id of the workflow

campaignStandardCoreAPI.triggerSignalActivity(workflowTriggerUrl, [workflowParameters])

Trigger a workflow.

Kind: instance method of CampaignStandardCoreAPI
See: getWorkflow

Param Type Description
workflowTriggerUrl string the trigger url for a workflow. You can get this from a call to getWorkflow
[workflowParameters] Object workflow parameters object. see the payload in the docs
workflowParameters.source string the triggering request source
workflowParameters.parameters Object the parameters to send to the workflow (paramater name, and parameter value pairs)

campaignStandardCoreAPI.controlWorkflow(workflowId, command)

Controls execution of a workflow.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
workflowId string the id of the workflow
command string the command to execute for the workflow. one of start, pause, resume, stop

campaignStandardCoreAPI.getAllOrgUnits([parameters])

Get all available orgUnits

Kind: instance method of CampaignStandardCoreAPI
See: getMetadataForResource

Param Type Default Description
[parameters] Object {} parameters to pass
[parameters.filters] Array [] apply the filters to the results. List of filters for a resource can be retrieved via a getMetadataForResource call
[parameters.lineCount] integer 25 limit the number of records to return (default is 25)
[parameters.order] string the field to order your records by (see the fields of a OrgUnitBase)
[parameters.descendingSort] descendingSort false set to true to get results in descending order (default is ascending)

campaignStandardCoreAPI.getProfileWithOrgUnit(profilePKey)

Gets a Profile record (with it's orgUnit property)

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
profilePKey string the PKey property of a Profile record

campaignStandardCoreAPI.updateProfileOrgUnit(profilePKey, orgUnitPKey)

Update the orgUnit of a Profile

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
profilePKey string the PKey property of a Profile record
orgUnitPKey string the PKey property of a OrgUnitBase record

campaignStandardCoreAPI.updateOrgUnit(orgUnitPKey, orgUnitObject)

Update the properties of an OrgUnitBase.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
orgUnitPKey string the PKey property of a OrgUnitBase record
orgUnitObject Object see orgUnitBase properties. Only set the properties you want to update.

campaignStandardCoreAPI.postDataToUrl(url, body)

Post to an absolute url.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
url string the url to POST to
body Object the POST body

campaignStandardCoreAPI.getDataFromRelativeUrl(relativeUrl)

Gets data from a relative url. Helper function.

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
relativeUrl string the relative url (returned from some ACS API calls)

campaignStandardCoreAPI.getAllCustomResources(customResource, [parameters])

Deprecated

Get all Custom Resource records Either use getAllBasicCustomResources() to get custom resources or getAllProfileAndServicesExt() to get extended resource data

Kind: instance method of CampaignStandardCoreAPI
See: getMetadataForResource

Param Type Default Description
customResource string the custom resource to get records from
[parameters] Object {} parameters to pass
[parameters.filters] Array [] apply the filters to the results. List of filters for a resource can be retrieved via a getMetadataForResource call
[parameters.hasCustomFilter] Boolean false set to true if you have a custom filter. Defaults to false.
[parameters.lineCount] integer 25 limit the number of records to return (default is 25)
[parameters.order] string the field to order your records by (see the fields of a Profile)
[parameters.descendingSort] boolean false set to true to get results in descending order (default is ascending)

campaignStandardCoreAPI.getAllBasicCustomResources(resource)

Get all Custom Resource records

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
resource string one of profile, service, history

campaignStandardCoreAPI.getAllProfileAndServicesExt(customResource, [parameters])

Get all Custom Resource records

Kind: instance method of CampaignStandardCoreAPI
See: getMetadataForResource

Param Type Default Description
customResource string the custom resource to get records from
[parameters] Object {} parameters to pass
[parameters.filters] Array [] apply the filters to the results. List of filters for a resource can be retrieved via a getMetadataForResource call
[parameters.hasCustomFilter] Boolean false set to true if you have a custom filter. Defaults to false.
[parameters.lineCount] integer 25 limit the number of records to return (default is 25)
[parameters.order] string the field to order your records by (see the fields of a Profile)
[parameters.descendingSort] boolean false set to true to get results in descending order (default is ascending)

campaignStandardCoreAPI.updateCustomResource(customResource, customResourcePKey, customResourceObject)

Update a Custom Resource record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
customResource string the custom resource
customResourcePKey string the PKey property of a Custom Resource record
customResourceObject Object A Custom Resource object. Only set the properties you want to update.

campaignStandardCoreAPI.createCustomResource(customResource, customResourceObject)

Create a Custom Resource record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
customResource string the custom resource
customResourceObject Object a Custom Resource object

campaignStandardCoreAPI.deleteCustomResource(customResource, customResourcePKey, customResourceObject)

Delete a Custom Resource record

Kind: instance method of CampaignStandardCoreAPI

Param Type Description
customResource string the custom resource
customResourcePKey string the PKey property of a Custom Resource record
customResourceObject Object a Custom Resource object

init(tenantId, apiKey, accessToken) ⇒ Promise.<CampaignStandardCoreAPI>

Returns a Promise that resolves with a new CampaignStandardCoreAPI object.

Kind: global function

Param Type Description
tenantId string the tenant id (your personal organization in Campaign Standard)
apiKey string the API key for your Adobe I/O Campaign Standard Integration
accessToken string the access token for your Adobe I/O Campaign Standard Integration

Debug Logs

LOG_LEVEL=debug <your_call_here>

Prepend the LOG_LEVEL environment variable and debug value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

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-campaign-standard's People

Contributors

amulyakashyap09 avatar dependabot[bot] avatar duynguyen avatar greenkeeper[bot] avatar meryllblanchet avatar michaelgoberling avatar moritzraho avatar purplecabbage avatar sandeep-paliwal avatar sarahxxu avatar shazron avatar

Stargazers

 avatar  avatar  avatar  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  avatar  avatar

aio-lib-campaign-standard's Issues

getMetadataForResourceExt returns data instead of metadata

The function campaignStandardCoreAPI.getMetadataForResourceExt("profile") is returning profile-data rather than profile-metadata. from reading the docs I'd assume that this would return the metadata including custom objects (fields, filters, etc).

Is this correct behavior?

I'm on 2.1.3 (latest)

Fix getGDPRDataFile method

The privateRequestDataUrl is an absolute URL, not a relative one like the previous (incorrect) docs showed. The REST API docs has since been corrected to show that this url is an absolute one.

ACNA-696 - campaignStandardCoreAPI.sendTransactionalEvent does not identify event to trigger

While using the Campaign Standard libraries, using sendTransactionalEvent(eventId, eventBody) does not identify the transactional event.

Expected Behaviour

sendTransactionalEvent(eventId, eventBody) library method should trigger the transactional event in Adobe Campaign Standard, resulting in message sent to target.

Actual Behaviour

sendTransactionalEvent(eventId, eventBody) library method fails to recognise the transactional event defined in Adobe Campaign Standard.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Define transactional event and related message (Email) for the event and publish.
Click on the "API preview" to fetch eventId.
For example, the transactional event published in one of the instance https://mc.adobe.io/<ORGANIZATION>/campaign/mcadobedemoinstance/EVT_Order_Approval

Nodesjs:

const acs = require('@adobe/aio-lib-campaign-standard');
const TENANT = "...";
const CLIENT_ID = "...";
const TOKEN = "...";
let payload = {"ctx":{"managerEmail": "[email protected]",...}};
let eventName = "EVT_Order_Approval"
let send_mc_message = async function (tenant, client_id, token, eventName, payload) {
    let acs_instance = await acs.init(tenant, client_id, token);
    return await acs_instance.sendTransactionalEvent(eventName, payload);
};

Error message:

{ CampaignStandardSDKError: [CampaignStandardSDK:ERROR_SEND_TRANSACTIONAL_EVENT] 404 - Not Found ("RST-360011 An error has occurred - please contact your administrator. Error rc=-2003")
    at new <anonymous> (/Users/diptimanbadajena/Documents/Assignments/2020-21/Accelerators/AIO-CNA/cna-app3/node_modules/@adobe/aio-lib-core-errors/src/AioCoreSDKErrorWrapper.js:33:9)
    at sdk.apis.messaging.sendTransactionalEvent.then.catch.err (/Users/diptimanbadajena/Documents/Assignments/2020-21/Accelerators/AIO-CNA/cna-app3/node_modules/@adobe/aio-lib-campaign-standard/src/index.js:428:18)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 'ERROR_SEND_TRANSACTIONAL_EVENT',
  sdk: 'CampaignStandardSDK',
  sdkDetails:
   { eventId: 'EVT_DMKT_Order_Approval',
     eventBody: { ctx: [Object] } },
  name: 'CampaignStandardSDKError' }

Platform and Version

aio -v
@adobe/aio-cli/2.3.0 darwin-x64 node-v10.16.0

Sample Code that illustrates the problem

Logs taken while reproducing problem

createProfile method fails with 404 - Not Found

Expected Behaviour

createProfile should return newly inserted profile or error is missing parameter.

Actual Behaviour

 stdout: 2019-12-13T15:14:32.341Z [MyApp /delaland/techlab-cna-paris-0.0.1/createprofile] info: Calling the create profile action...
2019-12-13T15:14:32.341Z       stdout: logging create profile
2019-12-13T15:14:32.715Z       stdout: 2019-12-13T15:14:32.715Z [MyApp /delaland/techlab-cna-paris-0.0.1/createprofile] error: [CampaignStandardSDK:ERROR_CREATE_PROFILE] 404 - Not Found ("RST-360011 An error has occurred - please contact your administrator. Error rc=-2003")

Steps to Reproduce

    // initialize the sdk
    const campaignClient = await CampaignStandard.init(params.tenant, params.apiKey, tokenResults.token)
   const createResult = await campaignClient.createProfile({email: '[email protected]','firstName': 'clement', 'lastName': 'del'})

Platform and Version

aio -v
@adobe/aio-cli/2.2.3 darwin-x64 node-v12.9.1

Sample Code that illustrates the problem

Code available in git

Logs taken while reproducing problem

Error from `triggerSignalActivity` when using triggerURL from `getWorkflow`

Expected Behaviour

For triggerSignalActivity, one has to first call getWorkflow, which returns a URL for triggering signal activity. That URL is then called, with required parameters, to trigger a workflow.
As the URL returned by getWorkflow is a full URL, e.g. https://mc.adobe.io/<ORGANIZATION>/campaign/workflow/execution/@19K_8ZhwSr_6KVriV4X8gw3YThAY-TAjJjV4vHmUiwTm_0kpgzQ-fa3x8KCLfb8FjjR53mJ22GYuLoaHLovKIuxoGXDvHXtuSSrLsbbT5PA9Dkezt6tzIA7hNTAR9oBun6cMHA/activities/activity/@19K_8ZhwSr_6KVriV4X8gw3YThAY-TAjJjV4vHmUiwTm_0kpgzQ-fa3x8KCLfb8FjjR53mJ22GYuLoaHLovKIgIFKtEyaPUqUf02xvnDBod6C2DYV0M8pVdXnSo-Xx2RMbKbAeJhFjtO0FUWO6WeouJQMcvkTwRhgdxyQ0nbh_jqAV11/trigger, it needs to be called in a "request" lib manner rather than a path of Swagger def.

Actual Behaviour

When calling acsClient.triggerSignalActivity(triggerUrl, wfParams), we will get Internal server error, because with triggerUrl being https://mc.adobe.io/..., the actual call will be to https://mc.adobe.io/adobeiosolutionsdemo/campaign/https://mc.adobe.io/adobeiosolutionsdemo/campaign/workflow/execution/....

Sample Code that illustrates the problem

const acsClient = await sdk.init(tenantId, authClientId, jwtToken)
const workflow = await acsClient.getWorkflow('myWkfId')
const wkfHref = workflow.body.activities.activity.signal1.trigger.href
await acsClient.triggerSignalActivity(processTriggerUrl(wkfHref), { source: 'API', parameters: { email: args.email } })

Logs taken while reproducing problem

Error while calling Adobe Campaign Standard triggerSignalActivity - Error: Internal Server Error

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


🚨 Reminder! Less than one month left to migrate your repositories over to Snyk before Greenkeeper says goodbye on June 3rd! 💜 🚚💨 💚

Find out how to migrate to Snyk at greenkeeper.io


The devDependency eslint-plugin-jest was updated from 23.9.0 to 23.10.0.

🚨 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.10.0

23.10.0 (2020-05-09)

Features

  • no-deprecated-functions: support jest version setting (#564) (05f20b8)
Commits

The new version differs by 3 commits.

  • 8b2568b chore(release): 23.10.0 [skip ci]
  • 05f20b8 feat(no-deprecated-functions): support jest version setting (#564)
  • 0d9dce0 chore: ensure that every rule has a .test.ts file in __tests__

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 🌴

feat: add getAllServices method

There are 4 resources:

  1. Profile
  2. Service
  3. History
  4. OrgUnitBase

For each resource you can get all the records for each resource, except for History (not specified in the docs, and it the docs always show a PKey is required). getAllServices method is missing.

Fix e2e test getAllProfiles (bad tenant id)

Expected Behaviour

e2e test getAllProfiles bad tenant id test should fail in an expected way.

Actual Behaviour

e2e test getAllProfiles bad tenant id test fails in unexpected ways, depending on a cold or warm start (for the Campaign Standard server). If cold, it fails with http 400, while when warm it fails with http 500.

Reproduce Scenario (including but not limited to)

Run the e2e tests with credentials.

Steps to Reproduce

npm run e2e with the appropriate .env credentials file.

The test is here

Proposed fix

Modify the test to test for http code >= 400, not just 500.

additional feature: getCustomResource

Can we add functionality to get a single custom resource?

add parameter to filter the custom resource.

Example:
result = await acsClient.getCustomResource("cusTriggerData");

Thanks in advance.

bug: need a way to specify filters and query parameters to methods that get all resource records

The methods are:

  • getAllProfiles
  • getAllOrgUnits
  • getAllServices

Query Parameters supported:

  • _lineCount (integer)
  • _order (string)

Filters

Filters depend on the resource (do a getMetadataForResource call). They are specified in the URL after the resource, and can be chained.

Thus, if your resource is at /profileAndServices/profile and you have a filter filter1, your url will be: /profileAndServices/profile/filter1

If your resource is at /profileAndServices/profile and you have filters filter1 and filter2, your url will be: /profileAndServices/profile/filter1/filter2 (chain them)

Record Column Selection

Instead of a filter, you can also "select" a field from the resource (think of a database table selection), by specifying the field after the resource. You can only select one field. For example, if you want the Profile records returned to only select the "email" field, your url will be:
/profileAndServices/profile/email

Example Call

const params = {
    lineCount: 10, // pagination: default 25
    order: 'email',  // sort: what field to sort on
    descendingSort: true // sort: default is ascending
}
const filters = [ 'byEmail', 'byText' ]
getAllProfiles(filters, params)

Use `axios` instead of `node-fetch`

This is because there is no way to intercept request/response. axios provides this. This is for debug logging. Works in the browser as well.

additional feature: updateCustomResource

Is it possible to add the feature to add data to custom resources?

Currently it is only possible to retrieve all customResources (getCustomResources)

API path
/profileAndServicesExt/{customResourceKey}

Where customResourceKey is input provided as a parameter, for example a value would be cusTriggerData.

This also expects a body to be provided. The body will consist of the fields of that custom resource.

getAllServices - Error: Not Found

After successfully initializing with the parameters (tenantID, apiKey, accessToken). Parameters have been tested with Postman. When calling getAllServices, I see the below error:
Error: Error while calling Adobe Campaign Standard getAllServices - Error: Not Found

Can we change this to a more descriptive error?

chore: add instructions on how to debug

Verbose output for debugging is using the DEBUG environment variable.

DEBUG=adobeio-cna-core-campaign-standard  <your_call_here>

Prepend that to the call that invokes your function, on the command line. This should output a lot of debug data.

createCustomResource - Internal Server Error

Expected Behaviour

The API call succeeds.

Actual Behaviour

The API call fails with an Internal Server Error.

Steps to Reproduce

Verify that the call via REST API succeeds in Postman (export to curl and verify again)
Use LOG_LEVEL=debug to see the SDK request and response

Fix

The SDK's request URL has an extra comma at the end. Adding this extra comma via Postman or curl verifies that it causes the same error.

The fix is to make sure the request url is well formed in the SDK (some path parameters might be missing default values)

cc @dhindle

The getAllCustomResources() function is generating a malformed URL request

See: https://jira.corp.adobe.com/browse/AIOE-109

Expected Behaviour

The request should be:
https://%tenantid%-adobeio.campaign.adobe.com/rest/customResource/cusMarketingHistory

Actual Behaviour

The request is:
https://%tenantid%-adobeio.campaign.adobe.com/rest/profileAndServicesExt/cusMarketingHistory

Reproduce Scenario (including but not limited to)

In ACS, create a customRessource without any link (no link to Profiles for instance)
Publish it.

Steps to Reproduce

Create an IO action and try to retrieve all the records of this custom resource, by using this kind of code:
const marketingHistoryRecords =await campaignClient.getAllCustomResources(customResourceName, {})

Platform and Version

@adobe/aio-cli/3.3.0 win32-x64 node-v10.16.0

Sample Code that illustrates the problem

Logs taken while reproducing problem

__secured_getmarketinghistory:ee99b25448a5453799b25448a5853754
2020-05-04T09:12:49.187Z stdout: 2020-05-04T09:12:49.186Z [main /bouessay/marketinghisto-app-0.0.1/__secured_getmarketinghistory] info: Calling the main action
2020-05-04T09:12:49.187Z stdout: 2020-05-04T09:12:49.187Z [main /bouessay/marketinghisto-app-0.0.1/__secured_getmarketinghistory] debug: {"statusCode":200,"body":{"message":"validation success"},"tenant":"intersportfrance-mkt-stage1","__ow_method":"post","apiKey":"0ca1f0006e494d9c8b713a92b82df1a0","LOG_LEVEL":"debug","__ow_headers":{"accept":"/","accept-encoding":"gzip, deflate, br","accept-language":"en-US, en;q=0.5","authorization":"","cache-control":"no-cache","connection":"close","content-type":"application/json","host":"controller-a","origin":"https://localhost:9080","perf-br-req-in":"1588583568.311","pragma":"no-cache","referer":"https://localhost:9080/?_mr=https%3A%2F%2Fexperience.adobe.com%2Fassets%2Fruntime.28bb2226.js&shell_domain=experience.adobe.com","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0","x-forwarded-for":"193.104.215.11, 10.250.204.235","x-forwarded-host":"bouessay.adobeioruntime.net","x-forwarded-port":"443","x-forwarded-proto":"https","x-org-id":"03AA65E45DD69DB50A495C94@AdobeOrg","x-real-ip":"10.250.204.235","x-request-id":"LI1ECmqqDb3BZPXZs7mhhS3alcPPUWh1"},"__ow_path":""}
2020-05-04T09:12:49.213Z stdout: 2020-05-04T09:12:49.213Z [aio-lib-campaign-standard] debug: sdk initialized successfully
2020-05-04T09:12:49.213Z stdout: 2020-05-04T09:12:49.213Z [main /bouessay/marketinghisto-app-0.0.1/__secured_getmarketinghistory] debug: before call getAllCustomResources cusMarketingHistory
2020-05-04T09:12:49.219Z stdout: 2020-05-04T09:12:49.219Z [aio-lib-campaign-standard] debug: REQUEST:
{
"url": "https://mc.adobe.io/intersportfrance-mkt-stage1/campaign/profileAndServicesExt/cusMarketingHistory/",
"credentials": "same-origin",
"headers": {
"X-Api-Key": "0ca1f0006e494d9c8b713a92b82df1a0",
"Authorization": "Bearer [hidden-data]"
},
"method": "GET",
"body": "{}"
}
2020-05-04T09:12:50.360Z stdout: 2020-05-04T09:12:50.360Z [aio-lib-campaign-standard] debug: RESPONSE:
{
"ok": false,
"url": "https://mc.adobe.io/intersportfrance-mkt-stage1/campaign/profileAndServicesExt/cusMarketingHistory/",
"status": 404,
"statusText": "Not Found",
"headers": {
"content-type": "text/plain; charset=utf-8",
"date": "Mon, 04 May 2020 09:12:50 GMT",
"server": "openresty",
"strict-transport-security": "max-age=31536000",
"x-content-type-options": "nosniff",
"x-debug-backend": "https://intersportfrance-mkt-stage1-adobeio.campaign.adobe.com/rest/profileAndServicesExt/cusMarketingHistory/",
"x-request-id": "OaQgC5fhTUfdmEOSD5Yx29MUcqew2UQk",
"x-robots-tag": "noindex",
"x-xss-protection": "1; mode=block",
"content-length": "93",
"connection": "Close"
},
"text": "RST-360011 Une erreur s’est produite. Veuillez contacter l’administrateur.\nError rc=-2003",
"data": "RST-360011 Une erreur s’est produite. Veuillez contacter l’administrateur.\nError rc=-2003",
"body": "RST-360011 Une erreur s’est produite. Veuillez contacter l’administrateur. Error rc=-2003",
"obj": "RST-360011 Une erreur s’est produite. Veuillez contacter l’administrateur. Error rc=-2003"
}
2020-05-04T09:12:50.361Z stdout: 2020-05-04T09:12:50.361Z [main /bouessay/marketinghisto-app-0.0.1/__secured_getmarketinghistory] error: [CampaignStandardSDK:ERROR_GET_ALL_CUSTOM_RESOURCES] 404 - Not Found ("RST-360011 Une erreur s’est produite. Veuillez contacter l’administrateur. Error rc=-2003")
2020-05-04T09:12:50.361Z stdout: 2020-05-04T09:12:50.361Z [main /bouessay/marketinghisto-app-0.0.1/__secured_getmarketinghistory] info: 500: server error

ACNA-697 - campaignStandardCoreAPI.getMetadataForResource does not fetch custom/extended attributes of resource

While using the Campaign Standard libraries, using getMetadataForResource(resource) does not fetch the custom/extended attributes related to resource.

Expected Behaviour

getMetadataForResource(resource) library method should pull all the attributes defined for a resource in Adobe Campaign Standard.

Actual Behaviour

getMetadataForResource(resource) library method fetches the default attributes related to resource.

Reproduce Scenario (including but not limited to)

(1) In Adobe Campaign Standard, navigate to Custom resources [Administration > Development > Custom resources]
(2) Click "CREATE" button and select "Extend and existing resource" (basically developers add business use case related custom/extended attributes to existing resource)
(3) Select "Profile" resource
(4) Add some simple attributes of type text / date / integer etc.
(5) Define new links to other attributes to extended resource
(6) Publish resource and the Adobe Campaign Standard forms allows users to populate the newly added attributes.

Steps to Reproduce

Nodesjs:

const acs = require('@adobe/aio-lib-campaign-standard');
const TENANT = "...";
const CLIENT_ID = "...";
const TOKEN = "...";
let get_metadata = async function (tenant, client_id, token, resource) {
    let acs_instance = await acs.init(tenant, client_id, token);
    return await acs_instance.getMetadataForResource(resource);
};

Invoke:

get_metadata(TENANT, CLIENT_ID, TOKEN, "profile").then(function (response) { console.log("success"); console.log(JSON.stringify(response))}).catch(function(error){console.log("error"); console.log(error)});

Response is success; however, does not show the newly added attributes in the response.
But if you refer response.body.href and use AJAX to retrieve the metadata; you can find all custom/extended attributes.

Platform and Version

aio -v
@adobe/aio-cli/2.3.0 darwin-x64 node-v10.16.0

Sample Code that illustrates the problem

Logs taken while reproducing problem

Expose API for custom resources of profiles and services

For "custom resources" in ACS, there are currently 2 APIs being exposed:

  • https://%tenantid%-adobeio.campaign.adobe.com/rest/customResources
  • https://%tenantid%-adobeio.campaign.adobe.com/rest/profileAndServicesExt

In the SDK, we currently expose getAllCustomResources() method, which basically calls /customResources behind the scene. However we don't have any method for /profileAndServicesExt, which contains profile, services and linked customer resources.

Therefore, we need to expose another method for /profileAndServicesExt, e.g. getAllProfileCustomResources().

This will fix #60 .

An in-range update of swagger-client is breaking the build 🚨


🚨 Reminder! Less than one month left to migrate your repositories over to Snyk before Greenkeeper says goodbye on June 3rd! 💜 🚚💨 💚

Find out how to migrate to Snyk at greenkeeper.io


The dependency swagger-client was updated from 3.10.1 to 3.10.2.

🚨 View failing branch.

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

swagger-client is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details

Commits

The new version differs by 22 commits.

  • cb95875 release: v3.10.2
  • af7f7b5 fix: amend header serialization algorithm (#1523)
  • d89a926 docs(tags-interface): add authorizations example (#1525)
  • 39d8b0c docs(tags-interface): document usage of security
  • 0340b15 test(client): fix test for requesting https over http
  • b55fa92 docs(http-client): document possible upload progress
  • 0dffbec Fix typos in documentation (#1520)
  • 3e7d9bf refactor: use noop instead of Function object (#1515)
  • dcddd66 docs(tags-interface): add file uploads example
  • 42718aa docs(try-it-out): add docs for attachContentTypeForEmptyPayload option
  • 13ed570 docs(try-it-out): document interceptor options
  • d82c8dc docs(try-it-out): add array parameter example
  • 2213b8d docs(resolver): fix option default value and description
  • 8a2357b docs(resolver): mention instance method
  • da389b0 docs(API): add basic documentation about library API

There are 22 commits in total.

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 🌴

triggerSignalActivity() throws error when workflow is called during it's "cooldown"

Hi,

External Signal activities in ACS can only be called once every 10 minutes. This is a hardcoded restriction to prevent serious issues in the workflows.

When you use triggerSignalActivity() for an ACS workflow during this 10 minute wait, it will result in an error like this:

error: [CampaignStandardSDK:ERROR_TRIGGER_SIGNAL_ACTIVITY] FetchError: invalid json response body at [URL OF THE TRIGGER] reason: Unexpected token T in JSON at position 0
    at /nodejsAction/dKXSJgAz/index.js:16453:32
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  type: 'invalid-json'
}

This is very likely due to ACS responding in a non-JSON form whenever a trigger is called it cannot execute.

Adding support for creation of extended profiles

Currently we have only one option to create a Profile but the API supports two ways of creating a profile. The endpoints for these two ways are different.
The original and already supported way is the /campaign/profileAndServices/profile but you also have the option to create a profile via /campaign/profileAndServicesExt/profile. In a project that I am working on this is creating an issue because I am unable to create valid profiles for the environment that are attached to a orgUnit.

Could we add support for this?

TypeError for all methods calling GET

It looks like all methods that call GET endpoints are failing by this error TypeError: Request with GET/HEAD method cannot have body. Tested with getAllProfiles and getAllProfileAndServicesExt.

Example code

// initialize the sdk
const campaignClient = await CampaignStandard.init(params.tenant, params.apiKey, token)

// get profiles from Campaign Standard
const profiles = await campaignClient.getAllProfiles()

campaignStandardCoreAPI.getTransactionalEvent should accept an extra macTenantId parameter

Expected Behaviour

Such as reported for campaignStandardCoreAPI.sendTransactionalEvent in #59, the MAC tenant id used by the API call can be different from the org id.

A similar fix than the one applied to #59 should be implemented, and the current getTransactionEvent function deprecated in favor of the new one.

Actual Behaviour

As of now, the SDK library code assumes both MAC tenant id and org id have the same value.

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.