embulk-input-facebook_ads_insights 0.1.1 → 0.1.6

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: 25294378cb92ec04eb4597bc4cf5bd88b42d0636
4
- data.tar.gz: cd464ac63c44f3ada5fcd35ddb8efdf589a32e15
3
+ metadata.gz: b9ef0353a04d37cbbf4f88b5248044c2735621bf
4
+ data.tar.gz: 245b4b5eb6452b904e9b7b6a9cd3ef59e3766b0c
5
5
  SHA512:
6
- metadata.gz: b6c7466198ac7be783d6ec4b3cec622e21ca544f7abbd4753a396ddb59ce6789ce66d65a699e20709efb4d85a9043208274c5c434b981617fd6f8a3beb759cfa
7
- data.tar.gz: 2351afd4f9099f36342757758c10ef45bc89dbbb13f336007d1b571b11191ed36f27b5dec8c44dcd21dc2c78bf52babfb5e22ebfb4f41e4e0c59eef69be7c641
6
+ metadata.gz: e231d047ae94fb6d2ed28c2b63ee873430bec9534278041990bafea8fcc622acd97300583e48d9dda6dd000182575791abb7b5caa5a61e3fe0de53c57ecb1b62
7
+ data.tar.gz: 857a30dbabfe73e0f952f7bde8a5a3b2d3700b058b477358e594ecbf37dd73925100b8cbc0bf7b51070174bb2bef151bc1b98b59e5243bca891d94ef1ad8fa4d
data/README.md CHANGED
@@ -29,6 +29,7 @@ Required Embulk version >= 0.9
29
29
  | product_id_limit | no | integer | see [product_id_limit](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
30
30
  | sort | no | array(string) | see [sort](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
31
31
  | time_increment | no | enum{monthly, all_days} or integer(1-90) | see [time_increment](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
32
+ | time_range | no | {since:YYYY-MM-DD, until:YYYY-MM-DD} | see [time_range](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
32
33
  | time_ranges | no | array({since:YYYY-MM-DD, until:YYYY-MM-DD}) | see [time_ranges](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
33
34
  | use_account_attribution_setting | no | boolean | see [use_account_attribution_setting](https://developers.facebook.com/docs/marketing-api/insights/parameters) for details. |
34
35
 
@@ -37,9 +38,9 @@ Required Embulk version >= 0.9
37
38
  | Name | Values |
38
39
  |:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
39
40
  | ObjectEnum | account, campaign, adset, ad |
40
- | FieldEnum | account_currency, account_id, account_name, action_values, actions, ad_id, ad_name, adset_id, adset_name, app_store_clicks, buying_type, campaign_id, campaign_name, canvas_avg_view_percent, canvas_avg_view_time, clicks, conversion_rate_ranking, conversion_values, conversions, cost_per_10_sec_video_view, cost_per_action_type, cost_per_conversion, cost_per_estimated_ad_recallers, cost_per_inline_link_click, cost_per_inline_post_engagement, cost_per_outbound_click, cost_per_thruplay, cost_per_unique_action_type, cost_per_unique_click, cost_per_unique_inline_link_click, cost_per_unique_outbound_click, cpc, cpm, cpp, ctr, date_start, date_stop, deeplink_clicks, engagement_rate_ranking, estimated_ad_recall_rate, estimated_ad_recallers, frequency, full_view_impressions, full_view_reach, impressions, inline_link_click_ctr, inline_link_clicks, inline_post_engagement, instant_experience_clicks_to_open, instant_experience_clicks_to_start, instant_experience_outbound_clicks, mobile_app_purchase_roas, newsfeed_avg_position, newsfeed_clicks, newsfeed_impressions, objective, outbound_clicks, outbound_clicks_ctr, purchase_roas, quality_ranking, reach, relevance_score, social_spend, spend, unique_actions, unique_clicks, unique_ctr, unique_impressions, unique_inline_link_click_ctr, unique_inline_link_clicks, unique_link_clicks_ctr, unique_outbound_clicks, unique_outbound_clicks_ctr, video_10_sec_watched_actions, video_30_sec_watched_actions, video_avg_time_watched_actions, video_complete_watched_actions, video_p100_watched_actions, video_p25_watched_actions, video_p50_watched_actions, video_p75_watched_actions, video_play_actions, video_thruplay_watched_actions, website_clicks, website_ctr, website_purchase_roas |
41
+ | FieldEnum | account_currency, account_id, account_name, action_values, actions, ad_bid_type, ad_bid_value, ad_click_actions, ad_delivery, ad_id, ad_impression_actions, ad_name, adset_bid_type, adset_bid_value, adset_budget_type, adset_budget_value, adset_delivery, adset_end, adset_id, adset_name, adset_start, age_targeting, auction_bid, auction_competitiveness, auction_max_competitor_bid, buying_type, campaign_id, campaign_name, canvas_avg_view_percent, canvas_avg_view_time, clicks, conversion_rate_ranking, conversion_values, conversions, cost_per_15_sec_video_view, cost_per_2_sec_continuous_video_view, cost_per_action_type, cost_per_ad_click, cost_per_conversion, cost_per_dda_countby_convs, cost_per_estimated_ad_recallers, cost_per_inline_link_click, cost_per_inline_post_engagement, cost_per_one_thousand_ad_impression, cost_per_outbound_click, cost_per_store_visit_action, cost_per_thruplay, cost_per_unique_action_type, cost_per_unique_click, cost_per_unique_conversion, cost_per_unique_inline_link_click, cost_per_unique_outbound_click, cpc, cpm, cpp, created_time, ctr, date_start, date_stop, dda_countby_convs, engagement_rate_ranking, estimated_ad_recall_rate, estimated_ad_recall_rate_lower_bound, estimated_ad_recall_rate_upper_bound, estimated_ad_recallers, estimated_ad_recallers_lower_bound, estimated_ad_recallers_upper_bound, frequency, full_view_impressions, full_view_reach, gender_targeting, impressions, inline_link_click_ctr, inline_link_clicks, inline_post_engagement, instant_experience_clicks_to_open, instant_experience_clicks_to_start, instant_experience_outbound_clicks, labels, location, mobile_app_purchase_roas, objective, outbound_clicks, outbound_clicks_ctr, place_page_name, purchase_roas, quality_ranking, quality_score_ectr, quality_score_ecvr, quality_score_organic, reach, social_spend, spend, store_visit_actions, unique_actions, unique_clicks, unique_conversions, unique_ctr, unique_inline_link_click_ctr, unique_inline_link_clicks, unique_link_clicks_ctr, unique_outbound_clicks, unique_outbound_clicks_ctr, unique_video_continuous_2_sec_watched_actions, unique_video_view_15_sec, updated_time, video_15_sec_watched_actions, video_30_sec_watched_actions, video_avg_time_watched_actions, video_continuous_2_sec_watched_actions, video_p100_watched_actions, video_p25_watched_actions, video_p50_watched_actions, video_p75_watched_actions, video_p95_watched_actions, video_play_actions, video_thruplay_watched_actions, video_time_watched_actions, website_ctr, website_purchase_roas, wish_bid |
41
42
  | ActionAttributionWindowEnum | 1d_view, 7d_view, 28d_view, 1d_click, 7d_click, 28d_click, default |
42
- | ActionBreakdownEnum | action_converted_product_id, 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 |
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 |
43
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 |
44
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
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} |
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.1"
16
+ version = "0.1.6"
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: "4.0.5"
24
+ compile group: "com.facebook.business.sdk", name: "facebook-java-business-sdk", version: "8.0.2"
25
25
  // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
26
26
  testCompile "junit:junit:4.+"
27
27
  }
@@ -29,11 +29,26 @@ public class AdsInsightsAccessor
29
29
  case "account_name": return adsInsights.getFieldAccountName();
30
30
  case "action_values": return actionsToString(adsInsights.getFieldActionValues());
31
31
  case "actions": return actionsToString(adsInsights.getFieldActions());
32
+ case "ad_bid_type": return adsInsights.getFieldAdBidType();
33
+ case "ad_bid_value": return adsInsights.getFieldAdBidValue();
34
+ case "ad_click_actions": return actionsToString(adsInsights.getFieldAdClickActions());
35
+ case "ad_delivery": return adsInsights.getFieldAdDelivery();
32
36
  case "ad_id": return adsInsights.getFieldAdId();
37
+ case "ad_impression_actions": return actionsToString(adsInsights.getFieldAdImpressionActions());
33
38
  case "ad_name": return adsInsights.getFieldAdName();
39
+ case "adset_bid_type": return adsInsights.getFieldAdsetBidType();
40
+ case "adset_bid_value": return adsInsights.getFieldAdsetBidValue();
41
+ case "adset_budget_type": return adsInsights.getFieldAdsetBudgetType();
42
+ case "adset_budget_value": return adsInsights.getFieldAdsetBudgetValue();
43
+ case "adset_delivery": return adsInsights.getFieldAdsetDelivery();
44
+ case "adset_end": return adsInsights.getFieldAdsetEnd();
34
45
  case "adset_id": return adsInsights.getFieldAdsetId();
35
46
  case "adset_name": return adsInsights.getFieldAdsetName();
36
- case "app_store_clicks": return adsInsights.getFieldAppStoreClicks();
47
+ case "adset_start": return adsInsights.getFieldAdsetStart();
48
+ case "age_targeting": return adsInsights.getFieldAgeTargeting();
49
+ case "auction_bid": return adsInsights.getFieldAuctionBid();
50
+ case "auction_competitiveness": return adsInsights.getFieldAuctionCompetitiveness();
51
+ case "auction_max_competitor_bid": return adsInsights.getFieldAuctionMaxCompetitorBid();
37
52
  case "buying_type": return adsInsights.getFieldBuyingType();
38
53
  case "campaign_id": return adsInsights.getFieldCampaignId();
39
54
  case "campaign_name": return adsInsights.getFieldCampaignName();
@@ -43,31 +58,43 @@ public class AdsInsightsAccessor
43
58
  case "conversion_rate_ranking": return adsInsights.getFieldConversionRateRanking();
44
59
  case "conversion_values": return actionsToString(adsInsights.getFieldConversionValues());
45
60
  case "conversions": return actionsToString(adsInsights.getFieldConversions());
46
- case "cost_per_10_sec_video_view": return actionsToString(adsInsights.getFieldCostPer10SecVideoView());
61
+ case "cost_per_15_sec_video_view": return actionsToString(adsInsights.getFieldCostPer15SecVideoView());
62
+ case "cost_per_2_sec_continuous_video_view": return actionsToString(adsInsights.getFieldCostPer2SecContinuousVideoView());
47
63
  case "cost_per_action_type": return actionsToString(adsInsights.getFieldCostPerActionType());
64
+ case "cost_per_ad_click": return actionsToString(adsInsights.getFieldCostPerAdClick());
48
65
  case "cost_per_conversion": return actionsToString(adsInsights.getFieldCostPerConversion());
66
+ case "cost_per_dda_countby_convs": return adsInsights.getFieldCostPerDdaCountbyConvs();
49
67
  case "cost_per_estimated_ad_recallers": return adsInsights.getFieldCostPerEstimatedAdRecallers();
50
68
  case "cost_per_inline_link_click": return adsInsights.getFieldCostPerInlineLinkClick();
51
69
  case "cost_per_inline_post_engagement": return adsInsights.getFieldCostPerInlinePostEngagement();
70
+ case "cost_per_one_thousand_ad_impression": return actionsToString(adsInsights.getFieldCostPerOneThousandAdImpression());
52
71
  case "cost_per_outbound_click": return actionsToString(adsInsights.getFieldCostPerOutboundClick());
72
+ case "cost_per_store_visit_action": return actionsToString(adsInsights.getFieldCostPerStoreVisitAction());
53
73
  case "cost_per_thruplay": return actionsToString(adsInsights.getFieldCostPerThruplay());
54
74
  case "cost_per_unique_action_type": return actionsToString(adsInsights.getFieldCostPerUniqueActionType());
55
75
  case "cost_per_unique_click": return adsInsights.getFieldCostPerUniqueClick();
76
+ case "cost_per_unique_conversion": return actionsToString(adsInsights.getFieldCostPerUniqueConversion());
56
77
  case "cost_per_unique_inline_link_click": return adsInsights.getFieldCostPerUniqueInlineLinkClick();
57
78
  case "cost_per_unique_outbound_click": return actionsToString(adsInsights.getFieldCostPerUniqueOutboundClick());
58
79
  case "cpc": return adsInsights.getFieldCpc();
59
80
  case "cpm": return adsInsights.getFieldCpm();
60
81
  case "cpp": return adsInsights.getFieldCpp();
82
+ case "created_time": return adsInsights.getFieldCreatedTime();
61
83
  case "ctr": return adsInsights.getFieldCtr();
62
84
  case "date_start": return adsInsights.getFieldDateStart();
63
85
  case "date_stop": return adsInsights.getFieldDateStop();
64
- case "deeplink_clicks": return adsInsights.getFieldDeeplinkClicks();
86
+ case "dda_countby_convs": return adsInsights.getFieldDdaCountbyConvs();
65
87
  case "engagement_rate_ranking": return adsInsights.getFieldEngagementRateRanking();
66
88
  case "estimated_ad_recall_rate": return adsInsights.getFieldEstimatedAdRecallRate();
89
+ case "estimated_ad_recall_rate_lower_bound": return adsInsights.getFieldEstimatedAdRecallRateLowerBound();
90
+ case "estimated_ad_recall_rate_upper_bound": return adsInsights.getFieldEstimatedAdRecallRateUpperBound();
67
91
  case "estimated_ad_recallers": return adsInsights.getFieldEstimatedAdRecallers();
92
+ case "estimated_ad_recallers_lower_bound": return adsInsights.getFieldEstimatedAdRecallersLowerBound();
93
+ case "estimated_ad_recallers_upper_bound": return adsInsights.getFieldEstimatedAdRecallersUpperBound();
68
94
  case "frequency": return adsInsights.getFieldFrequency();
69
95
  case "full_view_impressions": return adsInsights.getFieldFullViewImpressions();
70
96
  case "full_view_reach": return adsInsights.getFieldFullViewReach();
97
+ case "gender_targeting": return adsInsights.getFieldGenderTargeting();
71
98
  case "impressions": return adsInsights.getFieldImpressions();
72
99
  case "inline_link_click_ctr": return adsInsights.getFieldInlineLinkClickCtr();
73
100
  case "inline_link_clicks": return adsInsights.getFieldInlineLinkClicks();
@@ -75,41 +102,49 @@ public class AdsInsightsAccessor
75
102
  case "instant_experience_clicks_to_open": return adsInsights.getFieldInstantExperienceClicksToOpen();
76
103
  case "instant_experience_clicks_to_start": return adsInsights.getFieldInstantExperienceClicksToStart();
77
104
  case "instant_experience_outbound_clicks": return adsInsights.getFieldInstantExperienceOutboundClicks();
105
+ case "labels": return adsInsights.getFieldLabels();
106
+ case "location": return adsInsights.getFieldLocation();
78
107
  case "mobile_app_purchase_roas": return actionsToString(adsInsights.getFieldMobileAppPurchaseRoas());
79
- case "newsfeed_avg_position": return adsInsights.getFieldNewsfeedAvgPosition();
80
- case "newsfeed_clicks": return adsInsights.getFieldNewsfeedClicks();
81
- case "newsfeed_impressions": return adsInsights.getFieldNewsfeedImpressions();
82
108
  case "objective": return adsInsights.getFieldObjective();
83
109
  case "outbound_clicks": return actionsToString(adsInsights.getFieldOutboundClicks());
84
110
  case "outbound_clicks_ctr": return actionsToString(adsInsights.getFieldOutboundClicksCtr());
111
+ case "place_page_name": return adsInsights.getFieldPlacePageName();
85
112
  case "purchase_roas": return actionsToString(adsInsights.getFieldPurchaseRoas());
86
113
  case "quality_ranking": return adsInsights.getFieldQualityRanking();
114
+ case "quality_score_ectr": return adsInsights.getFieldQualityScoreEctr();
115
+ case "quality_score_ecvr": return adsInsights.getFieldQualityScoreEcvr();
116
+ case "quality_score_organic": return adsInsights.getFieldQualityScoreOrganic();
87
117
  case "reach": return adsInsights.getFieldReach();
88
- case "relevance_score": return adsInsights.getFieldRelevanceScore().toString();
89
118
  case "social_spend": return adsInsights.getFieldSocialSpend();
90
119
  case "spend": return adsInsights.getFieldSpend();
120
+ case "store_visit_actions": return actionsToString(adsInsights.getFieldStoreVisitActions());
91
121
  case "unique_actions": return actionsToString(adsInsights.getFieldUniqueActions());
92
122
  case "unique_clicks": return adsInsights.getFieldUniqueClicks();
123
+ case "unique_conversions": return actionsToString(adsInsights.getFieldUniqueConversions());
93
124
  case "unique_ctr": return adsInsights.getFieldUniqueCtr();
94
- case "unique_impressions": return adsInsights.getFieldUniqueImpressions();
95
125
  case "unique_inline_link_click_ctr": return adsInsights.getFieldUniqueInlineLinkClickCtr();
96
126
  case "unique_inline_link_clicks": return adsInsights.getFieldUniqueInlineLinkClicks();
97
127
  case "unique_link_clicks_ctr": return adsInsights.getFieldUniqueLinkClicksCtr();
98
128
  case "unique_outbound_clicks": return actionsToString(adsInsights.getFieldUniqueOutboundClicks());
99
129
  case "unique_outbound_clicks_ctr": return actionsToString(adsInsights.getFieldUniqueOutboundClicksCtr());
100
- case "video_10_sec_watched_actions": return actionsToString(adsInsights.getFieldVideo10SecWatchedActions());
130
+ case "unique_video_continuous_2_sec_watched_actions": return actionsToString(adsInsights.getFieldUniqueVideoContinuous2SecWatchedActions());
131
+ case "unique_video_view_15_sec": return actionsToString(adsInsights.getFieldUniqueVideoView15Sec());
132
+ case "updated_time": return adsInsights.getFieldUpdatedTime();
133
+ case "video_15_sec_watched_actions": return actionsToString(adsInsights.getFieldVideo15SecWatchedActions());
101
134
  case "video_30_sec_watched_actions": return actionsToString(adsInsights.getFieldVideo30SecWatchedActions());
102
135
  case "video_avg_time_watched_actions": return actionsToString(adsInsights.getFieldVideoAvgTimeWatchedActions());
103
- case "video_complete_watched_actions": return actionsToString(adsInsights.getFieldVideoCompleteWatchedActions());
136
+ case "video_continuous_2_sec_watched_actions": return actionsToString(adsInsights.getFieldVideoContinuous2SecWatchedActions());
104
137
  case "video_p100_watched_actions": return actionsToString(adsInsights.getFieldVideoP100WatchedActions());
105
138
  case "video_p25_watched_actions": return actionsToString(adsInsights.getFieldVideoP25WatchedActions());
106
139
  case "video_p50_watched_actions": return actionsToString(adsInsights.getFieldVideoP50WatchedActions());
107
140
  case "video_p75_watched_actions": return actionsToString(adsInsights.getFieldVideoP75WatchedActions());
141
+ case "video_p95_watched_actions": return actionsToString(adsInsights.getFieldVideoP95WatchedActions());
108
142
  case "video_play_actions": return actionsToString(adsInsights.getFieldVideoPlayActions());
109
143
  case "video_thruplay_watched_actions": return actionsToString(adsInsights.getFieldVideoThruplayWatchedActions());
110
- case "website_clicks": return adsInsights.getFieldWebsiteClicks();
144
+ case "video_time_watched_actions": return actionsToString(adsInsights.getFieldVideoTimeWatchedActions());
111
145
  case "website_ctr": return actionsToString(adsInsights.getFieldWebsiteCtr());
112
146
  case "website_purchase_roas": return actionsToString(adsInsights.getFieldWebsitePurchaseRoas());
147
+ case "wish_bid": return adsInsights.getFieldWishBid();
113
148
  // breakdowns
114
149
  case "ad_format_asset": return extractBreakdown("ad_format_asset");
115
150
  case "age": return extractBreakdown("age");
@@ -16,7 +16,9 @@ import org.embulk.spi.ColumnConfig;
16
16
  import org.slf4j.Logger;
17
17
  import org.slf4j.LoggerFactory;
18
18
 
19
+ import java.util.ArrayList;
19
20
  import java.util.List;
21
+ import java.util.Objects;
20
22
  import java.util.stream.Collectors;
21
23
 
22
24
  public class Client
@@ -31,7 +33,7 @@ public class Client
31
33
  this.pluginTask = pluginTask;
32
34
  }
33
35
 
34
- public APINodeList<AdsInsights> getInsights() throws APIException, InterruptedException
36
+ public List<AdsInsights> getInsights(boolean isPaginationValid) throws APIException, InterruptedException
35
37
  {
36
38
  AdReportRun adReportRun;
37
39
  switch (pluginTask.getObjectType()) {
@@ -56,7 +58,24 @@ public class Client
56
58
  while (adReportRun.fetch().getFieldAsyncPercentCompletion() != 100) {
57
59
  Thread.sleep(ASYNC_SLEEP_TIME);
58
60
  }
59
- return adReportRun.getInsights().execute();
61
+ // extra waiting
62
+ int retryCount = 0;
63
+ boolean succeeded = false;
64
+ APINodeList<AdsInsights> adsInsights = null;
65
+ while (retryCount < pluginTask.getMaxWeightSeconds() && !succeeded) {
66
+ try {
67
+ Thread.sleep(1000);
68
+ adsInsights = adReportRun.getInsights().execute();
69
+ succeeded = true;
70
+ }
71
+ catch (APIException e) {
72
+ retryCount++;
73
+ }
74
+ }
75
+ if (Objects.isNull(adsInsights)) {
76
+ throw new APIException();
77
+ }
78
+ return isPaginationValid ? fetchAllPage(adsInsights) : adsInsights;
60
79
  }
61
80
 
62
81
  // TODO: plz make me dry
@@ -94,6 +113,9 @@ public class Client
94
113
  if (pluginTask.getTimeIncrement().isPresent()) {
95
114
  request.setTimeIncrement(pluginTask.getTimeIncrement().get());
96
115
  }
116
+ if (pluginTask.getTimeRange().isPresent()) {
117
+ request.setTimeRange(Util.stringifyToStringMap(pluginTask.getTimeRange().get()));
118
+ }
97
119
  if (pluginTask.getTimeRanges().isPresent()) {
98
120
  request.setTimeRanges(Util.stringifyToStringMaps(pluginTask.getTimeRanges().get()));
99
121
  }
@@ -137,6 +159,9 @@ public class Client
137
159
  if (pluginTask.getTimeIncrement().isPresent()) {
138
160
  request.setTimeIncrement(pluginTask.getTimeIncrement().get());
139
161
  }
162
+ if (pluginTask.getTimeRange().isPresent()) {
163
+ request.setTimeRange(Util.stringifyToStringMap(pluginTask.getTimeRange().get()));
164
+ }
140
165
  if (pluginTask.getTimeRanges().isPresent()) {
141
166
  request.setTimeRanges(Util.stringifyToStringMaps(pluginTask.getTimeRanges().get()));
142
167
  }
@@ -180,6 +205,9 @@ public class Client
180
205
  if (pluginTask.getTimeIncrement().isPresent()) {
181
206
  request.setTimeIncrement(pluginTask.getTimeIncrement().get());
182
207
  }
208
+ if (pluginTask.getTimeRange().isPresent()) {
209
+ request.setTimeRange(Util.stringifyToStringMap(pluginTask.getTimeRange().get()));
210
+ }
183
211
  if (pluginTask.getTimeRanges().isPresent()) {
184
212
  request.setTimeRanges(Util.stringifyToStringMaps(pluginTask.getTimeRanges().get()));
185
213
  }
@@ -223,6 +251,9 @@ public class Client
223
251
  if (pluginTask.getTimeIncrement().isPresent()) {
224
252
  request.setTimeIncrement(pluginTask.getTimeIncrement().get());
225
253
  }
254
+ if (pluginTask.getTimeRange().isPresent()) {
255
+ request.setTimeRange(Util.stringifyToStringMap(pluginTask.getTimeRange().get()));
256
+ }
226
257
  if (pluginTask.getTimeRanges().isPresent()) {
227
258
  request.setTimeRanges(Util.stringifyToStringMaps(pluginTask.getTimeRanges().get()));
228
259
  }
@@ -232,6 +263,17 @@ public class Client
232
263
  return request.execute();
233
264
  }
234
265
 
266
+ private List<AdsInsights> fetchAllPage(APINodeList<AdsInsights> adsInsights) throws APIException
267
+ {
268
+ List<AdsInsights> result = new ArrayList<>();
269
+ APINodeList<AdsInsights> next = adsInsights;
270
+ while (!next.isEmpty()) {
271
+ result.addAll(next);
272
+ next = next.nextPage();
273
+ }
274
+ return result;
275
+ }
276
+
235
277
  private APIContext apiContext()
236
278
  {
237
279
  return new APIContext(pluginTask.getAccessToken());
@@ -56,7 +56,7 @@ public class FacebookAdsInsightsInputPlugin
56
56
  try {
57
57
  try (PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
58
58
  Client client = new Client(task);
59
- List<AdsInsights> insights = client.getInsights();
59
+ List<AdsInsights> insights = client.getInsights(!Exec.isPreview());
60
60
  for (AdsInsights insight : insights) {
61
61
  schema.visitColumns(new FacebookAdsInsightsColumnVisitor(insight, pageBuilder, task));
62
62
  pageBuilder.addRecord();
@@ -70,6 +70,10 @@ public interface PluginTask extends Task
70
70
  @ConfigDefault("null")
71
71
  public Optional<String> getTimeIncrement();
72
72
 
73
+ @Config("time_range")
74
+ @ConfigDefault("null")
75
+ public Optional<ToStringMap> getTimeRange();
76
+
73
77
  @Config("time_ranges")
74
78
  @ConfigDefault("null")
75
79
  public Optional<List<ToStringMap>> getTimeRanges();
@@ -77,4 +81,8 @@ public interface PluginTask extends Task
77
81
  @Config("use_account_attribution_setting")
78
82
  @ConfigDefault("null")
79
83
  public Optional<Boolean> getUseAccountAttributionSetting();
84
+
85
+ @Config("max_wait_seconds")
86
+ @ConfigDefault("60")
87
+ public Integer getMaxWeightSeconds();
80
88
  }
@@ -15,4 +15,9 @@ public class Util
15
15
  Gson gson = new Gson();
16
16
  return "[" + value.stream().map(gson::toJson).collect(Collectors.joining(",")) + "]";
17
17
  }
18
+ public static String stringifyToStringMap(ToStringMap value)
19
+ {
20
+ Gson gson = new Gson();
21
+ return gson.toJson(value);
22
+ }
18
23
  }
@@ -25,7 +25,6 @@ public class ActionBreakdown
25
25
  public static ActionBreakdown fromString(final String value)
26
26
  {
27
27
  switch (value) {
28
- case "action_converted_product_id": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CONVERTED_PRODUCT_ID);
29
28
  case "action_device": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_DEVICE);
30
29
  case "action_canvas_component_name": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CANVAS_COMPONENT_NAME);
31
30
  case "action_carousel_card_id": return new ActionBreakdown(AdsInsights.EnumActionBreakdowns.VALUE_ACTION_CAROUSEL_CARD_ID);
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.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - naotaka nakane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -50,12 +50,12 @@ 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.1.jar
54
- - classpath/facebook-java-business-sdk-4.0.5.jar
53
+ - classpath/embulk-input-facebook_ads_insights-0.1.6.jar
54
+ - classpath/facebook-java-business-sdk-8.0.2.jar
55
55
  - classpath/gson-2.5.jar
56
56
  - classpath/guava-20.0.jar
57
- - classpath/kotlin-stdlib-1.3.0.jar
58
- - classpath/kotlin-stdlib-common-1.3.0.jar
57
+ - classpath/kotlin-stdlib-1.2.60.jar
58
+ - classpath/kotlin-stdlib-common-1.2.60.jar
59
59
  - classpath/okhttp-3.9.1.jar
60
60
  - classpath/okio-2.1.0.jar
61
61
  - config/checkstyle/checkstyle.xml