twitter-ads 6.0.1 → 7.0.0

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
- SHA1:
3
- metadata.gz: 711cd962e65906bf2d4812dc41d48f1f21dfc405
4
- data.tar.gz: 0c266f4c5b2c97fde746e9ba0c55dcba0e63f0a4
2
+ SHA256:
3
+ metadata.gz: c416cfd2439eda9878a5394b0e7ac7b69eff1b096343992435048caf748652a2
4
+ data.tar.gz: 49bb5a43466a1ad10a57491b68309391beb55d094e1ef924b6d0c5f1964aa840
5
5
  SHA512:
6
- metadata.gz: efeea0e20e53512c8a5cfeae1f3a8f922d1dd97e955e13f2d270128a3c4be57832213691fd79f110868412eb597923b85d11a180ebb7aa0e856509737545dd83
7
- data.tar.gz: 197895b12bb107706f7d84dadadbb72c82b5bc91bbf0c72409ad6d45479bef5f5345b128e09ba74d7879f1550539bf253689ab70f80fff58f99b4102344a0476
6
+ metadata.gz: f81b4d99b38ad2c4b5df3fbe90d2af2c82d34a213ba443f7341adb8e00f38ab79055b1697d3f11fde669e88f47b573f64ebdd41fedc6db94df4321f104be072f
7
+ data.tar.gz: e36024ac178f1e67f19a1f41448b539b314d50a679b82acd5fd1a5e0406d71d21cb7ac82acdf64760899bbbcc0378ed94cbe6bef534ee706cbd40f0e17d5c18a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Getting Started [![Build Status](https://travis-ci.org/twitterdev/twitter-ruby-ads-sdk.svg?branch=master)](https://travis-ci.org/twitterdev/twitter-ruby-ads-sdk) [![Code Climate](https://codeclimate.com/github/twitterdev/twitter-ruby-ads-sdk/badges/gpa.svg)](https://codeclimate.com/github/twitterdev/twitter-ruby-ads-sdk) [![Test Coverage](https://codeclimate.com/github/twitterdev/twitter-ruby-ads-sdk/badges/coverage.svg)](https://codeclimate.com/github/twitterdev/twitter-ruby-ads-sdk/coverage) [![Gem Version](https://badge.fury.io/rb/twitter-ads.svg)](http://badge.fury.io/rb/twitter-ads)
1
+ Getting Started [![Build Status](https://travis-ci.org/twitterdev/twitter-ruby-ads-sdk.svg?branch=master)](https://travis-ci.org/twitterdev/twitter-ruby-ads-sdk)[![Gem Version](https://badge.fury.io/rb/twitter-ads.svg)](http://badge.fury.io/rb/twitter-ads)
2
2
  ------
3
3
 
4
4
  ##### Installation
@@ -40,6 +40,8 @@ require 'twitter-ads/campaign/targeting_criteria'
40
40
  require 'twitter-ads/campaign/tweet'
41
41
  require 'twitter-ads/campaign/organic_tweet'
42
42
  require 'twitter-ads/campaign/iab_category'
43
+ require 'twitter-ads/campaign/advertiser_business_categories'
44
+ require 'twitter-ads/campaign/content_categories'
43
45
 
44
46
  require 'twitter-ads/targeting_criteria/tv_market'
45
47
  require 'twitter-ads/targeting_criteria/tv_show'
@@ -52,8 +54,6 @@ require 'twitter-ads/targeting_criteria/network_operator'
52
54
  require 'twitter-ads/targeting_criteria/location'
53
55
  require 'twitter-ads/targeting_criteria/interest'
54
56
  require 'twitter-ads/targeting_criteria/language'
55
- require 'twitter-ads/targeting_criteria/behavior'
56
- require 'twitter-ads/targeting_criteria/behavior_taxonomy'
57
57
  require 'twitter-ads/targeting_criteria/app_store_category'
58
58
 
59
59
  require 'twitter-ads/creative/account_media'
@@ -74,7 +74,7 @@ require 'twitter-ads/creative/poll_cards'
74
74
  require 'twitter-ads/creative/tweet_previews'
75
75
  require 'twitter-ads/creative/tweets'
76
76
 
77
- require 'twitter-ads/targeting/reach_estimate'
77
+ require 'twitter-ads/targeting/audience_summary'
78
78
 
79
79
  require 'twitter-ads/measurement/web_event_tag'
80
80
  require 'twitter-ads/measurement/app_event_tag'
@@ -23,7 +23,6 @@ module TwitterAds
23
23
  'accounts/%{id}' # @api private
24
24
  FEATURES = "/#{TwitterAds::API_VERSION}/" \
25
25
  'accounts/%{id}/features' # @api private
26
- SCOPED_TIMELINE = '/5/accounts/%{id}/scoped_timeline' # @api private
27
26
  AUTHENTICATED_USER_ACCESS = "/#{TwitterAds::API_VERSION}/" \
28
27
  'accounts/%{id}/authenticated_user_access' # @api private
29
28
 
@@ -247,24 +246,6 @@ module TwitterAds
247
246
  load_resource(TailoredAudience, id, opts)
248
247
  end
249
248
 
250
- # Returns the most recent promotable Tweets created by one or more specified Twitter users.
251
- #
252
- # @param ids [Array] An Array of Twitter user IDs.
253
- # @param opts [Hash] A Hash of extended options.
254
- #
255
- # @return [Array] An Array of Tweet objects.
256
- #
257
- # @since 0.2.3
258
- def scoped_timeline(id, opts = {})
259
- TwitterAds::Utils.deprecated(
260
- 'Scoped Timeline')
261
- params = { user_id: id }.merge!(opts)
262
- resource = SCOPED_TIMELINE % { id: @id }
263
- request = Request.new(client, :get, resource, params: params)
264
- response = request.perform
265
- response.body[:data]
266
- end
267
-
268
249
  def authenticated_user_access
269
250
  params = {}
270
251
  resource = AUTHENTICATED_USER_ACCESS % { id: @id }
@@ -2,19 +2,19 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- class BehaviorTaxonomy
5
+ class AdvertiserBusinessCategories
6
6
 
7
7
  include TwitterAds::DSL
8
8
  include TwitterAds::Resource
9
9
 
10
+ attr_reader :account
11
+
10
12
  property :id, read_only: true
11
13
  property :name, read_only: true
12
- property :parent_id, read_only: true
13
- property :created_at, read_only: true
14
- property :updated_at, read_only: true
14
+ property :iab_categories, read_only: true
15
15
 
16
- RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
17
- 'targeting_criteria/behavior_taxonomies' # @api private
16
+ # @api private
17
+ RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/advertiser_business_categories"
18
18
 
19
19
  def initialize(account)
20
20
  @account = account
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ # Copyright (C) 2019 Twitter, Inc.
3
+
4
+ module TwitterAds
5
+ class ContentCategories
6
+
7
+ include TwitterAds::DSL
8
+ include TwitterAds::Resource
9
+
10
+ attr_reader :account
11
+
12
+ property :id, read_only: true
13
+ property :name, read_only: true
14
+ property :iab_categories, read_only: true
15
+
16
+ RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/content_categories" # @api private
17
+
18
+ def initialize(account)
19
+ @account = account
20
+ self
21
+ end
22
+ end
23
+ end
@@ -25,7 +25,6 @@ module TwitterAds
25
25
  property :charge_by
26
26
  property :end_time, type: :time
27
27
  property :entity_status
28
- property :include_sentiment
29
28
  property :name
30
29
  property :objective
31
30
  property :optimization
@@ -3,7 +3,7 @@
3
3
 
4
4
  module TwitterAds
5
5
 
6
- API_VERSION = '6'
6
+ API_VERSION = '7'
7
7
 
8
8
  # The Ads API Client class which functions as a
9
9
  # container for basic API consumer information.
@@ -16,7 +16,7 @@ module TwitterAds
16
16
  property :created_at, type: :time, read_only: true
17
17
  property :deleted, type: :bool, read_only: true
18
18
  property :id, read_only: true
19
- property :serving_status, read_only: true
19
+ property :entity_status, read_only: true
20
20
  property :updated_at, type: :time, read_only: true
21
21
 
22
22
  property :account_media_id
@@ -24,10 +24,15 @@ module TwitterAds
24
24
  end
25
25
 
26
26
  module Placement
27
- ALL_ON_TWITTER = 'ALL_ON_TWITTER'
28
- TWITTER_SEARCH = 'TWITTER_SEARCH'
29
- TWITTER_TIMELINE = 'TWITTER_TIMELINE'
30
- PUBLISHER_NETWORK = 'PUBLISHER_NETWORK'
27
+ ALL_ON_TWITTER = 'ALL_ON_TWITTER'
28
+ TWITTER_SEARCH = 'TWITTER_SEARCH'
29
+ TWITTER_TIMELINE = 'TWITTER_TIMELINE'
30
+ PUBLISHER_NETWORK = 'PUBLISHER_NETWORK'
31
+ TAP_FULL = 'TAP_FULL'
32
+ TAP_FULL_LANDSCAPE = 'TAP_FULL_LANDSCAPE'
33
+ TAP_BANNER = 'TAP_BANNER'
34
+ TAP_NATIVE = 'TAP_NATIVE'
35
+ TAP_MRECT = 'TAP_MRECT'
31
36
  end
32
37
 
33
38
  module Placement
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ # Copyright (C) 2019 Twitter, Inc.
3
+
4
+ module TwitterAds
5
+ module AudienceSummary
6
+
7
+ include TwitterAds::DSL
8
+ include TwitterAds::Resource
9
+
10
+ RESOURCE = "/#{TwitterAds::API_VERSION}/" \
11
+ 'accounts/%{account_id}/audience_summary'
12
+
13
+ property :audience_size, read_only: true
14
+
15
+ class << self
16
+
17
+ # Get an audience summary for the specified targeting criteria.
18
+ #
19
+ # @example
20
+ # TwitterAds::AudienceSummary.fetch(
21
+ # account,
22
+ # params: {targeting_criteria:[{targeting_type:'LOCATION',
23
+ # targeting_value:'96683cc9126741d1'}]}
24
+ # )
25
+ #
26
+ # @param params [Hash] A hash of input targeting criteria values
27
+ #
28
+ # @return [Hash] A hash containing the min and max audience size.
29
+ #
30
+ # @since 7.0.0
31
+ # @see https://developer.twitter.com/en/docs/ads/campaign-management/api-reference/audience-summary
32
+ def fetch(account, params)
33
+ resource = RESOURCE % { account_id: account.id }
34
+ headers = { 'Content-Type' => 'application/json' }
35
+
36
+ response = TwitterAds::Request.new(account.client,
37
+ :post,
38
+ resource,
39
+ headers: headers,
40
+ body: params.to_json).perform
41
+ response.body[:data]
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
@@ -2,5 +2,5 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- VERSION = '6.0.1'
5
+ VERSION = '7.0.0'
6
6
  end
@@ -0,0 +1,14 @@
1
+ {
2
+ "request": {
3
+ "params": {
4
+ "targeting_criteria": null,
5
+ "account_id": "2iqph"
6
+ }
7
+ },
8
+ "data": {
9
+ "audience_size": {
10
+ "min": 41133600,
11
+ "max": 50274400
12
+ }
13
+ }
14
+ }
@@ -29,7 +29,6 @@
29
29
  "currency": "USD",
30
30
  "created_at": "2011-07-11T20:36:11Z",
31
31
  "updated_at": "2011-09-04T19:39:51Z",
32
- "include_sentiment": null,
33
32
  "campaign_id": "2wap7",
34
33
  "deleted": false
35
34
  },
@@ -57,7 +56,6 @@
57
56
  "currency": "USD",
58
57
  "created_at": "2011-07-13T20:56:39Z",
59
58
  "updated_at": "2011-09-04T19:39:04Z",
60
- "include_sentiment": null,
61
59
  "campaign_id": "2wamv",
62
60
  "deleted": false
63
61
  },
@@ -85,7 +83,6 @@
85
83
  "currency": "USD",
86
84
  "created_at": "2011-07-14T00:04:47Z",
87
85
  "updated_at": "2011-09-04T19:39:39Z",
88
- "include_sentiment": null,
89
86
  "campaign_id": "2wai9",
90
87
  "deleted": false
91
88
  },
@@ -113,7 +110,6 @@
113
110
  "currency": "USD",
114
111
  "created_at": "2011-08-22T22:42:18Z",
115
112
  "updated_at": "2011-09-04T19:40:02Z",
116
- "include_sentiment": null,
117
113
  "campaign_id": "2of1n",
118
114
  "deleted": false
119
115
  },
