twitter-ads 6.0.1 → 9.0.0

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.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -2
  3. data/README.md +1 -1
  4. data/lib/twitter-ads.rb +5 -4
  5. data/lib/twitter-ads/account.rb +4 -23
  6. data/lib/twitter-ads/audiences/{tailored_audience.rb → custom_audience.rb} +85 -30
  7. data/lib/twitter-ads/{targeting_criteria/behavior_taxonomy.rb → campaign/advertiser_business_categories.rb} +6 -6
  8. data/lib/twitter-ads/campaign/content_categories.rb +23 -0
  9. data/lib/twitter-ads/campaign/line_item.rb +6 -6
  10. data/lib/twitter-ads/campaign/targeting_criteria.rb +1 -0
  11. data/lib/twitter-ads/client.rb +1 -1
  12. data/lib/twitter-ads/creative/cards.rb +56 -0
  13. data/lib/twitter-ads/creative/media_creative.rb +1 -1
  14. data/lib/twitter-ads/creative/promoted_tweet.rb +1 -1
  15. data/lib/twitter-ads/enum.rb +29 -34
  16. data/lib/twitter-ads/http/request.rb +7 -1
  17. data/lib/twitter-ads/resources/analytics.rb +1 -0
  18. data/lib/twitter-ads/targeting/audience_summary.rb +47 -0
  19. data/lib/twitter-ads/targeting_criteria/event.rb +1 -0
  20. data/lib/twitter-ads/version.rb +1 -1
  21. data/spec/fixtures/audience_summary.json +14 -0
  22. data/spec/fixtures/custom_audiences_all.json +67 -0
  23. data/spec/fixtures/{tailored_audiences_load.json → custom_audiences_load.json} +0 -0
  24. data/spec/fixtures/line_items_all.json +2 -10
  25. data/spec/fixtures/line_items_load.json +0 -1
  26. data/spec/fixtures/tailored_audiences_all.json +3 -0
  27. data/spec/fixtures/targeted_audiences.json +33 -0
  28. data/spec/spec_helper.rb +1 -4
  29. data/spec/twitter-ads/account_spec.rb +11 -11
  30. data/spec/twitter-ads/audiences/{tailored_audience_spec.rb → custom_audience_spec.rb} +3 -2
  31. data/spec/twitter-ads/campaign/line_item_spec.rb +6 -3
  32. data/spec/twitter-ads/campaign/targeting_criteria_spec.rb +1 -0
  33. data/spec/twitter-ads/creative/media_creative_spec.rb +1 -1
  34. data/spec/twitter-ads/creative/promoted_tweet_spec.rb +18 -0
  35. data/spec/twitter-ads/targeting/audience_summary_spec.rb +41 -0
  36. metadata +53 -47
  37. data/lib/twitter-ads/targeting/reach_estimate.rb +0 -78
  38. data/lib/twitter-ads/targeting_criteria/behavior.rb +0 -27
  39. data/spec/twitter-ads/campaign/reach_estimate_spec.rb +0 -103
@@ -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
  },
@@ -14,6 +14,7 @@
14
14
  ],
15
15
  "audience_type": "WEB",
16
16
  "id": "abc2",
17
+ "owner_account_id": "18ce54uhdu0",
17
18
  "reasons_not_targetable": [
18
19
  "TOO_SMALL"
19
20
  ],
@@ -33,6 +34,7 @@
33
34
  ],
34
35
  "audience_type": "CRM",
35
36
  "id": "abc1",
37
+ "owner_account_id": "18ce54uhdu0",
36
38
  "reasons_not_targetable": [],
37
39
  "list_type": "DEVICE_ID",
38
40
  "created_at": "2014-05-22T17:37:12Z",
@@ -50,6 +52,7 @@
50
52
  ],
51
53
  "audience_type": "CRM",
52
54
  "id": "abc3",
55
+ "owner_account_id": "18ce54uhdu0",
53
56
  "reasons_not_targetable": [
54
57
  "TOO_SMALL"
55
58
  ],
