Skip to content

ka4ok85/watson-campaign-automation-spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

watson-campaign-automation-spring

Maven Central Build Status HitCount

Installation

Gradle

compile group: 'com.github.ka4ok85', name: 'watson-campaign-automation-spring', version: '0.0.3'

Maven

<dependency>
    <groupId>com.github.ka4ok85</groupId>
    <artifactId>watson-campaign-automation-spring</artifactId>
    <version>0.0.3</version>
</dependency>

Authentication

Use oAuth authentication mechanism. Log into WCA and request your ClientId, ClientSecret and RefreshToken. All three values are required for accessing WCA API.

Getting ClientId and ClientSecret

  1. Log into WCA.
  2. Go to Menu Settings -> Organization Settings.
  3. Click on Application Account Access.
  4. Click on Add Application button and follow instructions.

Getting RefreshToken

  1. Log into WCA.
  2. Go to Menu Settings -> Organization Settings.
  3. Click on Application Account Access.
  4. Click on Add Account Access button and follow instructions. Choose Application you have added when requested ClientId and ClientSecret.

Library does NOT support password authentication mechanism due to security concerns.

Usage

Every API has 2 corresponding classes:

  1. Options - input parameters for API.
  2. Response - API output parameters.

In order to call API please follow these instructions:

  1. Initiate corresponding Options object.
  2. Path Options object to Engage method which has the same name as API.
  3. Read Response produced by method from step #2.

Spring Boot

  1. Add required values to application.properties
podNumber=1
clientId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
clientSecret=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
refreshToken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  1. Import SpringConfig class
import org.springframework.context.annotation.Import;
import com.github.ka4ok85.wca.config.SpringConfig;

@Import(SpringConfig.class)
  1. Autowire Engage service
@Autowired
private Engage engage;
  1. Use Engage service
ExportListOptions options = new ExportListOptions(66912L);
ResponseContainer<ExportListResponse> response = engage.exportList(options);
System.out.println(response.getResposne());

Java

  1. Import SpringConfig class
import org.springframework.context.annotation.Import;
import com.github.ka4ok85.wca.config.SpringConfig;

@Import(SpringConfig.class)
  1. Init Engage service instance
Engage engage = new Engage(1, "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
  1. Use Engage service
ExportListOptions options = new ExportListOptions(66912L);
ResponseContainer<ExportListResponse> response = engage.exportList(options);
System.out.println(response.getResposne());

Convenience Functionality

Besides easy access to WCA XML API Library provides additional convenience functionality. Please find more details below.

  1. Ability to download Export File. Supported by following APIs:
  • ExportList
  • ExportMailingTemplate
  • ExportTable
  • RawRecipientDataExport
  • WebTrackingDataExport

Following code snippet will download ExportList API result file to your local machine:

ExportListOptions options = new ExportListOptions(1L);
options.setLocalAbsoluteFilePath("c:\\data\\export_list.csv");
ResponseContainer<ExportListResponse> response = engage.exportList(options);