twitter-ads 6.0.1 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
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: 3ab4c35b2b3ff9a24fb3475717b923563c484d80b2ac7e981c18570ddbaebdbc
4
+ data.tar.gz: e5f228604a745b96a063c59d80248bd976f27a4cc43243cd34a0f45a55548cb0
5
5
  SHA512:
6
- metadata.gz: efeea0e20e53512c8a5cfeae1f3a8f922d1dd97e955e13f2d270128a3c4be57832213691fd79f110868412eb597923b85d11a180ebb7aa0e856509737545dd83
7
- data.tar.gz: 197895b12bb107706f7d84dadadbb72c82b5bc91bbf0c72409ad6d45479bef5f5345b128e09ba74d7879f1550539bf253689ab70f80fff58f99b4102344a0476
6
+ metadata.gz: d17c433739bebd2d74a7c62c20e58819f5f4ea29e241b3dd53ec4baeba4e55213761a27f40833d497b356638a8057770ab7a16f73578df96732555f511ddd43c
7
+ data.tar.gz: 2aff371a6a36636f82adce64fa00766bcd6e5257a6c288ea58f06740df3bb879008bc1e2afe8b286c8b0b1e431ce5bf413a011562cae9e5594f65133f5d63752
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (C) 2019 Twitter, Inc.
3
+ Copyright (C) 2020 Twitter, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
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
data/lib/twitter-ads.rb CHANGED
@@ -29,7 +29,7 @@ require 'twitter-ads/http/response'
29
29
 
30
30
  require 'twitter-ads/restapi.rb'
31
31
 
32
- require 'twitter-ads/audiences/tailored_audience'
32
+ require 'twitter-ads/audiences/custom_audience'
33
33
 
34
34
  require 'twitter-ads/campaign/app_list'
35
35
  require 'twitter-ads/campaign/campaign'
@@ -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,12 +54,11 @@ 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'
60
60
  require 'twitter-ads/creative/cards_fetch'
61
+ require 'twitter-ads/creative/cards'
61
62
  require 'twitter-ads/creative/image_app_download_card'
62
63
  require 'twitter-ads/creative/image_conversation_card'
63
64
  require 'twitter-ads/creative/media_creative'
@@ -74,7 +75,7 @@ require 'twitter-ads/creative/poll_cards'
74
75
  require 'twitter-ads/creative/tweet_previews'
75
76
  require 'twitter-ads/creative/tweets'
76
77
 
77
- require 'twitter-ads/targeting/reach_estimate'
78
+ require 'twitter-ads/targeting/audience_summary'
78
79
 
79
80
  require 'twitter-ads/measurement/web_event_tag'
80
81
  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
 
@@ -233,9 +232,9 @@ module TwitterAds
233
232
  load_resource(AppList, id, opts)
234
233
  end
235
234
 
236
- # Returns a collection of tailored audiences available to the current account.
235
+ # Returns a collection of custom audiences available to the current account.
237
236
  #
238
- # @param id [String] The TailoredAudience ID value.
237
+ # @param id [String] The CustomAudience ID value.
239
238
  # @param opts [Hash] A Hash of extended options.
240
239
  # @option opts [Boolean] :with_deleted Indicates if deleted items should be included.
241
240
  # @option opts [String] :sort_by The object param to sort the API response by.
@@ -243,26 +242,8 @@ module TwitterAds
243
242
  # @since 0.3.0
244
243
  #
245
244
  # @return A Cursor or object instance.
246
- def tailored_audiences(id = nil, opts = {})
247
- load_resource(TailoredAudience, id, opts)
248
- end
249
-
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]
245
+ def custom_audiences(id = nil, opts = {})
246
+ load_resource(CustomAudience, id, opts)
266
247
  end
267
248
 
268
249
  def authenticated_user_access
@@ -2,7 +2,7 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- class TailoredAudience
5
+ class CustomAudience
6
6
 
7
7
  include TwitterAds::DSL
8
8
  include TwitterAds::Resource
@@ -19,18 +19,19 @@ module TwitterAds
19
19
 
20
20
  property :audience_size, read_only: true
21
21
  property :audience_type, read_only: true
22
- property :metadata, read_only: true
23
22
  property :partner_source, read_only: true
24
23
  property :reasons_not_targetable, read_only: true
25
24
  property :targetable, type: :bool, read_only: true
26
25
  property :targetable_types, read_only: true
26
+ property :permission_level, read_only: true
27
+ property :owner_account_id, read_only: true
27
28
 
28
29
  RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
29
- 'accounts/%{account_id}/tailored_audiences' # @api private
30
+ 'accounts/%{account_id}/custom_audiences' # @api private
30
31
  RESOURCE = "/#{TwitterAds::API_VERSION}/" \
31
- 'accounts/%{account_id}/tailored_audiences/%{id}' # @api private
32
+ 'accounts/%{account_id}/custom_audiences/%{id}' # @api private
32
33
  RESOURCE_USERS = "/#{TwitterAds::API_VERSION}/" \
