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
@@ -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