embulk-input-facebook_ads_insights 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/build.gradle +99 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +5 -0
- data/gradlew +172 -0
- data/gradlew.bat +84 -0
- data/lib/embulk/input/facebook_ads_insights.rb +3 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/AdsInsightsAccessor.java +149 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/Client.java +243 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/FacebookAdsInsightsColumnVisitor.java +123 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/FacebookAdsInsightsInputPlugin.java +79 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/PluginTask.java +80 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/Util.java +18 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/ActionAttributionWindow.java +43 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/ActionBreakdown.java +47 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/ActionReportTime.java +38 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/Breakdown.java +69 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/DatePreset.java +55 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/Level.java +40 -0
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/ObjectType.java +30 -0
- data/src/test/java/org/embulk/input/facebook_ads_insights/TestFacebookAdsInsightsInputPlugin.java +5 -0
- metadata +106 -0
data/src/main/java/org/embulk/input/facebook_ads_insights/FacebookAdsInsightsColumnVisitor.java
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights;
|
2
|
+
|
3
|
+
import com.facebook.ads.sdk.AdsInsights;
|
4
|
+
import com.google.gson.JsonElement;
|
5
|
+
import org.embulk.spi.Column;
|
6
|
+
import org.embulk.spi.ColumnConfig;
|
7
|
+
import org.embulk.spi.ColumnVisitor;
|
8
|
+
import org.embulk.spi.PageBuilder;
|
9
|
+
import org.embulk.spi.json.JsonParser;
|
10
|
+
import org.embulk.spi.time.Timestamp;
|
11
|
+
import org.embulk.spi.time.TimestampParser;
|
12
|
+
import org.slf4j.Logger;
|
13
|
+
import org.slf4j.LoggerFactory;
|
14
|
+
|
15
|
+
import java.util.List;
|
16
|
+
import java.util.Objects;
|
17
|
+
|
18
|
+
public class FacebookAdsInsightsColumnVisitor implements ColumnVisitor
|
19
|
+
{
|
20
|
+
private static final String DEFAULT_TIMESTAMP_PATTERN = "%Y-%m-%dT%H:%M:%S.%L%z";
|
21
|
+
private final Logger logger = LoggerFactory.getLogger(FacebookAdsInsightsColumnVisitor.class);
|
22
|
+
|
23
|
+
private final AdsInsightsAccessor accessor;
|
24
|
+
private final PageBuilder pageBuilder;
|
25
|
+
private final PluginTask pluginTask;
|
26
|
+
|
27
|
+
public FacebookAdsInsightsColumnVisitor(final AdsInsights insights, final PageBuilder pageBuilder, final PluginTask pluginTask)
|
28
|
+
{
|
29
|
+
this.accessor = new AdsInsightsAccessor(insights);
|
30
|
+
this.pageBuilder = pageBuilder;
|
31
|
+
this.pluginTask = pluginTask;
|
32
|
+
}
|
33
|
+
|
34
|
+
@Override
|
35
|
+
public void stringColumn(Column column)
|
36
|
+
{
|
37
|
+
try {
|
38
|
+
String data = accessor.get(column.getName());
|
39
|
+
if (Objects.isNull(data)) {
|
40
|
+
pageBuilder.setNull(column);
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
pageBuilder.setString(column, data);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
catch (Exception e) {
|
47
|
+
pageBuilder.setNull(column);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
@Override
|
51
|
+
public void booleanColumn(Column column)
|
52
|
+
{
|
53
|
+
try {
|
54
|
+
String data = accessor.get(column.getName());
|
55
|
+
pageBuilder.setBoolean(column, Boolean.parseBoolean(data));
|
56
|
+
}
|
57
|
+
catch (Exception e) {
|
58
|
+
pageBuilder.setNull(column);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
@Override
|
62
|
+
public void longColumn(Column column)
|
63
|
+
{
|
64
|
+
try {
|
65
|
+
String data = accessor.get(column.getName());
|
66
|
+
pageBuilder.setLong(column, Long.parseLong(data));
|
67
|
+
}
|
68
|
+
catch (Exception e) {
|
69
|
+
pageBuilder.setNull(column);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
@Override
|
73
|
+
public void doubleColumn(Column column)
|
74
|
+
{
|
75
|
+
try {
|
76
|
+
String data = accessor.get(column.getName());
|
77
|
+
pageBuilder.setDouble(column, Double.parseDouble(data));
|
78
|
+
}
|
79
|
+
catch (Exception e) {
|
80
|
+
pageBuilder.setNull(column);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
@Override
|
84
|
+
public void timestampColumn(Column column)
|
85
|
+
{
|
86
|
+
try {
|
87
|
+
List<ColumnConfig> columnConfigs = pluginTask.getFields().getColumns();
|
88
|
+
String pattern = DEFAULT_TIMESTAMP_PATTERN;
|
89
|
+
for (ColumnConfig config : columnConfigs) {
|
90
|
+
if (config.getName().equals(column.getName())
|
91
|
+
&& config.getConfigSource() != null
|
92
|
+
&& config.getConfigSource().getObjectNode() != null
|
93
|
+
&& config.getConfigSource().getObjectNode().get("format") != null
|
94
|
+
&& config.getConfigSource().getObjectNode().get("format").isTextual()) {
|
95
|
+
pattern = config.getConfigSource().getObjectNode().get("format").asText();
|
96
|
+
break;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
TimestampParser parser = TimestampParser.of(pattern, "UTC");
|
100
|
+
Timestamp result = parser.parse(column.getName());
|
101
|
+
pageBuilder.setTimestamp(column, result);
|
102
|
+
}
|
103
|
+
catch (Exception e) {
|
104
|
+
pageBuilder.setNull(column);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
@Override
|
108
|
+
public void jsonColumn(Column column)
|
109
|
+
{
|
110
|
+
try {
|
111
|
+
JsonElement data = new com.google.gson.JsonParser().parse(accessor.get(column.getName()));
|
112
|
+
if (data.isJsonNull() || data.isJsonPrimitive()) {
|
113
|
+
pageBuilder.setNull(column);
|
114
|
+
}
|
115
|
+
else {
|
116
|
+
pageBuilder.setJson(column, new JsonParser().parse(data.toString()));
|
117
|
+
}
|
118
|
+
}
|
119
|
+
catch (Exception e) {
|
120
|
+
pageBuilder.setNull(column);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights;
|
2
|
+
|
3
|
+
import com.facebook.ads.sdk.APIException;
|
4
|
+
import com.facebook.ads.sdk.AdsInsights;
|
5
|
+
import org.embulk.config.ConfigDiff;
|
6
|
+
import org.embulk.config.ConfigSource;
|
7
|
+
import org.embulk.config.TaskReport;
|
8
|
+
import org.embulk.config.TaskSource;
|
9
|
+
import org.embulk.exec.ExecutionInterruptedException;
|
10
|
+
import org.embulk.spi.Exec;
|
11
|
+
import org.embulk.spi.InputPlugin;
|
12
|
+
import org.embulk.spi.PageBuilder;
|
13
|
+
import org.embulk.spi.PageOutput;
|
14
|
+
import org.embulk.spi.Schema;
|
15
|
+
import org.slf4j.Logger;
|
16
|
+
import org.slf4j.LoggerFactory;
|
17
|
+
|
18
|
+
import java.util.List;
|
19
|
+
|
20
|
+
public class FacebookAdsInsightsInputPlugin
|
21
|
+
implements InputPlugin
|
22
|
+
{
|
23
|
+
private final Logger logger = LoggerFactory.getLogger(FacebookAdsInsightsInputPlugin.class);
|
24
|
+
|
25
|
+
@Override
|
26
|
+
public ConfigDiff transaction(ConfigSource config,
|
27
|
+
InputPlugin.Control control)
|
28
|
+
{
|
29
|
+
PluginTask task = config.loadConfig(PluginTask.class);
|
30
|
+
Schema schema = task.getFields().toSchema();
|
31
|
+
return resume(task.dump(), schema, 1, control);
|
32
|
+
}
|
33
|
+
|
34
|
+
@Override
|
35
|
+
public ConfigDiff resume(TaskSource taskSource,
|
36
|
+
Schema schema, int taskCount,
|
37
|
+
InputPlugin.Control control)
|
38
|
+
{
|
39
|
+
control.run(taskSource, schema, taskCount);
|
40
|
+
return Exec.newConfigDiff();
|
41
|
+
}
|
42
|
+
|
43
|
+
@Override
|
44
|
+
public void cleanup(TaskSource taskSource,
|
45
|
+
Schema schema, int taskCount,
|
46
|
+
List<TaskReport> successTaskReports)
|
47
|
+
{
|
48
|
+
}
|
49
|
+
|
50
|
+
@Override
|
51
|
+
public TaskReport run(TaskSource taskSource,
|
52
|
+
Schema schema, int taskIndex,
|
53
|
+
PageOutput output)
|
54
|
+
{
|
55
|
+
PluginTask task = taskSource.loadTask(PluginTask.class);
|
56
|
+
try {
|
57
|
+
try (PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
|
58
|
+
Client client = new Client(task);
|
59
|
+
List<AdsInsights> insights = client.getInsights();
|
60
|
+
for (AdsInsights insight : insights) {
|
61
|
+
schema.visitColumns(new FacebookAdsInsightsColumnVisitor(insight, pageBuilder, task));
|
62
|
+
pageBuilder.addRecord();
|
63
|
+
}
|
64
|
+
pageBuilder.finish();
|
65
|
+
}
|
66
|
+
}
|
67
|
+
catch (APIException | InterruptedException e) {
|
68
|
+
logger.error(e.getMessage(), e);
|
69
|
+
throw new ExecutionInterruptedException(e);
|
70
|
+
}
|
71
|
+
return Exec.newTaskReport();
|
72
|
+
}
|
73
|
+
|
74
|
+
@Override
|
75
|
+
public ConfigDiff guess(ConfigSource config)
|
76
|
+
{
|
77
|
+
return Exec.newConfigDiff();
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights;
|
2
|
+
|
3
|
+
import org.embulk.config.Config;
|
4
|
+
import org.embulk.config.ConfigDefault;
|
5
|
+
import org.embulk.config.Task;
|
6
|
+
import org.embulk.input.facebook_ads_insights.model.ActionAttributionWindow;
|
7
|
+
import org.embulk.input.facebook_ads_insights.model.ActionBreakdown;
|
8
|
+
import org.embulk.input.facebook_ads_insights.model.ActionReportTime;
|
9
|
+
import org.embulk.input.facebook_ads_insights.model.Breakdown;
|
10
|
+
import org.embulk.input.facebook_ads_insights.model.DatePreset;
|
11
|
+
import org.embulk.input.facebook_ads_insights.model.Level;
|
12
|
+
import org.embulk.input.facebook_ads_insights.model.ObjectType;
|
13
|
+
import org.embulk.spi.SchemaConfig;
|
14
|
+
import org.embulk.spi.unit.ToStringMap;
|
15
|
+
|
16
|
+
import java.util.List;
|
17
|
+
import java.util.Optional;
|
18
|
+
|
19
|
+
public interface PluginTask extends Task
|
20
|
+
{
|
21
|
+
@Config("access_token")
|
22
|
+
public String getAccessToken();
|
23
|
+
|
24
|
+
@Config("object_type")
|
25
|
+
public ObjectType getObjectType();
|
26
|
+
|
27
|
+
@Config("object_id")
|
28
|
+
public String getObjectId();
|
29
|
+
|
30
|
+
@Config("fields")
|
31
|
+
public SchemaConfig getFields();
|
32
|
+
|
33
|
+
@Config("action_attribution_windows")
|
34
|
+
@ConfigDefault("null")
|
35
|
+
public Optional<List<ActionAttributionWindow>> getActionAttributionWindows();
|
36
|
+
|
37
|
+
@Config("action_breakdowns")
|
38
|
+
@ConfigDefault("null")
|
39
|
+
public Optional<List<ActionBreakdown>> getActionBreakdowns();
|
40
|
+
|
41
|
+
@Config("action_report_time")
|
42
|
+
@ConfigDefault("null")
|
43
|
+
public Optional<ActionReportTime> getActionReportTime();
|
44
|
+
|
45
|
+
@Config("breakdowns")
|
46
|
+
@ConfigDefault("null")
|
47
|
+
public Optional<List<Breakdown>> getBreakdowns();
|
48
|
+
|
49
|
+
@Config("date_preset")
|
50
|
+
@ConfigDefault("null")
|
51
|
+
public Optional<DatePreset> getDatePreset();
|
52
|
+
|
53
|
+
@Config("filtering")
|
54
|
+
@ConfigDefault("null")
|
55
|
+
public Optional<List<ToStringMap>> getFiltering();
|
56
|
+
|
57
|
+
@Config("level")
|
58
|
+
@ConfigDefault("null")
|
59
|
+
public Optional<Level> getLevel();
|
60
|
+
|
61
|
+
@Config("product_id_limit")
|
62
|
+
@ConfigDefault("null")
|
63
|
+
public Optional<Long> getProductIdLimit();
|
64
|
+
|
65
|
+
@Config("sort")
|
66
|
+
@ConfigDefault("null")
|
67
|
+
public Optional<List<String>> getSort();
|
68
|
+
|
69
|
+
@Config("time_increment")
|
70
|
+
@ConfigDefault("null")
|
71
|
+
public Optional<String> getTimeIncrement();
|
72
|
+
|
73
|
+
@Config("time_ranges")
|
74
|
+
@ConfigDefault("null")
|
75
|
+
public Optional<List<ToStringMap>> getTimeRanges();
|
76
|
+
|
77
|
+
@Config("use_account_attribution_setting")
|
78
|
+
@ConfigDefault("null")
|
79
|
+
public Optional<Boolean> getUseAccountAttributionSetting();
|
80
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights;
|
2
|
+
|
3
|
+
import com.google.gson.Gson;
|
4
|
+
import org.embulk.spi.unit.ToStringMap;
|
5
|
+
|
6
|
+
import java.util.List;
|
7
|
+
import java.util.stream.Collectors;
|
8
|
+
|
9
|
+
public class Util
|
10
|
+
{
|
11
|
+
private Util() {}
|
12
|
+
|
13
|
+
public static String stringifyToStringMaps(List<ToStringMap> value)
|
14
|
+
{
|
15
|
+
Gson gson = new Gson();
|
16
|
+
return "[" + value.stream().map(gson::toJson).collect(Collectors.joining(",")) + "]";
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights.model;
|
2
|
+
|
3
|
+
import com.facebook.ads.sdk.AdsInsights;
|
4
|
+
import com.fasterxml.jackson.annotation.JsonCreator;
|
5
|
+
import com.fasterxml.jackson.annotation.JsonValue;
|
6
|
+
import org.embulk.config.ConfigException;
|
7
|
+
|
8
|
+
public class ActionAttributionWindow
|
9
|
+
{
|
10
|
+
private final AdsInsights.EnumActionAttributionWindows enumActionAttributionWindows;
|
11
|
+
|
12
|
+
private ActionAttributionWindow(final AdsInsights.EnumActionAttributionWindows enumActionAttributionWindows)
|
13
|
+
{
|
14
|
+
this.enumActionAttributionWindows = enumActionAttributionWindows;
|
15
|
+
}
|
16
|
+
|
17
|
+
@JsonValue
|
18
|
+
@Override
|
19
|
+
public String toString()
|
20
|
+
{
|
21
|
+
return this.enumActionAttributionWindows.toString();
|
22
|
+
}
|
23
|
+
|
24
|
+
@JsonCreator
|
25
|
+
public static ActionAttributionWindow fromString(final String value)
|
26
|
+
{
|
27
|
+
switch (value) {
|
28
|
+
case "1d_click": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_1D_CLICK);
|
29
|
+
case "1d_view": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_1D_VIEW);
|
30
|
+
case "7d_click": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_7D_CLICK);
|
31
|
+
case "7d_view": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_7D_VIEW);
|
32
|
+
case "28d_click": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_28D_CLICK);
|
33
|
+
case "28d_view": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_28D_VIEW);
|
34
|
+
case "default": return new ActionAttributionWindow(AdsInsights.EnumActionAttributionWindows.VALUE_DEFAULT);
|
35
|
+
default: throw new ConfigException(String.format("Unknown ActionAttributionWindow value '%s'", value));
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
public AdsInsights.EnumActionAttributionWindows getEnum()
|
40
|
+
{
|
41
|
+
return this.enumActionAttributionWindows;
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights.model;
|
2
|
+
|
3
|
+
import com.facebook.ads.sdk.AdsInsights;
|
4
|
+
import com.fasterxml.jackson.annotation.JsonCreator;
|
5
|
+
import com.fasterxml.jackson.annotation.JsonValue;
|
6
|
+
import org.embulk.config.ConfigException;
|
7
|
+
|
8
|
+
public class ActionBreakdown
|
9
|
+
{
|
10
|
+
private final AdsInsights.EnumActionBreakdowns enumActionBreakdowns;
|
11
|
+
|
12
|
+
private ActionBreakdown(final AdsInsights.EnumActionBreakdowns enumActionBreakdowns)
|
13
|
+
{
|
14
|
+
this.enumActionBreakdowns = enumActionBreakdowns;
|
15
|
+
}
|
16
|
+
|
17
|
+
@JsonValue
|
18
|
+
@Override
|
19
|
+
public String toString()
|
20
|
+
{
|
21
|
+
return this.enumActionBreakdowns.toString();
|
22
|
+
}
|
23
|
+
|
24
|
+
@JsonCreator
|
25
|
+
public static ActionBreakdown fromString(final String value)
|
26
|
+
{
|
27
|
+
switch (value) {
|
28
|
+
case "action_converted_product_id": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CONVERTED_PRODUCT_ID);
|
29
|
+
case "action_device": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_DEVICE);
|
30
|
+
case "action_canvas_component_name": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CANVAS_COMPONENT_NAME);
|
31
|
+
case "action_carousel_card_id": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CAROUSEL_CARD_ID);
|
32
|
+
case "action_carousel_card_name": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CAROUSEL_CARD_NAME);
|
33
|
+
case "action_destination": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_DESTINATION);
|
34
|
+
case "action_reaction": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_REACTION);
|
35
|
+
case "action_target_id": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_TARGET_ID);
|
36
|
+
case "action_type": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_TYPE);
|
37
|
+
case "action_video_sound": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_VIDEO_SOUND);
|
38
|
+
case "action_video_type": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_VIDEO_TYPE);
|
39
|
+
default: throw new ConfigException(String.format("Unknown ActionBreakdown value '%s'", value));
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
public AdsInsights.EnumActionBreakdowns getEnum()
|
44
|
+
{
|
45
|
+
return this.enumActionBreakdowns;
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights.model;
|
2
|
+
|
3
|
+
import com.facebook.ads.sdk.AdsInsights;
|
4
|
+
import com.fasterxml.jackson.annotation.JsonCreator;
|
5
|
+
import com.fasterxml.jackson.annotation.JsonValue;
|
6
|
+
import org.embulk.config.ConfigException;
|
7
|
+
|
8
|
+
public class ActionReportTime
|
9
|
+
{
|
10
|
+
private final AdsInsights.EnumActionReportTime enumActionReportTime;
|
11
|
+
|
12
|
+
private ActionReportTime(final AdsInsights.EnumActionReportTime enumActionReportTime)
|
13
|
+
{
|
14
|
+
this.enumActionReportTime = enumActionReportTime;
|
15
|
+
}
|
16
|
+
|
17
|
+
@JsonValue
|
18
|
+
@Override
|
19
|
+
public String toString()
|
20
|
+
{
|
21
|
+
return this.enumActionReportTime.toString();
|
22
|
+
}
|
23
|
+
|
24
|
+
@JsonCreator
|
25
|
+
public static ActionReportTime fromString(final String value)
|
26
|
+
{
|
27
|
+
switch (value) {
|
28
|
+
case "conversion": return new ActionReportTime(AdsInsights.EnumActionReportTime.VALUE_CONVERSION);
|
29
|
+
case "impression": return new ActionReportTime(AdsInsights.EnumActionReportTime.VALUE_IMPRESSION);
|
30
|
+
default: throw new ConfigException(String.format("Unknown ActionReportTime value '%s'", value));
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
public AdsInsights.EnumActionReportTime getEnum()
|
35
|
+
{
|
36
|
+
return this.enumActionReportTime;
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
package org.embulk.input.facebook_ads_insights.model;
|
2
|
+
|
3
|
+
import com.facebook.ads.sdk.AdsInsights;
|
4
|
+
import com.fasterxml.jackson.annotation.JsonCreator;
|
5
|
+
import com.fasterxml.jackson.annotation.JsonValue;
|
6
|
+
import org.embulk.config.ConfigException;
|
7
|
+
|
8
|
+
import java.util.ArrayList;
|
9
|
+
import java.util.Arrays;
|
10
|
+
import java.util.List;
|
11
|
+
|
12
|
+
public class Breakdown
|
13
|
+
{
|
14
|
+
public static final List<String> NAMES = new ArrayList<>(Arrays.asList(
|
15
|
+
"ad_format_asset", "age", "body_asset", "call_to_action_asset", "country",
|
16
|
+
"description_asset", "gender", "image_asset", "impression_device", "link_url_asset",
|
17
|
+
"product_id", "region", "title_asset", "video_asset", "dma", "frequency_value",
|
18
|
+
"hourly_stats_aggregated_by_advertiser_time_zone", "hourly_stats_aggregated_by_audience_time_zone",
|
19
|
+
"place_page_id", "publisher_platform", "platform_position", "device_platform"
|
20
|
+
));
|
21
|
+
private final AdsInsights.EnumBreakdowns enumBreakdowns;
|
22
|
+
|
23
|
+
private Breakdown(final AdsInsights.EnumBreakdowns enumBreakdowns)
|
24
|
+
{
|
25
|
+
this.enumBreakdowns = enumBreakdowns;
|
26
|
+
}
|
27
|
+
|
28
|
+
@JsonValue
|
29
|
+
@Override
|
30
|
+
public String toString()
|
31
|
+
{
|
32
|
+
return this.enumBreakdowns.toString();
|
33
|
+
}
|
34
|
+
|
35
|
+
@JsonCreator
|
36
|
+
public static Breakdown fromString(final String value)
|
37
|
+
{
|
38
|
+
switch (value) {
|
39
|
+
case "ad_format_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_AD_FORMAT_ASSET);
|
40
|
+
case "age": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_AGE);
|
41
|
+
case "body_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_BODY_ASSET);
|
42
|
+
case "call_to_action_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_CALL_TO_ACTION_ASSET);
|
43
|
+
case "country": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_COUNTRY);
|
44
|
+
case "description_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_DESCRIPTION_ASSET);
|
45
|
+
case "gender": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_GENDER);
|
46
|
+
case "image_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_IMAGE_ASSET);
|
47
|
+
case "impression_device": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_IMPRESSION_DEVICE);
|
48
|
+
case "link_url_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_LINK_URL_ASSET);
|
49
|
+
case "product_id": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_PRODUCT_ID);
|
50
|
+
case "region": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_REGION);
|
51
|
+
case "title_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_TITLE_ASSET);
|
52
|
+
case "video_asset": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_VIDEO_ASSET);
|
53
|
+
case "dma": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_DMA);
|
54
|
+
case "frequency_value": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_FREQUENCY_VALUE);
|
55
|
+
case "hourly_stats_aggregated_by_advertiser_time_zone": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_HOURLY_STATS_AGGREGATED_BY_ADVERTISER_TIME_ZONE);
|
56
|
+
case "hourly_stats_aggregated_by_audience_time_zone": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_HOURLY_STATS_AGGREGATED_BY_AUDIENCE_TIME_ZONE);
|
57
|
+
case "place_page_id": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_PLACE_PAGE_ID);
|
58
|
+
case "publisher_platform": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_PUBLISHER_PLATFORM);
|
59
|
+
case "platform_position": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_PLATFORM_POSITION);
|
60
|
+
case "device_platform": return new Breakdown(AdsInsights.EnumBreakdowns.VALUE_DEVICE_PLATFORM);
|
61
|
+
default: throw new ConfigException(String.format("Unknown Breakdown value '%s'", value));
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
public AdsInsights.EnumBreakdowns getEnum()
|
66
|
+
{
|
67
|
+
return this.enumBreakdowns;
|
68
|
+
}
|
69
|
+
}
|