33
- 'accounts/%{account_id}/tailored_audiences/' \
34
+ 'accounts/%{account_id}/custom_audiences/' \
34
35
  '%{id}/users' # @api private
35
36
 
36
37
  LIST_TYPES = %w(
@@ -54,17 +55,17 @@ module TwitterAds
54
55
 
55
56
  class << self
56
57
 
57
- # Creates a new tailored audience.
58
+ # Creates a new custom audience.
58
59
  #
59
60
  # @example
60
- # audience = TailoredAudience.create(account, 'my list')
61
+ # audience = CustomAudience.create(account, 'my list')
61
62
  #
62
63
  # @param account [Account] The account object instance.
63
- # @param name [String] The tailored audience name.
64
+ # @param name [String] The custom audience name.
64
65
  #
65
66
  # @since 4.0
66
67
  #
67
- # @return [TailoredAudience] The newly created tailored audience instance.
68
+ # @return [CustomAudience] The newly created custom audience instance.
68
69
  def create(account, name)
69
70
  audience = new(account)
70
71
  params = { name: name }
@@ -75,7 +76,7 @@ module TwitterAds
75
76
 
76
77
  end
77
78
 
78
- # Deletes the current tailored audience instance.
79
+ # Deletes the current custom audience instance.
79
80
  #
80
81
  # @example
81
82
  # audience.delete!
@@ -84,21 +85,21 @@ module TwitterAds
84
85
  #
85
86
  # @since 0.3.0
86
87
  #
87
- # @return [self] Returns the tailored audience instance refreshed from the API.
88
+ # @return [self] Returns the custom audience instance refreshed from the API.
88
89
  def delete!
89
90
  resource = RESOURCE % { account_id: account.id, id: id }
90
91
  response = Request.new(account.client, :delete, resource).perform
91
92
  from_response(response.body[:data])
92
93
  end
93
94
 
94
- # This is a private API and requires whitelisting from Twitter.
95
+ # This is a private API and requires allowlisting from Twitter.
95
96
  #
96
97
  # This endpoint will allow partners to add, update and remove users from a given
97
- # tailored_audience_id.
98
+ # custom_audience_id.
98
99
  # The endpoint will also accept multiple user identifier types per user as well.
99
100
  #
100
101
  # @example
101
- # tailored_audience.users(
102
+ # custom_audience.users(
102
103
  # account,
103
104
  # [
104
105
  # {
@@ -137,9 +138,63 @@ module TwitterAds
137
138
  [success_count, total_count]
138
139
  end
139
140
 
141
+ # Retrieves the entites targeting the current tailored audience instance.
142
+ #
143
+ # @example
144
+ # audience.targeted(with_active=true)
145
+ #
146
+ # @param with_active [bool] Include active/inactive
147
+ #
148
+ # @since 8.0.0
149
+ #
150
+ # @return [self] Returns a Cursor instance of the targeted entities.
151
+ def targeted(opts = {})
152
+ validate_loaded
153
+ params = {}.merge!(opts)
154
+ TargetedTailoredAudience.load(account, id, params)
155
+ end
156
+
157
+ def validate_loaded
158
+ raise ArgumentError.new(
159
+ "Error! #{self.class} object not yet initialized, " \
160
+ "call #{self.class}.load first") if id.nil?
161
+ end
162
+ end
163
+
164
+ class TargetedTailoredAudience
165
+
166
+ include TwitterAds::DSL
167
+ include TwitterAds::Resource
168
+
169
+ attr_reader :account
170
+
171
+ # read-only
172
+ property :campaign_id, read_only: true
173
+ property :campaign_name, read_only: true
174
+ property :line_items, read_only: true
175
+
176
+ RESOURCE_TARGETED = "/#{TwitterAds::API_VERSION}/" \
177
+ 'accounts/%{account_id}/tailored_audiences/%{id}/targeted' # @api private
178
+
179
+ def initialize(account)
180
+ @account = account
181
+ self
182
+ end
183
+
184
+ class << self
185
+
186
+ def load(account, tailored_audience_id, params)
187
+ resource = RESOURCE_TARGETED % { account_id: account.id, id: tailored_audience_id }
188
+ request = TwitterAds::Request.new(account.client,
189
+ :get,
190
+ resource,
191
+ params: params)
192
+ Cursor.new(self, request, init_with: [account])
193
+ end
194
+ end
140
195
  end
141
196
 
142
- class TailoredAudiencePermission
197
+ class CustomAudiencePermission
143
198
 
144
199
  include TwitterAds::DSL
145
200
  include TwitterAds::Resource
@@ -152,16 +207,16 @@ module TwitterAds
152
207
  property :deleted, type: :bool, read_only: true
153
208
 
154
209
  property :id
155
- property :tailored_audience_id
210
+ property :custom_audience_id
156
211
  property :granted_account_id
157
212
  property :permission_level
158
213
 
159
214
  RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
160
- 'accounts/%{account_id}/tailored_audiences/' \
161
- '%{tailored_audience_id}/permissions' # @api private
215
+ 'accounts/%{account_id}/custom_audiences/' \
216
+ '%{custom_audience_id}/permissions' # @api private
162
217
  RESOURCE = "/#{TwitterAds::API_VERSION}/" \
163
- 'accounts/%{account_id}/tailored_audiences/' \
164
- '%{tailored_audience_id}/permissions/%{id}' # @api private
218
+ 'accounts/%{account_id}/custom_audiences/' \
219
+ '%{custom_audience_id}/permissions/%{id}' # @api private
165
220
 
166
221
  def initialize(account)
167
222
  @account = account
@@ -171,22 +226,22 @@ module TwitterAds
171
226
  class << self
172
227
 
173
228
  # Retrieve details for some or
174
- # all permissions associated with the specified tailored audience.
229
+ # all permissions associated with the specified custom audience.
175
230
  #
176
231
  # @exapmle
177
- # permissions = TailoredAudiencePermission.all(account, '36n4f')
232
+ # permissions = CustomAudiencePermission.all(account, '36n4f')
178
233
  #
179
234
  # @param account [Account] The account object instance.
180
- # @param tailored_audience_id [String] The tailored audience id.
235
+ # @param custom_audience_id [String] The custom audience id.
181
236
  #
182
237
  # @since 5.2.0
183
238
  #
184
- # @return [TailoredAudiencePermission] The tailored audience permission instance.
185
- def all(account, tailored_audience_id, opts = {})
239
+ # @return [CustomAudiencePermission] The custom audience permission instance.
240
+ def all(account, custom_audience_id, opts = {})
186
241
  params = {}.merge!(opts)
187
242
  resource = RESOURCE_COLLECTION % {
188
243
  account_id: account.id,
189
- tailored_audience_id: tailored_audience_id
244
+ custom_audience_id: custom_audience_id
190
245
  }
191
246
  request = Request.new(account.client, :get, resource, params: params)
192
247
  Cursor.new(self, request, init_with: [account])
@@ -195,7 +250,7 @@ module TwitterAds
195
250
  end
196
251
 
197
252
  # Saves or updates the current object instance
198
- # depending on the presence of `object.tailored_audience_id`.
253
+ # depending on the presence of `object.custom_audience_id`.
199
254
  #
200
255
  # @exapmle
201
256
  # object.save
@@ -206,14 +261,14 @@ module TwitterAds
206
261
  def save
207
262
  resource = RESOURCE_COLLECTION % {
208
263
  account_id: account.id,
209
- tailored_audience_id: tailored_audience_id
264
+ custom_audience_id: custom_audience_id
210
265
  }
211
266
  params = to_params
212
267
  response = Request.new(account.client, :post, resource, params: params).perform
213
268
  from_response(response.body[:data])
214
269
  end
215
270
 
216
- # Deletes the current or specified tailored audience permission.
271
+ # Deletes the current or specified custom audience permission.
217
272
  #
218
273
  # @example
219
274
  # object.delete!
@@ -226,7 +281,7 @@ module TwitterAds
226
281
  def delete!
227
282
  resource = RESOURCE % {
228
283
  account_id: account.id,
229
- tailored_audience_id: tailored_audience_id,
284
+ custom_audience_id: custom_audience_id,
230
285
  id: @id
231
286
  }
232
287
  response = Request.new(account.client, :delete, resource).perform
@@ -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
@@ -17,18 +17,20 @@ module TwitterAds
17
17
  property :updated_at, type: :time, read_only: true
18
18
 
19
19
  property :advertiser_domain
20
+ property :android_app_store_identifier
21
+ property :audience_expansion
20
22
  property :automatically_select_bid
21
23
  property :bid_amount_local_micro
22
- property :bid_unit
24
+ property :bid_strategy
23
25
  property :campaign_id
24
26
  property :categories
25
- property :charge_by
26
27
  property :end_time, type: :time
27
28
  property :entity_status
28
- property :include_sentiment
29
+ property :goal
30
+ property :ios_app_store_identifier
29
31
  property :name
30
32
  property :objective
31
- property :optimization
33
+ property :pay_by
32
34
  property :placements
33
35
  property :primary_web_event_tag
34
36
  property :product_type
@@ -37,9 +39,7 @@ module TwitterAds
37
39
 
38
40
  # beta (not yet generally available)
39
41
  property :advertiser_user_id
40
- property :bid_type
41
42
  property :tracking_tags
42
- property :audience_expansion
43
43
 
44
44
  # sdk only
45
45
  property :to_delete, type: :bool
@@ -21,6 +21,7 @@ module TwitterAds
21
21
  property :line_item_id
22
22
  property :targeting_type
23
23
  property :targeting_value
24
+ property :operator_type
24
25
  property :tailored_audience_expansion, type: :bool
25
26
  property :location_type
26
27