@@ -141,7 +137,7 @@
141
137
  "currency": "JPY",
142
138
  "created_at": "2011-08-26T20:51:14Z",
143
139
  "updated_at": "2011-08-26T21:30:25Z",
144
- "include_sentiment": "POSITIVE_ONLY",
140
+
145
141
  "campaign_id": "2w9n1",
146
142
  "deleted": true
147
143
  },
@@ -169,7 +165,7 @@
169
165
  "currency": "USD",
170
166
  "created_at": "2011-08-26T21:38:51Z",
171
167
  "updated_at": "2011-08-26T22:24:37Z",
172
- "include_sentiment": "POSITIVE_ONLY",
168
+
173
169
  "campaign_id": "2vuug",
174
170
  "deleted": true
175
171
  },
@@ -197,7 +193,6 @@
197
193
  "currency": "JPY",
198
194
  "created_at": "2011-08-26T22:28:55Z",
199
195
  "updated_at": "2011-09-04T19:38:46Z",
200
- "include_sentiment": null,
201
196
  "campaign_id": "2vuj3",
202
197
  "deleted": false
203
198
  },
@@ -225,7 +220,6 @@
225
220
  "currency": "USD",
226
221
  "created_at": "2011-09-01T17:25:04Z",
227
222
  "updated_at": "2011-09-16T02:56:55Z",