@@ -0,0 +1,33 @@
1
+ {
2
+ "request": {
3
+ "params": {
4
+ "account_id": "2iqph",
5
+ "tailored_audience_id": "abc2"
6
+ }
7
+ },
8
+ "next_cursor": null,
9
+ "data": [
10
+ {
11
+ "campaign_id": "59hod",
12
+ "campaign_name": "test-campaign",
13
+ "line_items": [
14
+ {
15
+ "id": "5gzog",
16
+ "name": "test-line-item",
17
+ "servable": true
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "campaign_id": "arja7",
23
+ "campaign_name": "Untitled campaign",
24
+ "line_items": [
25
+ {
26
+ "id": "bjw1q",
27
+ "name": null,
28
+ "servable": true
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ }
data/spec/spec_helper.rb CHANGED
@@ -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
@@ -240,22 +240,22 @@ describe TwitterAds::Account do
240
240
 
241
241
  end
242
242
 
243
- describe '#tailored_audiences' do
243
+ describe '#custom_audiences' do
244
244
 
245
245
  before(:each) do
246
- resource_collection = "#{ADS_API}/accounts/#{account.id}/tailored_audiences"
247
- stub_fixture(:get, :tailored_audiences_all, resource_collection)
246
+ resource_collection = "#{ADS_API}/accounts/#{account.id}/custom_audiences"
247
+ stub_fixture(:get, :custom_audiences_all, resource_collection)
248
248
 
249
- resource = "#{ADS_API}/accounts/#{account.id}/tailored_audiences/abc2"
250
- stub_fixture(:get, :tailored_audiences_load, /#{resource}\?.*/)
249
+ resource = "#{ADS_API}/accounts/#{account.id}/custom_audiences/abc2"
250
+ stub_fixture(:get, :custom_audiences_load, /#{resource}\?.*/)
251
251
  end
252
252
 
253
253
  context 'with an id specified' do
254
254
 
255
- it 'successfully loads the specified tailored audience' do
256
- result = account.tailored_audiences('abc2')
255
+ it 'successfully loads the specified custom audience' do
256
+ result = account.custom_audiences('abc2')
257
257
  expect(result).not_to be_nil
258
- expect(result.class).to eq(TwitterAds::TailoredAudience)
258
+ expect(result.class).to eq(TwitterAds::CustomAudience)
259
259
  expect(result.id).to eq('abc2')
260
260
  end
261
261
 
@@ -263,11 +263,11 @@ describe TwitterAds::Account do
263
263
 
264
264
  context 'without an id specified' do
265
265
 
266
- it 'succesfully returns a cursor with all tailored audiences' do
267
- result = account.tailored_audiences
266
+ it 'succesfully returns a cursor with all custom audiences' do
267
+ result = account.custom_audiences
268
268
  expect(result.to_a.size).to eq(3)
269
269
  expect(result.class).to eq(TwitterAds::Cursor)
270
- expect(result.first.class).to eq(TwitterAds::TailoredAudience)
270
+ expect(result.first.class).to eq(TwitterAds::CustomAudience)
271
271
  expect(result.first.id).to eq('abc2')
272
272
  end
273
273
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'spec_helper'
5
5
 
6
- describe TwitterAds::TailoredAudience do
6
+ describe TwitterAds::CustomAudience do
7
7
 
8
8
  before(:each) do
9
9
  stub_fixture(:get, :accounts_all, "#{ADS_API}/accounts")
@@ -31,11 +31,12 @@ describe TwitterAds::TailoredAudience do
31
31
  deleted
32
32
  audience_size
33
33
  audience_type
34
- metadata
35
34
  partner_source
36
35
  reasons_not_targetable
37
36
  targetable
38
37
  targetable_types
38
+ permission_level
39
+ owner_account_id
39
40
  )
40
41
 
41
42
  write = %w(name list_type)
@@ -30,18 +30,21 @@ describe TwitterAds::LineItem do
30
30
  name
31
31
  campaign_id
32
32
  advertiser_domain
33
+ android_app_store_identifier
34
+ audience_expansion
33
35
  categories
34
- charge_by
35
- include_sentiment
36
+ pay_by
36
37
  objective
37
38
  entity_status
38
39
  primary_web_event_tag
39
40
  product_type
40
41
  placements
41
- bid_unit
42
+ bid_strategy
42
43
  automatically_select_bid
43
44
  bid_amount_local_micro
44
45
  total_budget_amount_local_micro
46
+ goal
47
+ ios_app_store_identifier
45
48
  )
46
49
  include_examples 'object property check', read, write
47
50
 
@@ -30,6 +30,7 @@ describe TwitterAds::TargetingCriteria do
30
30
  line_item_id
31
31
  targeting_type
32
32
  targeting_value
33
+ operator_type
33
34
  tailored_audience_expansion
34
35
  )
35
36
 
@@ -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
 
@@ -41,6 +41,24 @@ describe TwitterAds::Creative::PromotedTweet do
41
41
  expect { subject.save }.to raise_error(TwitterAds::ClientError)
42
42
  end
43
43
 
44
+ it 'sets params[:tweet_ids] from params[:tweet_id]' do
45
+ request = double('request')
46
+ response = double('response')
47
+ allow(response).to receive(:body).and_return({ data: [{}] })
48
+ allow(request).to receive(:perform).and_return(response)
49
+ expected_params = { params: { line_item_id: '12345', tweet_ids: 99999999999999999999 } }
50
+
51
+ expect(Request).to receive(:new).with(
52
+ client,
53
+ :post,
54
+ "/#{TwitterAds::API_VERSION}/accounts/#{account.id}/promoted_tweets",
55
+ expected_params
56
+ ).and_return(request)
57
+
58
+ subject.line_item_id = '12345'
59
+ subject.tweet_id = 99999999999999999999
60
+ subject.save
61
+ end
44
62
  end
45
63
 
46
64
  end
@@ -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: 9.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: 2021-07-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json
@@ -57,9 +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/tailored_audience.rb
60
+ - lib/twitter-ads/audiences/custom_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
@@ -69,6 +71,7 @@ files:
69
71
  - lib/twitter-ads/campaign/tweet.rb
70
72
  - lib/twitter-ads/client.rb
71
73
  - lib/twitter-ads/creative/account_media.rb
74
+ - lib/twitter-ads/creative/cards.rb
72
75
  - lib/twitter-ads/creative/cards_fetch.rb
73
76
  - lib/twitter-ads/creative/draft_tweet.rb
74
77
  - lib/twitter-ads/creative/image_app_download_card.rb
@@ -101,10 +104,8 @@ files:
101
104
  - lib/twitter-ads/restapi.rb
102
105
  - lib/twitter-ads/settings/tax.rb
103
106
  - lib/twitter-ads/settings/user.rb
104
- - lib/twitter-ads/targeting/reach_estimate.rb
107
+ - lib/twitter-ads/targeting/audience_summary.rb
105
108
  - 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
109
  - lib/twitter-ads/targeting_criteria/conversation.rb
109
110
  - lib/twitter-ads/targeting_criteria/device.rb
110
111
  - lib/twitter-ads/targeting_criteria/event.rb
@@ -123,8 +124,11 @@ files:
123
124
  - spec/fixtures/accounts_load.json
124
125
  - spec/fixtures/app_lists_all.json
125
126
  - spec/fixtures/app_lists_load.json
127
+ - spec/fixtures/audience_summary.json
126
128
  - spec/fixtures/campaigns_all.json
127
129
  - spec/fixtures/campaigns_load.json
130
+ - spec/fixtures/custom_audiences_all.json
131
+ - spec/fixtures/custom_audiences_load.json
128
132
  - spec/fixtures/funding_instruments_all.json
129
133
  - spec/fixtures/funding_instruments_load.json
130
134
  - spec/fixtures/line_items_all.json
@@ -137,7 +141,7 @@ files:
137
141
  - spec/fixtures/promoted_tweets_load.json
138
142
  - spec/fixtures/reach_estimate.json
139
143
  - spec/fixtures/tailored_audiences_all.json
140
- - spec/fixtures/tailored_audiences_load.json
144
+ - spec/fixtures/targeted_audiences.json
141
145
  - spec/fixtures/tweet_previews.json
142
146
  - spec/fixtures/videos_all.json
143
147
  - spec/fixtures/videos_load.json
@@ -146,10 +150,9 @@ files:
146
150
  - spec/spec_helper.rb
147
151
  - spec/support/helpers.rb
148
152
  - spec/twitter-ads/account_spec.rb
149
- - spec/twitter-ads/audiences/tailored_audience_spec.rb
153
+ - spec/twitter-ads/audiences/custom_audience_spec.rb
150
154
  - spec/twitter-ads/campaign/app_list_spec.rb
151
155
  - spec/twitter-ads/campaign/line_item_spec.rb
152
- - spec/twitter-ads/campaign/reach_estimate_spec.rb
153
156
  - spec/twitter-ads/campaign/targeting_criteria_spec.rb
154
157
  - spec/twitter-ads/campaign/tweet_spec.rb
155
158
  - spec/twitter-ads/client_spec.rb
@@ -161,6 +164,7 @@ files:
161
164
  - spec/twitter-ads/placements_spec.rb
162
165
  - spec/twitter-ads/rate_limit_spec.rb
163
166
  - spec/twitter-ads/retry_count_spec.rb
167
+ - spec/twitter-ads/targeting/audience_summary_spec.rb
164
168
  - spec/twitter-ads/utils_spec.rb
165
169
  - twitter-ads.gemspec
166
170
  homepage: https://github.com/twitterdev/twitter-ruby-ads-sdk
@@ -182,53 +186,55 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
186
  - !ruby/object:Gem::Version
183
187
  version: 2.6.0
184
188
  requirements: []
185
- rubyforge_project:
186
- rubygems_version: 2.5.2.3
189
+ rubygems_version: 3.2.22
187
190
  signing_key:
188
191
  specification_version: 4
189
192
  summary: The officially supported Twitter Ads API SDK for Ruby.
190
193
  test_files:
191
- - spec/spec_helper.rb
192
- - spec/twitter-ads/retry_count_spec.rb
193
- - spec/twitter-ads/audiences/tailored_audience_spec.rb
194
- - spec/twitter-ads/cursor_spec.rb
195
- - spec/twitter-ads/account_spec.rb
196
- - spec/twitter-ads/client_spec.rb
197
- - spec/twitter-ads/rate_limit_spec.rb
198
- - spec/twitter-ads/placements_spec.rb
199
- - spec/twitter-ads/campaign/targeting_criteria_spec.rb
200
- - spec/twitter-ads/campaign/app_list_spec.rb
201
- - spec/twitter-ads/campaign/reach_estimate_spec.rb
202
- - spec/twitter-ads/campaign/line_item_spec.rb
203
- - spec/twitter-ads/campaign/tweet_spec.rb
204
- - spec/twitter-ads/creative/tweet_previews_spec.rb
205
- - spec/twitter-ads/creative/media_creative_spec.rb
206
- - spec/twitter-ads/creative/promoted_tweet_spec.rb
207
- - spec/twitter-ads/creative/promoted_account_spec.rb
208
- - spec/twitter-ads/utils_spec.rb
209
- - spec/shared/properties.rb
210
- - spec/support/helpers.rb
211
- - spec/fixtures/line_items_load.json
212
- - spec/fixtures/promotable_users_all.json
213
- - spec/fixtures/reach_estimate.json
194
+ - spec/fixtures/accounts_all.json
214
195
  - spec/fixtures/accounts_features.json
215
- - spec/fixtures/videos_all.json
196
+ - spec/fixtures/accounts_load.json
197
+ - spec/fixtures/app_lists_all.json
198
+ - spec/fixtures/app_lists_load.json
199
+ - spec/fixtures/audience_summary.json
200
+ - spec/fixtures/campaigns_all.json
201
+ - spec/fixtures/campaigns_load.json
202
+ - spec/fixtures/custom_audiences_all.json
203
+ - spec/fixtures/custom_audiences_load.json
204
+ - spec/fixtures/funding_instruments_all.json
205
+ - spec/fixtures/funding_instruments_load.json
216
206
  - spec/fixtures/line_items_all.json
207
+ - spec/fixtures/line_items_load.json
208
+ - spec/fixtures/no_content.json
217
209
  - spec/fixtures/placements.json
210
+ - spec/fixtures/promotable_users_all.json
218
211
  - spec/fixtures/promotable_users_load.json
219
- - spec/fixtures/tweet_previews.json
220
- - spec/fixtures/tailored_audiences_all.json
221
212
  - spec/fixtures/promoted_tweets_all.json
222
- - spec/fixtures/funding_instruments_load.json
223
- - spec/fixtures/tailored_audiences_load.json
224
- - spec/fixtures/app_lists_load.json
225
213
  - spec/fixtures/promoted_tweets_load.json
226
- - spec/fixtures/funding_instruments_all.json
227
- - spec/fixtures/campaigns_load.json
228
- - spec/fixtures/app_lists_all.json
229
- - spec/fixtures/accounts_load.json
230
- - spec/fixtures/no_content.json
231
- - spec/fixtures/campaigns_all.json
232
- - spec/fixtures/accounts_all.json
214
+ - spec/fixtures/reach_estimate.json
215
+ - spec/fixtures/tailored_audiences_all.json
216
+ - spec/fixtures/targeted_audiences.json
217
+ - spec/fixtures/tweet_previews.json
218
+ - spec/fixtures/videos_all.json
233
219
  - spec/fixtures/videos_load.json
234
220
  - spec/quality_spec.rb
221
+ - spec/shared/properties.rb
222
+ - spec/spec_helper.rb
223
+ - spec/support/helpers.rb
224
+ - spec/twitter-ads/account_spec.rb
225
+ - spec/twitter-ads/audiences/custom_audience_spec.rb
226
+ - spec/twitter-ads/campaign/app_list_spec.rb
227
+ - spec/twitter-ads/campaign/line_item_spec.rb
228
+ - spec/twitter-ads/campaign/targeting_criteria_spec.rb
229
+ - spec/twitter-ads/campaign/tweet_spec.rb
230
+ - spec/twitter-ads/client_spec.rb
231
+ - spec/twitter-ads/creative/media_creative_spec.rb
232
+ - spec/twitter-ads/creative/promoted_account_spec.rb
233
+ - spec/twitter-ads/creative/promoted_tweet_spec.rb
234
+ - spec/twitter-ads/creative/tweet_previews_spec.rb
235
+ - spec/twitter-ads/cursor_spec.rb
236
+ - spec/twitter-ads/placements_spec.rb
237
+ - spec/twitter-ads/rate_limit_spec.rb
238
+ - spec/twitter-ads/retry_count_spec.rb
239
+ - spec/twitter-ads/targeting/audience_summary_spec.rb
240
+ - spec/twitter-ads/utils_spec.rb