twitter-ads 5.2.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -2
- data/README.md +1 -1
- data/lib/twitter-ads.rb +8 -4
- data/lib/twitter-ads/account.rb +6 -24
- data/lib/twitter-ads/audiences/tailored_audience.rb +56 -1
- data/lib/twitter-ads/{targeting_criteria/behavior_taxonomy.rb → campaign/advertiser_business_categories.rb} +6 -6
- data/lib/twitter-ads/campaign/campaign.rb +1 -2
- data/lib/twitter-ads/campaign/content_categories.rb +23 -0
- data/lib/twitter-ads/campaign/funding_instrument.rb +1 -2
- data/lib/twitter-ads/campaign/line_item.rb +4 -4
- data/lib/twitter-ads/campaign/organic_tweet.rb +1 -3
- data/lib/twitter-ads/campaign/targeting_criteria.rb +1 -1
- data/lib/twitter-ads/campaign/tweet.rb +4 -49
- data/lib/twitter-ads/client.rb +2 -2
- data/lib/twitter-ads/creative/account_media.rb +4 -6
- data/lib/twitter-ads/creative/draft_tweet.rb +40 -0
- data/lib/twitter-ads/creative/image_app_download_card.rb +2 -2
- data/lib/twitter-ads/creative/image_conversation_card.rb +3 -2
- data/lib/twitter-ads/creative/media_creative.rb +2 -3
- data/lib/twitter-ads/creative/media_library.rb +12 -13
- data/lib/twitter-ads/creative/promoted_account.rb +1 -2
- data/lib/twitter-ads/creative/promoted_tweet.rb +2 -3
- data/lib/twitter-ads/creative/scheduled_tweet.rb +1 -12
- data/lib/twitter-ads/creative/tweets.rb +52 -0
- data/lib/twitter-ads/creative/video_app_download_card.rb +4 -6
- data/lib/twitter-ads/creative/video_conversation_card.rb +6 -6
- data/lib/twitter-ads/creative/video_website_card.rb +3 -5
- data/lib/twitter-ads/creative/website_card.rb +2 -2
- data/lib/twitter-ads/cursor.rb +6 -0
- data/lib/twitter-ads/enum.rb +22 -13
- data/lib/twitter-ads/error.rb +5 -15
- data/lib/twitter-ads/http/request.rb +37 -2
- data/lib/twitter-ads/http/response.rb +1 -13
- data/lib/twitter-ads/resources/analytics.rb +99 -47
- data/lib/twitter-ads/resources/dsl.rb +8 -1
- data/lib/twitter-ads/restapi.rb +29 -0
- data/lib/twitter-ads/settings/tax.rb +13 -1
- data/lib/twitter-ads/targeting/audience_summary.rb +47 -0
- data/lib/twitter-ads/targeting_criteria/{behavior.rb → conversation.rb} +3 -7
- data/lib/twitter-ads/targeting_criteria/event.rb +1 -0
- data/lib/twitter-ads/utils.rb +23 -0
- data/lib/twitter-ads/version.rb +1 -1
- data/spec/fixtures/audience_summary.json +14 -0
- data/spec/fixtures/line_items_all.json +2 -10
- data/spec/fixtures/line_items_load.json +0 -1
- data/spec/fixtures/tailored_audiences_all.json +3 -0
- data/spec/fixtures/targeted_audiences.json +33 -0
- data/spec/fixtures/tweet_previews.json +23 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/twitter-ads/audiences/tailored_audience_spec.rb +25 -2
- data/spec/twitter-ads/campaign/line_item_spec.rb +0 -1
- data/spec/twitter-ads/campaign/targeting_criteria_spec.rb +1 -1
- data/spec/twitter-ads/campaign/tweet_spec.rb +0 -59
- data/spec/twitter-ads/client_spec.rb +17 -1
- data/spec/twitter-ads/creative/media_creative_spec.rb +1 -1
- data/spec/twitter-ads/creative/promoted_tweet_spec.rb +18 -0
- data/spec/twitter-ads/creative/tweet_previews_spec.rb +41 -0
- data/spec/twitter-ads/rate_limit_spec.rb +247 -0
- data/spec/twitter-ads/retry_count_spec.rb +61 -0
- data/spec/twitter-ads/{creative/image_app_download_card_spec.rb → targeting/audience_summary_spec.rb} +16 -18
- metadata +50 -49
- data/lib/twitter-ads/audiences/audience_intelligence.rb +0 -68
- data/lib/twitter-ads/targeting/reach_estimate.rb +0 -78
- data/spec/fixtures/tweet_preview.json +0 -24
- data/spec/twitter-ads/campaign/reach_estimate_spec.rb +0 -103
- data/spec/twitter-ads/creative/account_media_spec.rb +0 -32
- data/spec/twitter-ads/creative/image_conversation_card_spec.rb +0 -40
- data/spec/twitter-ads/creative/video_app_download_card_spec.rb +0 -42
- data/spec/twitter-ads/creative/video_conversation_card_spec.rb +0 -51
- data/spec/twitter-ads/creative/website_card_spec.rb +0 -42
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-ads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Babich
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: multi_json
|
@@ -57,10 +57,11 @@ files:
|
|
57
57
|
- bin/twitter-ads
|
58
58
|
- lib/twitter-ads.rb
|
59
59
|
- lib/twitter-ads/account.rb
|
60
|
-
- lib/twitter-ads/audiences/audience_intelligence.rb
|
61
60
|
- lib/twitter-ads/audiences/tailored_audience.rb
|
61
|
+
- lib/twitter-ads/campaign/advertiser_business_categories.rb
|
62
62
|
- lib/twitter-ads/campaign/app_list.rb
|
63
63
|
- lib/twitter-ads/campaign/campaign.rb
|
64
|
+
- lib/twitter-ads/campaign/content_categories.rb
|
64
65
|
- lib/twitter-ads/campaign/funding_instrument.rb
|
65
66
|
- lib/twitter-ads/campaign/iab_category.rb
|
66
67
|
- lib/twitter-ads/campaign/line_item.rb
|
@@ -71,6 +72,7 @@ files:
|
|
71
72
|
- lib/twitter-ads/client.rb
|
72
73
|
- lib/twitter-ads/creative/account_media.rb
|
73
74
|
- lib/twitter-ads/creative/cards_fetch.rb
|
75
|
+
- lib/twitter-ads/creative/draft_tweet.rb
|
74
76
|
- lib/twitter-ads/creative/image_app_download_card.rb
|
75
77
|
- lib/twitter-ads/creative/image_conversation_card.rb
|
76
78
|
- lib/twitter-ads/creative/media_creative.rb
|
@@ -80,6 +82,7 @@ files:
|
|
80
82
|
- lib/twitter-ads/creative/promoted_tweet.rb
|
81
83
|
- lib/twitter-ads/creative/scheduled_tweet.rb
|
82
84
|
- lib/twitter-ads/creative/tweet_previews.rb
|
85
|
+
- lib/twitter-ads/creative/tweets.rb
|
83
86
|
- lib/twitter-ads/creative/video_app_download_card.rb
|
84
87
|
- lib/twitter-ads/creative/video_conversation_card.rb
|
85
88
|
- lib/twitter-ads/creative/video_website_card.rb
|
@@ -97,12 +100,12 @@ files:
|
|
97
100
|
- lib/twitter-ads/resources/dsl.rb
|
98
101
|
- lib/twitter-ads/resources/persistence.rb
|
99
102
|
- lib/twitter-ads/resources/resource.rb
|
103
|
+
- lib/twitter-ads/restapi.rb
|
100
104
|
- lib/twitter-ads/settings/tax.rb
|
101
105
|
- lib/twitter-ads/settings/user.rb
|
102
|
-
- lib/twitter-ads/targeting/
|
106
|
+
- lib/twitter-ads/targeting/audience_summary.rb
|
103
107
|
- lib/twitter-ads/targeting_criteria/app_store_category.rb
|
104
|
-
- lib/twitter-ads/targeting_criteria/
|
105
|
-
- lib/twitter-ads/targeting_criteria/behavior_taxonomy.rb
|
108
|
+
- lib/twitter-ads/targeting_criteria/conversation.rb
|
106
109
|
- lib/twitter-ads/targeting_criteria/device.rb
|
107
110
|
- lib/twitter-ads/targeting_criteria/event.rb
|
108
111
|
- lib/twitter-ads/targeting_criteria/interest.rb
|
@@ -120,6 +123,7 @@ files:
|
|
120
123
|
- spec/fixtures/accounts_load.json
|
121
124
|
- spec/fixtures/app_lists_all.json
|
122
125
|
- spec/fixtures/app_lists_load.json
|
126
|
+
- spec/fixtures/audience_summary.json
|
123
127
|
- spec/fixtures/campaigns_all.json
|
124
128
|
- spec/fixtures/campaigns_load.json
|
125
129
|
- spec/fixtures/funding_instruments_all.json
|
@@ -135,7 +139,8 @@ files:
|
|
135
139
|
- spec/fixtures/reach_estimate.json
|
136
140
|
- spec/fixtures/tailored_audiences_all.json
|
137
141
|
- spec/fixtures/tailored_audiences_load.json
|
138
|
-
- spec/fixtures/
|
142
|
+
- spec/fixtures/targeted_audiences.json
|
143
|
+
- spec/fixtures/tweet_previews.json
|
139
144
|
- spec/fixtures/videos_all.json
|
140
145
|
- spec/fixtures/videos_load.json
|
141
146
|
- spec/quality_spec.rb
|
@@ -146,21 +151,18 @@ files:
|
|
146
151
|
- spec/twitter-ads/audiences/tailored_audience_spec.rb
|
147
152
|
- spec/twitter-ads/campaign/app_list_spec.rb
|
148
153
|
- spec/twitter-ads/campaign/line_item_spec.rb
|
149
|
-
- spec/twitter-ads/campaign/reach_estimate_spec.rb
|
150
154
|
- spec/twitter-ads/campaign/targeting_criteria_spec.rb
|
151
155
|
- spec/twitter-ads/campaign/tweet_spec.rb
|
152
156
|
- spec/twitter-ads/client_spec.rb
|
153
|
-
- spec/twitter-ads/creative/account_media_spec.rb
|
154
|
-
- spec/twitter-ads/creative/image_app_download_card_spec.rb
|
155
|
-
- spec/twitter-ads/creative/image_conversation_card_spec.rb
|
156
157
|
- spec/twitter-ads/creative/media_creative_spec.rb
|
157
158
|
- spec/twitter-ads/creative/promoted_account_spec.rb
|
158
159
|
- spec/twitter-ads/creative/promoted_tweet_spec.rb
|
159
|
-
- spec/twitter-ads/creative/
|
160
|
-
- spec/twitter-ads/creative/video_conversation_card_spec.rb
|
161
|
-
- spec/twitter-ads/creative/website_card_spec.rb
|
160
|
+
- spec/twitter-ads/creative/tweet_previews_spec.rb
|
162
161
|
- spec/twitter-ads/cursor_spec.rb
|
163
162
|
- spec/twitter-ads/placements_spec.rb
|
163
|
+
- spec/twitter-ads/rate_limit_spec.rb
|
164
|
+
- spec/twitter-ads/retry_count_spec.rb
|
165
|
+
- spec/twitter-ads/targeting/audience_summary_spec.rb
|
164
166
|
- spec/twitter-ads/utils_spec.rb
|
165
167
|
- twitter-ads.gemspec
|
166
168
|
homepage: https://github.com/twitterdev/twitter-ruby-ads-sdk
|
@@ -182,55 +184,54 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
184
|
- !ruby/object:Gem::Version
|
183
185
|
version: 2.6.0
|
184
186
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
187
|
+
rubygems_version: 3.1.4
|
186
188
|
signing_key:
|
187
189
|
specification_version: 4
|
188
190
|
summary: The officially supported Twitter Ads API SDK for Ruby.
|
189
191
|
test_files:
|
190
|
-
- spec/
|
192
|
+
- spec/quality_spec.rb
|
193
|
+
- spec/support/helpers.rb
|
194
|
+
- spec/shared/properties.rb
|
191
195
|
- spec/twitter-ads/audiences/tailored_audience_spec.rb
|
196
|
+
- spec/twitter-ads/creative/promoted_account_spec.rb
|
197
|
+
- spec/twitter-ads/creative/tweet_previews_spec.rb
|
198
|
+
- spec/twitter-ads/creative/media_creative_spec.rb
|
199
|
+
- spec/twitter-ads/creative/promoted_tweet_spec.rb
|
200
|
+
- spec/twitter-ads/rate_limit_spec.rb
|
192
201
|
- spec/twitter-ads/cursor_spec.rb
|
193
|
-
- spec/twitter-ads/account_spec.rb
|
194
|
-
- spec/twitter-ads/client_spec.rb
|
195
202
|
- spec/twitter-ads/placements_spec.rb
|
196
|
-
- spec/twitter-ads/
|
203
|
+
- spec/twitter-ads/client_spec.rb
|
204
|
+
- spec/twitter-ads/account_spec.rb
|
205
|
+
- spec/twitter-ads/targeting/audience_summary_spec.rb
|
206
|
+
- spec/twitter-ads/retry_count_spec.rb
|
207
|
+
- spec/twitter-ads/utils_spec.rb
|
197
208
|
- spec/twitter-ads/campaign/app_list_spec.rb
|
198
|
-
- spec/twitter-ads/campaign/
|
199
|
-
- spec/twitter-ads/campaign/line_item_spec.rb
|
209
|
+
- spec/twitter-ads/campaign/targeting_criteria_spec.rb
|
200
210
|
- spec/twitter-ads/campaign/tweet_spec.rb
|
201
|
-
- spec/twitter-ads/
|
202
|
-
- spec/
|
203
|
-
- spec/
|
204
|
-
- spec/twitter-ads/creative/media_creative_spec.rb
|
205
|
-
- spec/twitter-ads/creative/promoted_tweet_spec.rb
|
206
|
-
- spec/twitter-ads/creative/image_conversation_card_spec.rb
|
207
|
-
- spec/twitter-ads/creative/video_conversation_card_spec.rb
|
208
|
-
- spec/twitter-ads/creative/promoted_account_spec.rb
|
209
|
-
- spec/twitter-ads/creative/image_app_download_card_spec.rb
|
210
|
-
- spec/twitter-ads/utils_spec.rb
|
211
|
-
- spec/shared/properties.rb
|
212
|
-
- spec/support/helpers.rb
|
213
|
-
- spec/fixtures/line_items_load.json
|
214
|
-
- spec/fixtures/promotable_users_all.json
|
215
|
-
- spec/fixtures/reach_estimate.json
|
216
|
-
- spec/fixtures/tweet_preview.json
|
211
|
+
- spec/twitter-ads/campaign/line_item_spec.rb
|
212
|
+
- spec/fixtures/promotable_users_load.json
|
213
|
+
- spec/fixtures/promoted_tweets_load.json
|
217
214
|
- spec/fixtures/accounts_features.json
|
215
|
+
- spec/fixtures/campaigns_all.json
|
216
|
+
- spec/fixtures/line_items_load.json
|
217
|
+
- spec/fixtures/tweet_previews.json
|
218
|
+
- spec/fixtures/targeted_audiences.json
|
218
219
|
- spec/fixtures/videos_all.json
|
219
|
-
- spec/fixtures/line_items_all.json
|
220
|
-
- spec/fixtures/placements.json
|
221
|
-
- spec/fixtures/promotable_users_load.json
|
222
220
|
- spec/fixtures/tailored_audiences_all.json
|
223
|
-
- spec/fixtures/promoted_tweets_all.json
|
224
221
|
- spec/fixtures/funding_instruments_load.json
|
225
|
-
- spec/fixtures/
|
222
|
+
- spec/fixtures/accounts_load.json
|
223
|
+
- spec/fixtures/line_items_all.json
|
224
|
+
- spec/fixtures/app_lists_all.json
|
225
|
+
- spec/fixtures/placements.json
|
226
226
|
- spec/fixtures/app_lists_load.json
|
227
|
-
- spec/fixtures/promoted_tweets_load.json
|
228
|
-
- spec/fixtures/funding_instruments_all.json
|
229
227
|
- spec/fixtures/campaigns_load.json
|
230
|
-
- spec/fixtures/app_lists_all.json
|
231
|
-
- spec/fixtures/accounts_load.json
|
232
|
-
- spec/fixtures/no_content.json
|
233
|
-
- spec/fixtures/campaigns_all.json
|
234
228
|
- spec/fixtures/accounts_all.json
|
229
|
+
- spec/fixtures/promotable_users_all.json
|
230
|
+
- spec/fixtures/tailored_audiences_load.json
|
231
|
+
- spec/fixtures/promoted_tweets_all.json
|
235
232
|
- spec/fixtures/videos_load.json
|
236
|
-
- spec/
|
233
|
+
- spec/fixtures/funding_instruments_all.json
|
234
|
+
- spec/fixtures/reach_estimate.json
|
235
|
+
- spec/fixtures/no_content.json
|
236
|
+
- spec/fixtures/audience_summary.json
|
237
|
+
- spec/spec_helper.rb
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
module TwitterAds
|
5
|
-
class AudienceIntelligence
|
6
|
-
|
7
|
-
include TwitterAds::DSL
|
8
|
-
include TwitterAds::Resource::InstanceMethods
|
9
|
-
|
10
|
-
attr_reader :account
|
11
|
-
|
12
|
-
# writable
|
13
|
-
property :conversation_type
|
14
|
-
property :targeting_inputs
|
15
|
-
property :audience_definition
|
16
|
-
|
17
|
-
# demographics-only
|
18
|
-
property :start_time, type: :time
|
19
|
-
property :end_time, type: :time
|
20
|
-
|
21
|
-
# read
|
22
|
-
property :operator_type, read_only: true
|
23
|
-
property :targeting_type, read_only: true
|
24
|
-
property :targeting_value, read_only: true
|
25
|
-
property :localized, read_only: true
|
26
|
-
|
27
|
-
RESOURCE_CONVERSATIONS = "/#{TwitterAds::API_VERSION}/" \
|
28
|
-
'accounts/%{account_id}/audience_intelligence/' \
|
29
|
-
'conversations' # @api private
|
30
|
-
RESOURCE_DEMOGRAPHICS = "/#{TwitterAds::API_VERSION}/" \
|
31
|
-
'accounts/%{account_id}/audience_intelligence/' \
|
32
|
-
'demographics' # @api private
|
33
|
-
|
34
|
-
def initialize(account)
|
35
|
-
@account = account
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
def conversations
|
40
|
-
headers = { 'Content-Type' => 'application/json' }
|
41
|
-
params = {
|
42
|
-
conversation_type: conversation_type,
|
43
|
-
audience_definition: audience_definition,
|
44
|
-
targeting_inputs: targeting_inputs
|
45
|
-
}
|
46
|
-
resource = RESOURCE_CONVERSATIONS % { account_id: account.id }
|
47
|
-
request = Request.new(account.client, :post, resource, body: params.to_json, headers: headers)
|
48
|
-
Cursor.new(self.class, request, init_with: [account])
|
49
|
-
end
|
50
|
-
|
51
|
-
def demographics
|
52
|
-
headers = { 'Content-Type' => 'application/json' }
|
53
|
-
params = {
|
54
|
-
audience_definition: audience_definition,
|
55
|
-
targeting_inputs: targeting_inputs
|
56
|
-
}
|
57
|
-
resource = RESOURCE_DEMOGRAPHICS % { account_id: account.id }
|
58
|
-
response = Request.new(
|
59
|
-
account.client,
|
60
|
-
:post,
|
61
|
-
resource,
|
62
|
-
body: params.to_json,
|
63
|
-
headers: headers).perform
|
64
|
-
response.body[:data]
|
65
|
-
# cannot use cursor here given that the response "keys" are dynmaic based on input values
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
module TwitterAds
|
5
|
-
module ReachEstimate
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
# Get a reach estimate for the specified line item details.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# TwitterAds::ReachEstimate.fetch(
|
13
|
-
# account,
|
14
|
-
# 'PROMOTED_TWEETS',
|
15
|
-
# 'WEBSITE_CLICKS',
|
16
|
-
# 5500000,
|
17
|
-
# 30000000,
|
18
|
-
# similar_to_followers_of_user: 2153688540,
|
19
|
-
# gender: 2
|
20
|
-
# )
|
21
|
-
#
|
22
|
-
# @param client [Client] The Client object instance.
|
23
|
-
# @param product_type [String] The product type being targeted.
|
24
|
-
# @param objective [String] The objective being targeted.
|
25
|
-
# @param campaign_daily_budget_amount_local_micro [Long] Daily budget in micros.
|
26
|
-
# @param opts [Hash] A Hash of extended options.
|
27
|
-
#
|
28
|
-
# @option opts [Long] :bid_amount_local_micro Bid amount in local currency micros.
|
29
|
-
# @option opts [String] :bid_type The bidding mechanism.
|
30
|
-
# @option opts [String] :currency ISO-4217 Currency code for bid amount.
|
31
|
-
# @option opts [String] :followers_of_users Comma-separated user IDs.
|
32
|
-
# @option opts [String] :similar_to_followers_of_users Comma-separated user IDs.
|
33
|
-
# @option opts [String] :locations Comma-separated location IDs.
|
34
|
-
# @option opts [String] :interests Comma-seaprated interest IDs.
|
35
|
-
# @option opts [String] :gender Gender identifier.
|
36
|
-
# @option opts [String] :platforms Comma-separated platform IDs.
|
37
|
-
# @option opts [String] :tailored_audiences Comma-separated tailored audience IDs.
|
38
|
-
# @option opts [String] :tailored_audiences_expanded Comma-separated tailoerd audience IDs.
|
39
|
-
# @option opts [String] :languages Comma-separated language IDs.
|
40
|
-
# @option opts [String] :platform_versions Comma-separated platform version IDs.
|
41
|
-
# @option opts [String] :devices Comma-separated device IDs.
|
42
|
-
# @option opts [String] :behaviors Comma-separated behavior IDs.
|
43
|
-
# @option opts [String] :behaviors_expanded Comma-separated behaviors IDs.
|
44
|
-
# @option opts [String] :campaign engagement Campaign ID for Tweet Engager Retargeting.
|
45
|
-
# @option opts [String] :user_engagement Promoted User ID for Tweet Engager Retargeting.
|
46
|
-
# @option opts [String] :engagement_type engagement type for Tweet Engager Retargeting.
|
47
|
-
# @option opts [String] :network_operators Network operators to target
|
48
|
-
# @option opts [String] :app_store_categories App store categories to target.
|
49
|
-
# @option opts [String] :app_store_categories_expanded App store categories with lookalikes.
|
50
|
-
#
|
51
|
-
# @return [Hash] A hash containing count and infinite_bid_count.
|
52
|
-
#
|
53
|
-
# @since 1.0.0
|
54
|
-
# @see https://developer.twitter.com/en/docs/ads/campaign-management/api-reference/reach-estimate
|
55
|
-
def fetch(account, product_type, objective, campaign_daily_budget,
|
56
|
-
opts = {})
|
57
|
-
resource = "/#{TwitterAds::API_VERSION}/accounts/#{account.id}/reach_estimate"
|
58
|
-
params = {
|
59
|
-
product_type: product_type,
|
60
|
-
objective: objective,
|
61
|
-
campaign_daily_budget_amount_local_micro: campaign_daily_budget
|
62
|
-
}.merge!(opts)
|
63
|
-
|
64
|
-
# The response value count is "bid sensitive", we default to bid_type=AUTO here to preserve
|
65
|
-
# expected behavior despite an API change that occurred in December 2015.
|
66
|
-
unless params.keys.include?(:bid_type) || params.keys.include?(:bid_amount_local_micro)
|
67
|
-
params = { bid_type: 'AUTO' }.merge!(params)
|
68
|
-
end
|
69
|
-
|
70
|
-
response = TwitterAds::Request.new(account.client, :get,
|
71
|
-
resource, params: params).perform
|
72
|
-
response.body[:data]
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"data_type": "tweet_preview",
|
3
|
-
"data": [
|
4
|
-
{
|
5
|
-
"platform": "web",
|
6
|
-
"preview": " <div><img><div><div><div><a>AdsAPI</a><a>@AdsAPI</a></div></div><div>Hello World!</div><div><div><img><div><div></div><div><span> Ratings/pricing not available for preview </span><span> Ratings/pricing not available for preview </span></div><div></div> INSTALL </div></div></div><a><img></a><div><div><span></span><span>Promoted by AdsAPI</span></div></div></div></div>"
|
7
|
-
},
|
8
|
-
{
|
9
|
-
"platform": "android",
|
10
|
-
"preview": " <div><img><div><div><div><a>AdsAPI</a><a>@AdsAPI</a></div></div><div>Hello World!</div><div><div><img><div><div></div><div><span> Ratings/pricing not available for preview </span><span> Ratings/pricing not available for preview </span></div><div></div> INSTALL </div></div></div><a><img></a><div><div><span></span><span>Promoted by AdsAPI</span></div></div></div></div>"
|
11
|
-
},
|
12
|
-
{
|
13
|
-
"platform": "iphone",
|
14
|
-
"preview": " <div><img><div><div><div><a>AdsAPI</a><a>@AdsAPI</a></div></div><div>Hello World!</div><div><div><img><div><div></div><div><span> Ratings/pricing not available for preview </span><span> Ratings/pricing not available for preview </span></div><div></div> INSTALL </div></div></div><a><img></a><div><div><span></span><span>Promoted by AdsAPI</span></div></div></div></div>"
|
15
|
-
}
|
16
|
-
],
|
17
|
-
"request": {
|
18
|
-
"params": {
|
19
|
-
"status": "Hello World!",
|
20
|
-
"card_id": "pfs",
|
21
|
-
"account_id": "2iqph"
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe TwitterAds::ReachEstimate do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
stub_fixture(:get, :accounts_all, "#{ADS_API}/accounts")
|
10
|
-
stub_fixture(:get, :accounts_load, "#{ADS_API}/accounts/2iqph")
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:client) do
|
14
|
-
Client.new(
|
15
|
-
Faker::Lorem.characters(15),
|
16
|
-
Faker::Lorem.characters(40),
|
17
|
-
"123456-#{Faker::Lorem.characters(40)}",
|
18
|
-
Faker::Lorem.characters(40)
|
19
|
-
)
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:account) { client.accounts.first }
|
23
|
-
|
24
|
-
describe '#fetch' do
|
25
|
-
|
26
|
-
let!(:resource) { "#{ADS_API}/accounts/#{account.id}/reach_estimate" }
|
27
|
-
let!(:rel_path) { "/#{TwitterAds::API_VERSION}/accounts/#{account.id}/reach_estimate" }
|
28
|
-
|
29
|
-
before(:each) do
|
30
|
-
stub_fixture(:get, :reach_estimate, /#{resource}\?.*/)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'creates proper get request with no optional parameters specified' do
|
34
|
-
expected = { product_type: 'PROMOTED_TWEETS', objective: 'WEBSITE_CLICKS',
|
35
|
-
campaign_daily_budget_amount_local_micro: 30000000, bid_type: 'AUTO' }
|
36
|
-
args = [account.client, :get, rel_path, params: expected]
|
37
|
-
|
38
|
-
expect(Request).to receive(:new).with(*args).and_call_original
|
39
|
-
TwitterAds::ReachEstimate.fetch(account, 'PROMOTED_TWEETS', 'WEBSITE_CLICKS', 30000000)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'creates proper get request when optional paremeters are specified' do
|
43
|
-
|
44
|
-
expected = { product_type: 'PROMOTED_TWEETS', objective: 'WEBSITE_CLICKS',
|
45
|
-
campaign_daily_budget_amount_local_micro: 30000000,
|
46
|
-
similar_to_followers_of_user: '12', gender: '2', bid_type: 'AUTO' }
|
47
|
-
args = [account.client, :get, rel_path, params: expected]
|
48
|
-
|
49
|
-
expect(Request).to receive(:new).with(*args).and_call_original
|
50
|
-
TwitterAds::ReachEstimate.fetch(
|
51
|
-
account, 'PROMOTED_TWEETS', 'WEBSITE_CLICKS', 30000000,
|
52
|
-
similar_to_followers_of_user: '12', gender: '2')
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'without bid_type specified' do
|
57
|
-
|
58
|
-
it 'defaults bid_type to AUTO for backward compatibility' do
|
59
|
-
expected = { product_type: 'PROMOTED_TWEETS', objective: 'WEBSITE_CLICKS',
|
60
|
-
campaign_daily_budget_amount_local_micro: 30000000,
|
61
|
-
bid_type: 'AUTO' }
|
62
|
-
args = [account.client, :get, rel_path, params: expected]
|
63
|
-
|
64
|
-
expect(Request).to receive(:new).with(*args).and_call_original
|
65
|
-
TwitterAds::ReachEstimate.fetch(account, 'PROMOTED_TWEETS', 'WEBSITE_CLICKS', 30000000)
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'with bid_type specified' do
|
71
|
-
|
72
|
-
it 'does not default bid_type to AUTO' do
|
73
|
-
expected = { product_type: 'PROMOTED_TWEETS', objective: 'WEBSITE_CLICKS',
|
74
|
-
bid_amount_local_micro: 3000000,
|
75
|
-
campaign_daily_budget_amount_local_micro: 30000000, bid_type: 'MAX' }
|
76
|
-
args = [account.client, :get, rel_path, params: expected]
|
77
|
-
|
78
|
-
expect(Request).to receive(:new).with(*args).and_call_original
|
79
|
-
TwitterAds::ReachEstimate.fetch(
|
80
|
-
account, 'PROMOTED_TWEETS', 'WEBSITE_CLICKS', 30000000,
|
81
|
-
bid_amount_local_micro: 3000000, bid_type: 'MAX')
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'with bid_amount_local_micro specified' do
|
87
|
-
|
88
|
-
it 'does not default bid_type to AUTO' do
|
89
|
-
expected = { product_type: 'PROMOTED_TWEETS', objective: 'WEBSITE_CLICKS',
|
90
|
-
bid_amount_local_micro: 1500000,
|
91
|
-
campaign_daily_budget_amount_local_micro: 30000000 }
|
92
|
-
args = [account.client, :get, rel_path, params: expected]
|
93
|
-
|
94
|
-
expect(Request).to receive(:new).with(*args).and_call_original
|
95
|
-
TwitterAds::ReachEstimate.fetch(
|
96
|
-
account, 'PROMOTED_TWEETS', 'WEBSITE_CLICKS', 30000000, bid_amount_local_micro: 1500000)
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|