1.3.1 • Published 3 years ago

odc-api v1.3.1

Weekly downloads
16
License
ISC
Repository
-
Last release
3 years ago

odc-api

An API that simplifies working with the WPP ODC platform. It's still a W.I.P., so not all functionality from the ODC platform is included. Note that this library is not officially supported by the ODC development team. Before using this in a case, discuss what you're up to with the development team so you know for sure the platform will be able to handle it. This library is using the Front End API, so it might not be suitable for large quantities of data.

In case you're missing some functionality, contact MEH@greenhousegroup.com for more information.

Example 1: Create Context Rule

import ODCAuthClient, { Adset, predicateHelper } from "../src/index";

(async () => {
  try {
    const authClient = new ODCAuthClient({
      email: process.env.EMAIL,
      password: process.env.PASSWORD,
    });
    const adset = new Adset(authClient, 1234);
    await adset.syncContent("draft");

    adset.addContextRule({
      predicate: predicateHelper.create("id", "=", "1234"),
      assignments: [{ name: "title", expr: "A new Title for this ID" }],
    });

    await adset.saveChanges();
  } catch (e) {
    console.log(e);
  }
})();

Structure

Classes

ODC

Client class that handles authentication and requests.

Usage:

const authClient = new ODCAuthClient({
  email: EMAIL<String>,
  password: PASSWORD<String>,
});

Exposes three different methods:

  • GET
  • POST
  • UPDATE

Switch to another agency

When your account has access to multiple agencies, you should explicitely switch to that agency.

Usage:

authclient.switchAgency(1);

Please note that it's a best practise to create a dedicated account for API usage.

Entitites

Adset

Class for updating an Adset. Not yet supporting the creation of adsets dynamically.

Usage:

new Adset(odcClient <ODCAuthClient>, adsetId <Number>);

AdsetService

Service that wraps multiple functions of the Adset entity, making it easier to use. For example, when creating a Context Rule, you don't have to manually sync the adset content and save the changes afterwards.

Usage:

const adsetService = new AdsetService(odcClient <ODCAuthClient>);
await adsetService.addContextRules(adsetId: <Number>, rules: <ContextRule[]>);
1.3.1

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago