embulk-input-facebook_ads_insights 0.1.6 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9ef0353a04d37cbbf4f88b5248044c2735621bf
4
- data.tar.gz: 245b4b5eb6452b904e9b7b6a9cd3ef59e3766b0c
3
+ metadata.gz: 79ad7271aa1d3f1049ff02767fa72185fa5cdefd
4
+ data.tar.gz: 2033ec87f0bde97e4d2af1f9acf416e43a189c58
5
5
  SHA512:
6
- metadata.gz: e231d047ae94fb6d2ed28c2b63ee873430bec9534278041990bafea8fcc622acd97300583e48d9dda6dd000182575791abb7b5caa5a61e3fe0de53c57ecb1b62
7
- data.tar.gz: 857a30dbabfe73e0f952f7bde8a5a3b2d3700b058b477358e594ecbf37dd73925100b8cbc0bf7b51070174bb2bef151bc1b98b59e5243bca891d94ef1ad8fa4d
6
+ metadata.gz: 69b5fa024f8c0f676c0263a206bd372c4b6effcb79dc6f643221720d7680685a0a3871f9841a7170702831d688c32d1658cd40e3e3cca898ae1759457878e086
7
+ data.tar.gz: e68abcef4d926d532174971aa1465d1f9b5fd162d4c13fb3ad9dd8b5891db5f79aba5feabda3df741aa4071e80233c90ca82eef68f7a311d9b59b64fda314bb5
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) | see [action_attribution_windows](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
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.6"
16
+ version = "0.1.11"
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: "8.0.2"
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
  }
@@ -25,6 +25,7 @@ public class Client
25
25
  {
26
26
  private final Logger logger = LoggerFactory.getLogger(Client.class);
27
27
  private static final int ASYNC_SLEEP_TIME = 3000;
28
+ private static final int ASYNC_SLEEP_TIME_LIMIT = 900_000;
28
29
 
29
30
  private final PluginTask pluginTask;
30
31
 
@@ -35,34 +36,69 @@ public class Client
35
36
 
36
37
  public List<AdsInsights> getInsights(boolean isPaginationValid) throws APIException, InterruptedException
37
38
  {
38
- AdReportRun adReportRun;
39
- switch (pluginTask.getObjectType()) {
40
- case ACCOUNT: {
41
- adReportRun = getAdAccountInsights();
42
- break;
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
- case CAMPAIGN: {
45
- adReportRun = getCampaignInsights();
46
- break;
47
- }
48
- case ADSET: {
49
- adReportRun = getAdSetInsights();
50
- break;
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 (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
- case AD: {
53
- adReportRun = getAdInsights();
54
- break;
85
+ catch (RuntimeException e) {
86
+ if (jobStatus.equals("failed")) {
87
+ continue;
88
+ }
89
+ throw new APIException(e);
55
90
  }
56
- default: throw new IllegalArgumentException();
57
91
  }
58
- while (adReportRun.fetch().getFieldAsyncPercentCompletion() != 100) {
59
- Thread.sleep(ASYNC_SLEEP_TIME);
92
+ if (adReportRun == null || adReportRun.getFieldAsyncPercentCompletion() != 100) {
93
+ throw new APIException();
60
94
  }
95
+ logger.info(adReportRun.getRawResponse());
96
+
61
97
  // extra waiting
62
98
  int retryCount = 0;
63
99
  boolean succeeded = false;
64
100
  APINodeList<AdsInsights> adsInsights = null;
65
- while (retryCount < pluginTask.getMaxWeightSeconds() && !succeeded) {
101
+ while (retryCount < pluginTask.getMaxWaitSeconds() && !succeeded) {
66
102
  try {
67
103
  Thread.sleep(1000);
68
104
  adsInsights = adReportRun.getInsights().execute();
@@ -84,5 +84,5 @@ public interface PluginTask extends Task
84
84
 
85
85
  @Config("max_wait_seconds")
86
86
  @ConfigDefault("60")
87
- public Integer getMaxWeightSeconds();
87
+ public Integer getMaxWaitSeconds();
88
88
  }
@@ -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.VALUE_LIFETIME);
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.6
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - naotaka nakane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-29 00:00:00.000000000 Z
11
+ date: 2021-06-08 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/embulk-input-facebook_ads_insights-0.1.6.jar
54
- - classpath/facebook-java-business-sdk-8.0.2.jar
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.11.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