twitter-ads 5.1.0 → 7.0.1
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 -25
- data/lib/twitter-ads/audiences/tailored_audience.rb +98 -3
- 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 +0 -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 +1 -2
- 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 +19 -9
- 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/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/tweet_previews.json +23 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/twitter-ads/campaign/line_item_spec.rb +0 -1
- data/spec/twitter-ads/campaign/targeting_criteria_spec.rb +0 -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/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 +46 -47
- 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
@@ -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
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
include TwitterAds::Enum
|
7
|
-
|
8
|
-
describe TwitterAds::Creative::AccountMedia do
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
stub_fixture(:get, :accounts_all, "#{ADS_API}/accounts")
|
12
|
-
stub_fixture(:get, :accounts_load, "#{ADS_API}/accounts/2iqph")
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:client) do
|
16
|
-
Client.new(
|
17
|
-
Faker::Lorem.characters(15),
|
18
|
-
Faker::Lorem.characters(40),
|
19
|
-
"123456-#{Faker::Lorem.characters(40)}",
|
20
|
-
Faker::Lorem.characters(40)
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:account) { client.accounts.first }
|
25
|
-
|
26
|
-
# check model properties
|
27
|
-
subject { described_class.new(account) }
|
28
|
-
read = %w(id created_at updated_at deleted media_url)
|
29
|
-
write = %w(media_id creative_type video_id)
|
30
|
-
include_examples 'object property check', read, write
|
31
|
-
|
32
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe TwitterAds::Creative::ImageConversationCard 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
|
-
# check model properties
|
25
|
-
subject { described_class.new(account) }
|
26
|
-
read = %w(id image deleted created_at updated_at)
|
27
|
-
write = %w(
|
28
|
-
name
|
29
|
-
title
|
30
|
-
first_cta
|
31
|
-
first_cta_tweet
|
32
|
-
second_cta
|
33
|
-
second_cta_tweet
|
34
|
-
thank_you_text
|
35
|
-
thank_you_url
|
36
|
-
image_media_id
|
37
|
-
)
|
38
|
-
include_examples 'object property check', read, write
|
39
|
-
|
40
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe TwitterAds::Creative::VideoAppDownloadCard 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
|
-
# check model properties
|
25
|
-
subject { described_class.new(account) }
|
26
|
-
read = %w(id video_url video_poster_url deleted created_at updated_at)
|
27
|
-
write = %w(
|
28
|
-
name
|
29
|
-
country_code
|
30
|
-
iphone_app_id
|
31
|
-
iphone_deep_link
|
32
|
-
ipad_app_id
|
33
|
-
ipad_deep_link
|
34
|
-
googleplay_app_id
|
35
|
-
googleplay_deep_link
|
36
|
-
app_cta
|
37
|
-
image_media_id
|
38
|
-
video_id
|
39
|
-
)
|
40
|
-
include_examples 'object property check', read, write
|
41
|
-
|
42
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe TwitterAds::Creative::VideoConversationCard 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
|
-
# check model properties
|
25
|
-
subject { described_class.new(account) }
|
26
|
-
|
27
|
-
read = %w(
|
28
|
-
id
|
29
|
-
video_url
|
30
|
-
video_poster_url
|
31
|
-
deleted
|
32
|
-
created_at
|
33
|
-
updated_at
|
34
|
-
)
|
35
|
-
|
36
|
-
write = %w(
|
37
|
-
name
|
38
|
-
title
|
39
|
-
first_cta
|
40
|
-
first_cta_tweet
|
41
|
-
second_cta
|
42
|
-
second_cta_tweet
|
43
|
-
thank_you_text
|
44
|
-
thank_you_url
|
45
|
-
image_media_id
|
46
|
-
video_id
|
47
|
-
)
|
48
|
-
|
49
|
-
include_examples 'object property check', read, write
|
50
|
-
|
51
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2019 Twitter, Inc.
|
3
|
-
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe TwitterAds::Creative::WebsiteCard 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
|
-
# check model properties
|
25
|
-
subject { described_class.new(account) }
|
26
|
-
read = %w(
|
27
|
-
card_type
|
28
|
-
card_uri
|
29
|
-
created_at
|
30
|
-
deleted
|
31
|
-
id
|
32
|
-
image
|
33
|
-
image_display_height
|
34
|
-
image_display_width
|
35
|
-
website_dest_url
|
36
|
-
website_display_url
|
37
|
-
updated_at
|
38
|
-
)
|
39
|
-
write = %w(image_media_id name website_title website_url)
|
40
|
-
include_examples 'object property check', read, write
|
41
|
-
|
42
|
-
end
|