228
- "include_sentiment": null,
229
223
  "campaign_id": "2v3c4",
230
224
  "deleted": true
231
225
  },
@@ -253,7 +247,6 @@
253
247
  "currency": "JPY",
254
248
  "created_at": "2011-09-06T17:42:52Z",
255
249
  "updated_at": "2011-09-30T18:54:18Z",
256
- "include_sentiment": null,
257
250
  "campaign_id": "2ttv3",
258
251
  "deleted": false
259
252
  },
@@ -281,7 +274,6 @@
281
274
  "currency": "USD",
282
275
  "created_at": "2011-09-06T22:44:13Z",
283
276
  "updated_at": "2011-09-20T01:32:27Z",
284
- "include_sentiment": null,
285
277
  "campaign_id": "2ttv3",
286
278
  "deleted": true
287
279
  }
@@ -24,7 +24,6 @@
24
24
  "currency": "USD",
25
25
  "created_at": "2011-07-11T20:36:11Z",
26
26
  "updated_at": "2011-09-04T19:39:51Z",
27
- "include_sentiment": null,
28
27
  "campaign_id": "2wap7",
29
28
  "deleted": false
30
29
  },
@@ -3,12 +3,10 @@
3
3
 
4
4
  unless RUBY_PLATFORM =~ /java/ || RUBY_ENGINE =~ /rbx/
