Skip to content

Commit

Permalink
Merge pull request #73 from taboola/closing-api-gaps-2023
Browse files Browse the repository at this point in the history
Closing api gaps 2023
  • Loading branch information
vladimanaev authored Nov 14, 2023
2 parents 8124df7 + 0e8903c commit 353375a
Show file tree
Hide file tree
Showing 44 changed files with 1,701 additions and 56 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Backstage API Java Client

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.taboola/backstage-api-java-client/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/com.taboola/backstage-api-java-client)
[![Build Status](https://app.travis-ci.com/taboola/backstage-api-java-client.svg?branch=master)](https://app.travis-ci.com/taboola/backstage-api-java-client)

[//]: # ([![Build Status](https://app.travis-ci.com/taboola/backstage-api-java-client.svg?branch=master)](https://app.travis-ci.com/taboola/backstage-api-java-client))

### Table of Contents
1. [Getting Started](#1-getting-started)
Expand Down Expand Up @@ -65,21 +66,21 @@ try {
//create campaign
Campaign campaign = backstage.campaignsService().create(clientAuth, accountId, createCampaignOperation);
//configure item
CampaignItemOperation campaignItemOperation = CampaignItemOperation.create()
.setUrl("http://www.example.com");
//configure first item
CampaignItemOperation firstCampaignItem = CampaignItemOperation.create()
.setUrl("http://www.example.com")
.setTitle("Example Title")
.setThumbnailUrl("http://www.example.com/thumbnail.png");
//create item
CampaignItem item = backstage.campaignItemsService().createItem(clientAuth, accountId,
campaign.getId(), campaignItemOperation);
//configure collection item creation request
CampaignItemMassiveOperation campaignItemMassiveOperation = CampaignItemMassiveOperation.create()
.addItem(firstCampaignItem);
//polling until Taboola crawler done crawling our supplied URL
while(ItemStatus.CRAWLING.equals(item.getStatus())) {
Thread.sleep(10_000L);
item = backstage.campaignItemsService().readItem(clientAuth, accountId, campaign.getId(), item.getId());
}
//create items
Results<CampaignItem> item = backstage.campaignItemsService().createMassive(clientAuth, accountId,
campaign.getId(), campaignItemMassiveOperation);
//item done crawling, do something...
//items and campaigns were created, do something...
} catch (BackstageAPIUnauthorizedException e) {
logger.warn("Token is expired or bad credentials", e);
Expand All @@ -93,7 +94,7 @@ try {
### 3. Authentication

Supports:
1. CLIENT_CREDENTIALS
1. CLIENT_CREDENTIALS - Recommended for server to server integrations
2. PASSWORD_AUTHENTICATION

Authentication service can be found under Backstage instance, see below:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.taboola</groupId>
<artifactId>backstage-api-java-client</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Backstage API Java Client</description>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/taboola/backstage/Backstage.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static class BackstageBuilder {
private static final String DEFAULT_BACKSTAGE_HOST = "https://backstage.taboola.com/backstage/";
private static final String DEFAULT_AUTH_BACKSTAGE_HOST = "https://authentication.taboola.com/authentication/";
private static final String DEFAULT_USER_AGENT = "Taboola Java Client";
private static final String VERSION = "1.1.4";
private static final String VERSION = "1.1.5";
private static final SerializationConfig DEFAULT_SERIALIZATION_CONFIG = new SerializationConfig();

private String baseUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import com.taboola.backstage.model.media.campaigns.items.CampaignItemMassiveCreationOperation;
import com.taboola.backstage.model.media.campaigns.items.CampaignItemMassiveOperation;
import com.taboola.backstage.model.media.campaigns.items.CampaignItemMassiveUpdateOperation;
import com.taboola.backstage.model.media.campaigns.items.CampaignPerformanceVideoItem;
import com.taboola.backstage.model.media.campaigns.items.PerformanceVideoBulkCreateOperation;
import com.taboola.backstage.model.media.campaigns.items.PerformanceVideoBulkUpdateOperation;

import retrofit2.http.*;

Expand Down Expand Up @@ -103,4 +106,53 @@ CampaignItem deleteItem(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId,
@Path("item_id") String itemId) throws BackstageAPIException;

@GET(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/campaigns/{campaign_id}/performance-video/items")
@Headers("Content-Type: application/json")
Results<CampaignPerformanceVideoItem> getVideoCreatives(@Header("Authorization") String authToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId) throws BackstageAPIException;

@GET(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/campaigns/{campaign_id}/performance-video/items/{creative_id}")
@Headers("Content-Type: application/json")
CampaignPerformanceVideoItem getVideoCreative(@Header("Authorization") String authToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId,
@Path("creative_id") String creativeId) throws BackstageAPIException;

@POST(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/campaigns/{campaign_id}/performance-video/items")
@Headers("Content-Type: application/json")
CampaignPerformanceVideoItem insertVideoCreative(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId,
@Body CampaignPerformanceVideoItem newItem) throws BackstageAPIException;

@PUT(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/campaigns/{campaign_id}/performance-video/items/{creative_id}")
@Headers("Content-Type: application/json")
CampaignPerformanceVideoItem updateVideoCreative(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId,
@Path("creative_id") String creativeId,
@Query("bypass_url_response_validation") boolean bypassUrlResponseValidation,
@Body CampaignPerformanceVideoItem updatePojo) throws BackstageAPIException;

@DELETE(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/campaigns/{campaign_id}/performance-video/items/{creative_id}")
@Headers("Content-Type: application/json")
CampaignPerformanceVideoItem deleteVideoCreative(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId,
@Path("creative_id") String creativeId) throws BackstageAPIException;

@PUT(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/items/bulk/performance-video")
@Headers("Content-Type: application/json")
Results<CampaignPerformanceVideoItem> bulkCreateVideo(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Body PerformanceVideoBulkCreateOperation create) throws BackstageAPIException;

@POST(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/items/bulk/performance-video")
@Headers("Content-Type: application/json")
Results<CampaignPerformanceVideoItem> bulkUpdateVideo(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Query("bypass_url_response_validation") boolean bypassUrlResponseValidation,
@Body PerformanceVideoBulkUpdateOperation update) throws BackstageAPIException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.taboola.backstage.model.media.campaigns.Campaign;
import com.taboola.backstage.model.media.campaigns.CampaignBase;
import com.taboola.backstage.model.media.campaigns.CampaignPatch;
import com.taboola.backstage.model.media.campaigns.CampaignTargetingCollection;
import com.taboola.backstage.model.media.campaigns.CampaignsMassiveOperation;

import retrofit2.http.*;
Expand Down Expand Up @@ -77,4 +78,10 @@ CampaignPatch patchCampaign(@Header("Authorization") String accessToken,
Campaign deleteCampaign(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId);

@GET(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "{account_id}/campaigns/{campaign_id}/targeting/publisher_targeting/whitelist")
@Headers("Content-Type: application/json")
CampaignTargetingCollection<String> getCampaignTargetingWhiteList(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Path("campaign_id") String campaignId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.taboola.backstage.exceptions.BackstageAPIException;
import com.taboola.backstage.model.media.reports.CampaignSummaryReport;
import com.taboola.backstage.model.media.reports.HistoryReport;
import com.taboola.backstage.model.media.reports.TopCampaignContentReport;
import retrofit2.http.*;

Expand Down Expand Up @@ -32,4 +33,11 @@ CampaignSummaryReport getCampaignSummary(@Header("Authorization") String authTok
@Query("start_date") String startDate,
@Query("end_date") String endDate,
@QueryMap Map<String, String> filters) throws BackstageAPIException;
}

@GET(BackstagePaths.BACKSTAGE_API_PATH_PREFIX + "/{account_id}/reports/campaign-history/dimensions/by_account")
@Headers("Content-Type: application/json")
HistoryReport getCampaignHistoryByAccountReport(@Header("Authorization") String authToken,
@Path("account_id") String accountId,
@Query("start_date") String startDate,
@Query("end_date") String endDate) throws BackstageAPIException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.taboola.backstage.model.media.campaigns;

import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;

/**
* Created by vladi.m
* Date 13/11/2023
* Time 9:46
* Copyright Taboola
*/
public enum AggregationType {
AGGREGATED,
LAST_VALUE,
@JsonEnumDefaultValue UNSUPPORTED_BY_SDK_VALUE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.taboola.backstage.model.media.campaigns;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* Created by vladi.m
* Date 13/11/2023
* Time 9:38
* Copyright Taboola
*/
public class AttributionConfig {
private Integer lookBackWindowInMinutes;
private Integer vtaLookBackWindowInMinutes;
private AggregationType aggregationType;

public Integer getLookBackWindowInMinutes() {
return lookBackWindowInMinutes;
}

public void setLookBackWindowInMinutes(Integer lookBackWindowInMinutes) {
this.lookBackWindowInMinutes = lookBackWindowInMinutes;
}

public Integer getVtaLookBackWindowInMinutes() {
return vtaLookBackWindowInMinutes;
}

public void setVtaLookBackWindowInMinutes(Integer vtaLookBackWindowInMinutes) {
this.vtaLookBackWindowInMinutes = vtaLookBackWindowInMinutes;
}

public AggregationType getAggregationType() {
return aggregationType;
}

public void setAggregationType(AggregationType aggregationType) {
this.aggregationType = aggregationType;
}

@Override
public String toString() {
return "AttributionConfig{" +
"lookBackWindowInMinutes=" + lookBackWindowInMinutes +
", vtaLookBackWindowInMinutes=" + vtaLookBackWindowInMinutes +
", aggregationType=" + aggregationType +
'}';
}
}
Loading

0 comments on commit 353375a

Please sign in to comment.