embulk-input-facebook_ads_insights 0.1.5 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/build.gradle +2 -2
- data/src/main/java/org/embulk/input/facebook_ads_insights/Client.java +55 -20
- data/src/main/java/org/embulk/input/facebook_ads_insights/PluginTask.java +1 -1
- data/src/main/java/org/embulk/input/facebook_ads_insights/model/DatePreset.java +2 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e15001bc050404e05fc3b7e722b04c0a5482d99e
|
4
|
+
data.tar.gz: f7ab80fcb6b69af1af7c4b1d89d89962bce2aabb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec4d35fec9a2004948a407fa3b26265b3519167be8fd03306c74ace9ed617cb13d969ace589d291aa9dba923661a94db24fba6b18a051970f8ceffd7ccd58a6
|
7
|
+
data.tar.gz: 336ade308d51f06878cbd228ba39a1de3c85fc65fc98c23de86ccd8a49c984d633d73e9a09bf81209ca711586cb2f30635792e00ba30f2f4070be7fce4f0ee17
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Required Embulk version >= 0.9
|
|
19
19
|
| object_type | yes | ObjectEnum | ads object type. |
|
20
20
|
| object_id | yes | string | ads object id. |
|
21
21
|
| fields | yes | array({name:{FieldEnum, BreakdownEnum}, type:string}) | columns to fetch. |
|
22
|
-
| action_attribution_windows | no | array(ActionAttributionWindowEnum)
|
22
|
+
| action_attribution_windows | no | array(ActionAttributionWindowEnum) | see [action_attribution_windows](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
|
23
23
|
| action_breakdowns | no | array(ActionBreakdownEnum) | see [action_breakdowns](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
|
24
24
|
| action_report_time | no | enum{impression, conversion} | see [action_report_time](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
|
25
25
|
| breakdowns | no | array(BreakdownEnum) | see [breakdowns](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
|
@@ -42,7 +42,7 @@ Required Embulk version >= 0.9
|
|
42
42
|
| ActionAttributionWindowEnum | 1d_view, 7d_view, 28d_view, 1d_click, 7d_click, 28d_click, default |
|
43
43
|
| ActionBreakdownEnum | action_device, action_canvas_component_name, action_carousel_card_id, action_carousel_card_name, action_destination, action_reaction, action_target_id, action_type, action_video_sound, action_video_type |
|
44
44
|
| BreakdownEnum | ad_format_asset, age, body_asset, call_to_action_asset, country, description_asset, gender, image_asset, impression_device, link_url_asset, product_id, region, title_asset, video_asset, dma, frequency_value, hourly_stats_aggregated_by_advertiser_time_zone, hourly_stats_aggregated_by_audience_time_zone, place_page_id, publisher_platform, platform_position, device_platform |
|
45
|
-
| DatePresetEnum | today, yesterday, this_month, last_month, this_quarter, lifetime, last_3d, last_7d, last_14d, last_28d, last_30d, last_90d, last_week_mon_sun, last_week_sun_sat, last_quarter, last_year, this_week_mon_today, this_week_sun_today, this_year |
|
45
|
+
| DatePresetEnum | today, yesterday, this_month, last_month, this_quarter, lifetime, maximum, last_3d, last_7d, last_14d, last_28d, last_30d, last_90d, last_week_mon_sun, last_week_sun_sat, last_quarter, last_year, this_week_mon_today, this_week_sun_today, this_year |
|
46
46
|
| FilteringOperatorEnum | EQUAL, NOT_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, IN_RANGE, NOT_IN_RANGE, CONTAIN, NOT_CONTAIN, IN, NOT_IN, STARTS_WITH, ANY, ALL, AFTER, BEFORE, NONE} |
|
47
47
|
|
48
48
|
## Example
|
data/build.gradle
CHANGED
@@ -13,7 +13,7 @@ configurations {
|
|
13
13
|
provided
|
14
14
|
}
|
15
15
|
|
16
|
-
version = "0.1.
|
16
|
+
version = "0.1.10"
|
17
17
|
|
18
18
|
sourceCompatibility = 1.8
|
19
19
|
targetCompatibility = 1.8
|
@@ -21,7 +21,7 @@ targetCompatibility = 1.8
|
|
21
21
|
dependencies {
|
22
22
|
compile "org.embulk:embulk-core:0.9.17"
|
23
23
|
provided "org.embulk:embulk-core:0.9.17"
|
24
|
-
compile group: "com.facebook.business.sdk", name: "facebook-java-business-sdk", version: "
|
24
|
+
compile group: "com.facebook.business.sdk", name: "facebook-java-business-sdk", version: "10.0.0"
|
25
25
|
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
|
26
26
|
testCompile "junit:junit:4.+"
|
27
27
|
}
|
@@ -24,7 +24,8 @@ import java.util.stream.Collectors;
|
|
24
24
|
public class Client
|
25
25
|
{
|
26
26
|
private final Logger logger = LoggerFactory.getLogger(Client.class);
|
27
|
-
private static final int ASYNC_SLEEP_TIME =
|
27
|
+
private static final int ASYNC_SLEEP_TIME = 30000;
|
28
|
+
private static final int ASYNC_SLEEP_TIME_LIMIT = 900_000;
|
28
29
|
|
29
30
|
private final PluginTask pluginTask;
|
30
31
|
|
@@ -35,34 +36,68 @@ public class Client
|
|
35
36
|
|
36
37
|
public List<AdsInsights> getInsights(boolean isPaginationValid) throws APIException, InterruptedException
|
37
38
|
{
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
int elapsedTime = 0;
|
40
|
+
boolean asyncCompleted = false;
|
41
|
+
AdReportRun adReportRun = null;
|
42
|
+
while (!asyncCompleted) {
|
43
|
+
switch (pluginTask.getObjectType()) {
|
44
|
+
case ACCOUNT: {
|
45
|
+
adReportRun = getAdAccountInsights();
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
case CAMPAIGN: {
|
49
|
+
adReportRun = getCampaignInsights();
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
case ADSET: {
|
53
|
+
adReportRun = getAdSetInsights();
|
54
|
+
break;
|
55
|
+
}
|
56
|
+
case AD: {
|
57
|
+
adReportRun = getAdInsights();
|
58
|
+
break;
|
59
|
+
}
|
60
|
+
default: throw new IllegalArgumentException();
|
43
61
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
62
|
+
logger.info(adReportRun.getRawResponse());
|
63
|
+
|
64
|
+
String jobStatus = "";
|
65
|
+
try {
|
66
|
+
while (adReportRun.fetch().getFieldAsyncPercentCompletion() != 100) {
|
67
|
+
logger.info(adReportRun.getRawResponse());
|
68
|
+
Thread.sleep(ASYNC_SLEEP_TIME);
|
69
|
+
elapsedTime += ASYNC_SLEEP_TIME;
|
70
|
+
if (adReportRun.getFieldAsyncStatus().equals("Job Skipped")) {
|
71
|
+
jobStatus = "skipped";
|
72
|
+
throw new RuntimeException("async was aborted because the AsyncStatus is \"Job Skipped\"");
|
73
|
+
}
|
74
|
+
if (adReportRun.getFieldAsyncStatus().equals("Job Failed")) {
|
75
|
+
jobStatus = "failed";
|
76
|
+
throw new RuntimeException("async was aborted because the AsyncStatus is \"Job Failed\"");
|
77
|
+
}
|
78
|
+
if (adReportRun.getFieldAsyncStatus().equals("Job Not Started") && elapsedTime >= ASYNC_SLEEP_TIME_LIMIT) {
|
79
|
+
jobStatus = "aborted";
|
80
|
+
throw new RuntimeException("async was aborted because the number of retries exceeded the limit");
|
81
|
+
}
|
82
|
+
}
|
83
|
+
asyncCompleted = true;
|
51
84
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
85
|
+
catch (RuntimeException e) {
|
86
|
+
if (jobStatus != "failed"){
|
87
|
+
throw new APIException(e);
|
88
|
+
}
|
55
89
|
}
|
56
|
-
default: throw new IllegalArgumentException();
|
57
90
|
}
|
58
|
-
|
59
|
-
|
91
|
+
if (adReportRun == null || adReportRun.getFieldAsyncPercentCompletion() != 100) {
|
92
|
+
throw new APIException();
|
60
93
|
}
|
94
|
+
logger.info(adReportRun.getRawResponse());
|
95
|
+
|
61
96
|
// extra waiting
|
62
97
|
int retryCount = 0;
|
63
98
|
boolean succeeded = false;
|
64
99
|
APINodeList<AdsInsights> adsInsights = null;
|
65
|
-
while (retryCount < pluginTask.
|
100
|
+
while (retryCount < pluginTask.getMaxWaitSeconds() && !succeeded) {
|
66
101
|
try {
|
67
102
|
Thread.sleep(1000);
|
68
103
|
adsInsights = adReportRun.getInsights().execute();
|
@@ -30,7 +30,8 @@ public class DatePreset
|
|
30
30
|
case "this_month": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_THIS_MONTH);
|
31
31
|
case "last_month": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_LAST_MONTH);
|
32
32
|
case "this_quarter": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_THIS_QUARTER);
|
33
|
-
case "lifetime": return new DatePreset(AdsInsights.EnumDatePreset.
|
33
|
+
case "lifetime": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_MAXIMUM);
|
34
|
+
case "maximum": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_MAXIMUM);
|
34
35
|
case "last_3d": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_LAST_3D);
|
35
36
|
case "last_7d": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_LAST_7D);
|
36
37
|
case "last_14d": return new DatePreset(AdsInsights.EnumDatePreset.VALUE_LAST_14D);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-facebook_ads_insights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- naotaka nakane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,12 +50,16 @@ files:
|
|
50
50
|
- README.md
|
51
51
|
- build.gradle
|
52
52
|
- classpath/annotations-13.0.jar
|
53
|
-
- classpath/
|
54
|
-
- classpath/
|
53
|
+
- classpath/byte-buddy-1.10.13.jar
|
54
|
+
- classpath/byte-buddy-agent-1.10.13.jar
|
55
|
+
- classpath/embulk-input-facebook_ads_insights-0.1.10.jar
|
56
|
+
- classpath/facebook-java-business-sdk-10.0.0.jar
|
55
57
|
- classpath/gson-2.5.jar
|
56
58
|
- classpath/guava-20.0.jar
|
57
59
|
- classpath/kotlin-stdlib-1.2.60.jar
|
58
60
|
- classpath/kotlin-stdlib-common-1.2.60.jar
|
61
|
+
- classpath/mockito-core-3.5.11.jar
|
62
|
+
- classpath/objenesis-3.1.jar
|
59
63
|
- classpath/okhttp-3.9.1.jar
|
60
64
|
- classpath/okio-2.1.0.jar
|
61
65
|
- config/checkstyle/checkstyle.xml
|