5
5
  require 'simplecov'
6
- require 'codeclimate-test-reporter'
7
6
 
8
7
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
9
8
  [
10
- SimpleCov::Formatter::HTMLFormatter,
11
- CodeClimate::TestReporter::Formatter
9
+ SimpleCov::Formatter::HTMLFormatter
12
10
  ]
13
11
  )
14
12
 
@@ -22,7 +20,6 @@ require 'rubocop'
22
20
  require 'faker'
23
21
 
24
22
  require 'webmock/rspec'
25
- WebMock.disable_net_connect!(allow: 'codeclimate.com')
26
23
 
27
24
  require 'twitter-ads'
28
25
  include TwitterAds
@@ -32,7 +32,6 @@ describe TwitterAds::LineItem do
32
32
  advertiser_domain
33
33
  categories
34
34
  charge_by
35
- include_sentiment
36
35
  objective
37
36
  entity_status
38
37
  primary_web_event_tag
@@ -25,7 +25,7 @@ describe TwitterAds::Creative::MediaCreative do
25
25
 
26
26
  # check model properties
27
27
  subject { described_class.new(account) }
28
- read = %w(id created_at updated_at deleted approval_status serving_status)
28
+ read = %w(id created_at updated_at deleted approval_status entity_status)
29
29
  write = %w(account_media_id line_item_id landing_url)
30
30
  include_examples 'object property check', read, write
31
31
 
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ # Copyright (C) 2019 Twitter, Inc.
3
+
4
+ require 'spec_helper'
5
+
6
+ describe TwitterAds::AudienceSummary 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
+ stub_fixture(:post, :audience_summary, "#{ADS_API}/accounts/2iqph/audience_summary")
12
+ end
13
+
14
+ let(:client) do
15
+ Client.new(
16
+ Faker::Lorem.characters(15),
17
+ Faker::Lorem.characters(40),
18
+ "123456-#{Faker::Lorem.characters(40)}",
19
+ Faker::Lorem.characters(40)
20
+ )
21
+ end
22
+
23
+ let(:account) { client.accounts.first }
24
+ let(:params) {
25
+ {
26
+ targeting_criteria: [{
27
+ targeting_type: 'LOCATION',
28
+ targeting_value: '96683cc9126741d1'
29
+ }]
30
+ }
31
+ }
32
+
33
+ # check model properties
34
+ subject { described_class.fetch(account, params) }
35
+
36
+ it 'has all the correct properties' do
37
+ expect(subject[:audience_size][:min]).to eq(41133600)
38
+ expect(subject[:audience_size][:max]).to eq(50274400)
39
+ end
40
+
41
+ end
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: 6.0.1
4
+ version: 7.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: 2019-11-26 00:00:00.000000000 Z
15
+ date: 2020-04-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json
@@ -58,8 +58,10 @@ files:
58
58
  - lib/twitter-ads.rb
59
59
  - lib/twitter-ads/account.rb
60
60
  - lib/twitter-ads/audiences/tailored_audience.rb
61
+ - lib/twitter-ads/campaign/advertiser_business_categories.rb
61
62
  - lib/twitter-ads/campaign/app_list.rb
62
63
  - lib/twitter-ads/campaign/campaign.rb
64
+ - lib/twitter-ads/campaign/content_categories.rb
63
65
  - lib/twitter-ads/campaign/funding_instrument.rb
64
66
  - lib/twitter-ads/campaign/iab_category.rb
65
67
  - lib/twitter-ads/campaign/line_item.rb
@@ -101,10 +103,8 @@ files:
101
103
  - lib/twitter-ads/restapi.rb
102
104
  - lib/twitter-ads/settings/tax.rb
103
105
  - lib/twitter-ads/settings/user.rb
104
- - lib/twitter-ads/targeting/reach_estimate.rb
106
+ - lib/twitter-ads/targeting/audience_summary.rb
105
107
  - lib/twitter-ads/targeting_criteria/app_store_category.rb
106
- - lib/twitter-ads/targeting_criteria/behavior.rb
107
- - lib/twitter-ads/targeting_criteria/behavior_taxonomy.rb
108
108
  - lib/twitter-ads/targeting_criteria/conversation.rb
109
109
  - lib/twitter-ads/targeting_criteria/device.rb
110
110
  - lib/twitter-ads/targeting_criteria/event.rb
@@ -123,6 +123,7 @@ files:
123
123
  - spec/fixtures/accounts_load.json
124
124
  - spec/fixtures/app_lists_all.json
125
125
  - spec/fixtures/app_lists_load.json
126
+ - spec/fixtures/audience_summary.json
126
127
  - spec/fixtures/campaigns_all.json
127
128
  - spec/fixtures/campaigns_load.json
128
129
  - spec/fixtures/funding_instruments_all.json
@@ -149,7 +150,6 @@ files:
149
150
  - spec/twitter-ads/audiences/tailored_audience_spec.rb
150
151
  - spec/twitter-ads/campaign/app_list_spec.rb
151
152
  - spec/twitter-ads/campaign/line_item_spec.rb
152
- - spec/twitter-ads/campaign/reach_estimate_spec.rb
153
153
  - spec/twitter-ads/campaign/targeting_criteria_spec.rb
154
154
  - spec/twitter-ads/campaign/tweet_spec.rb
155
155
  - spec/twitter-ads/client_spec.rb
@@ -161,6 +161,7 @@ files:
161
161
  - spec/twitter-ads/placements_spec.rb
162
162
  - spec/twitter-ads/rate_limit_spec.rb
163
163
  - spec/twitter-ads/retry_count_spec.rb
164
+ - spec/twitter-ads/targeting/audience_summary_spec.rb
164
165
  - spec/twitter-ads/utils_spec.rb
165
166
  - twitter-ads.gemspec
166
167
  homepage: https://github.com/twitterdev/twitter-ruby-ads-sdk
@@ -182,8 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  - !ruby/object:Gem::Version
183
184
  version: 2.6.0
184
185
  requirements: []
185
- rubyforge_project:
186
- rubygems_version: 2.5.2.3
186
+ rubygems_version: 3.1.2
187
187
  signing_key:
188
188
  specification_version: 4
189
189
  summary: The officially supported Twitter Ads API SDK for Ruby.
@@ -194,11 +194,11 @@ test_files:
194
194
  - spec/twitter-ads/cursor_spec.rb
195
195
  - spec/twitter-ads/account_spec.rb
196
196
  - spec/twitter-ads/client_spec.rb
197
+ - spec/twitter-ads/targeting/audience_summary_spec.rb
197
198
  - spec/twitter-ads/rate_limit_spec.rb
198
199
  - spec/twitter-ads/placements_spec.rb
199
200
  - spec/twitter-ads/campaign/targeting_criteria_spec.rb
200
201
  - spec/twitter-ads/campaign/app_list_spec.rb
201
- - spec/twitter-ads/campaign/reach_estimate_spec.rb
202
202
  - spec/twitter-ads/campaign/line_item_spec.rb
203
203
  - spec/twitter-ads/campaign/tweet_spec.rb
204
204
  - spec/twitter-ads/creative/tweet_previews_spec.rb
@@ -208,6 +208,7 @@ test_files:
208
208
  - spec/twitter-ads/utils_spec.rb
209
209
  - spec/shared/properties.rb
210
210
  - spec/support/helpers.rb
211
+ - spec/fixtures/audience_summary.json
211
212
  - spec/fixtures/line_items_load.json
212
213
  - spec/fixtures/promotable_users_all.json
213
214
  - spec/fixtures/reach_estimate.json
@@ -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,27 +0,0 @@
1
- # frozen_string_literal: true
2
- # Copyright (C) 2019 Twitter, Inc.
3
-
4
- module TwitterAds
5
- class Behavior
6
-
7
- include TwitterAds::DSL
8
- include TwitterAds::Resource
9
-
10
- property :id, read_only: true
11
- property :name, read_only: true
12
- property :targeting_type, read_only: true
13
- property :targeting_value, read_only: true
14
- property :audience_code, read_only: true
15
- property :country_code, read_only: true
16
- property :partner_source, read_only: true
17
- property :targetable_type, read_only: true
18
-
19
- RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
20
- 'targeting_criteria/behaviors' # @api private
21
-
22
- def initialize(account)
23
- @account = account
24
- self
25
- end
26
- end
27
- end
@@ -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