twitter-ads 7.0.1 → 8.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
2
  SHA256:
3
- metadata.gz: b42045b5ca461ee6f6a13ed129264351506089d23622ad2429a1a154e0b2b03f
4
- data.tar.gz: 431d8797b1d1aa606c10672780708112053710b0e745e46e13bd602097c48ca9
3
+ metadata.gz: ffe2cf6607163db38e5a09d5cc26e6bd38e700ac5a9a63be8bfaac8837f15725
4
+ data.tar.gz: 58becc51cdae11dbb55f40f7bc5aaccb024efb250e6f34d3020cc310cfeb3cdb
5
5
  SHA512:
6
- metadata.gz: fb703d3ef21d673d313c7223474e5dabbdb0d64233b88550a1135773118273a71272a38b791c927139773de1b62e639f06075fd9a25a94668e9a7cefd9bd0f82
7
- data.tar.gz: bcef25e9c1a7a4d3ac331bbf901dbaefbe00121a7f0ca6e66c484f0b93585d5d8e85d7d8e46d3bfe771cc5daa584735626300a3b56743e529e4de5031aff3a36
6
+ metadata.gz: 49bec3d898f35d4b0b9e8a95244910230f0c580f6eaf1b111ce71661ea247df2ec5f698600b8a86537889bfe4f4cf2be7a34745f9ffef04be99ad6a9c789f67f
7
+ data.tar.gz: 34c513a59fd03118f3c9273401867c1d5e1a8d81dfcb0a9a9891549350639d68d86dd1670e6822aaa3aab171d474c70b28f161350680ed767f702f39dcbe63cc
@@ -20,6 +20,7 @@ module TwitterAds
20
20
  property :audience_size, read_only: true
21
21
  property :audience_type, read_only: true
22
22
  property :metadata, read_only: true
23
+ property :owner_account_id, read_only: true
23
24
  property :partner_source, read_only: true
24
25
  property :reasons_not_targetable, read_only: true
25
26
  property :targetable, type: :bool, read_only: true
@@ -91,7 +92,7 @@ module TwitterAds
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
98
  # tailored_audience_id.
@@ -137,6 +138,60 @@ 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
197
  class TailoredAudiencePermission
@@ -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
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module TwitterAds
5
5
 
6
- API_VERSION = '7'
6
+ API_VERSION = '8'
7
7
 
8
8
  # The Ads API Client class which functions as a
9
9
  # container for basic API consumer information.
@@ -48,7 +48,7 @@ module TwitterAds
48
48
 
49
49
  # convert to `tweet_ids` param
50
50
  params = to_params
51
- params[:tweet_ids] = *params.delete(:tweet_id) if params.key?(:tweet_id)
51
+ params[:tweet_ids] = params.delete(:tweet_id) if params.key?(:tweet_id)
52
52
 
53
53
  if @id
54
54
  raise TwitterAds::NotFound.new(nil, 'Method PUT not allowed.', 404)
@@ -9,13 +9,12 @@ module TwitterAds
9
9
  module Objective
10
10
  APP_ENGAGEMENTS = 'APP_ENGAGEMENTS'
11
11
  APP_INSTALLS = 'APP_INSTALLS'
12
+ ENGAGEMENTS = 'ENGAGEMENTS'
12
13
  FOLLOWERS = 'FOLLOWERS'
13
- LEAD_GENERATION = 'LEAD_GENERATION'
14
- TWEET_ENGAGEMENTS = 'TWEET_ENGAGEMENTS'
14
+ PREROLL_VIEWS = 'PREROLL_VIEWS'
15
+ REACH = 'REACH'
15
16
  VIDEO_VIEWS = 'VIDEO_VIEWS'
16
17
  WEBSITE_CLICKS = 'WEBSITE_CLICKS'
17
- WEBSITE_CONVERSIONS = 'WEBSITE_CONVERSIONS'
18
-
19
18
  end
20
19
 
21
20
  module Product
@@ -21,6 +21,7 @@ module TwitterAds
21
21
  property :gender_breakdown_percentage, read_only: true
22
22
  property :device_breakdown_percentage, read_only: true
23
23
  property :country_breakdown_percentage, read_only: true
24
+ property :targeting_value, read_only: true
24
25
 
25
26
  RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
26
27
  'targeting_criteria/events' # @api private
@@ -2,5 +2,5 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- VERSION = '7.0.1'
5
+ VERSION = '8.0.0'
6
6
  end
@@ -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
+ }
@@ -7,7 +7,12 @@ describe TwitterAds::TailoredAudience do
7
7
 
8
8
  before(:each) do
9
9
  stub_fixture(:get, :accounts_all, "#{ADS_API}/accounts")
10
- stub_fixture(:get, :accounts_load, "#{ADS_API}/accounts/2iqph")
10
+ stub_fixture(:get,
11
+ :tailored_audiences_load,
12
+ "#{ADS_API}/accounts/2iqph/tailored_audiences/abc2?with_deleted=true")
13
+ stub_fixture(:get,
14
+ :targeted_audiences,
15
+ "#{ADS_API}/accounts/2iqph/tailored_audiences/abc2/targeted")
11
16
  end
12
17
 
13
18
  let(:client) do
@@ -20,7 +25,7 @@ describe TwitterAds::TailoredAudience do
20
25
  end
21
26
 
22
27
  let(:account) { client.accounts.first }
23
-
28
+ let(:tailored_audience) { described_class.load(account, 'abc2') }
24
29
  # check model properties
25
30
  subject { described_class.new(account) }
26
31
 
@@ -29,6 +34,7 @@ describe TwitterAds::TailoredAudience do
29
34
  created_at
30
35
  updated_at
31
36
  deleted
37
+ owner_account_id
32
38
  audience_size
33
39
  audience_type
34
40
  metadata
@@ -42,4 +48,21 @@ describe TwitterAds::TailoredAudience do
42
48
 
43
49
  include_examples 'object property check', read, write
44
50
 
51
+ describe '#targeted' do
52
+
53
+ let(:cursor) { tailored_audience.targeted }
54
+
55
+ it 'has all the correct properties' do
56
+ result = cursor.first
57
+ expect(result).to eq(cursor.instance_variable_get('@collection').first)
58
+ expect(result).to be_instance_of(TwitterAds::TargetedTailoredAudience)
59
+ expect(cursor).to be_instance_of(Cursor)
60
+ end
61
+
62
+ it 'raises error when TailoredAudience is not loaded' do
63
+ result = TwitterAds::TailoredAudience.new(account)
64
+ expect(result).to receive(:validate_loaded).and_call_original
65
+ expect { result.targeted }.to raise_error(ArgumentError)
66
+ end
67
+ end
45
68
  end
@@ -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
 
@@ -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
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: 7.0.1
4
+ version: 8.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: 2020-09-25 00:00:00.000000000 Z
15
+ date: 2020-10-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json
@@ -139,6 +139,7 @@ files:
139
139
  - spec/fixtures/reach_estimate.json
140
140
  - spec/fixtures/tailored_audiences_all.json
141
141
  - spec/fixtures/tailored_audiences_load.json
142
+ - spec/fixtures/targeted_audiences.json
142
143
  - spec/fixtures/tweet_previews.json
143
144
  - spec/fixtures/videos_all.json
144
145
  - spec/fixtures/videos_load.json
@@ -183,53 +184,54 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  - !ruby/object:Gem::Version
184
185
  version: 2.6.0
185
186
  requirements: []
186
- rubygems_version: 3.0.3
187
+ rubygems_version: 3.1.4
187
188
  signing_key:
188
189
  specification_version: 4
189
190
  summary: The officially supported Twitter Ads API SDK for Ruby.
190
191
  test_files:
191
- - spec/support/helpers.rb
192
192
  - spec/quality_spec.rb
193
+ - spec/support/helpers.rb
193
194
  - spec/shared/properties.rb
194
- - spec/twitter-ads/cursor_spec.rb
195
- - spec/twitter-ads/rate_limit_spec.rb
196
195
  - spec/twitter-ads/audiences/tailored_audience_spec.rb
197
- - spec/twitter-ads/targeting/audience_summary_spec.rb
198
- - spec/twitter-ads/campaign/line_item_spec.rb
199
- - spec/twitter-ads/campaign/targeting_criteria_spec.rb
200
- - spec/twitter-ads/campaign/tweet_spec.rb
201
- - spec/twitter-ads/campaign/app_list_spec.rb
202
- - spec/twitter-ads/creative/promoted_tweet_spec.rb
196
+ - spec/twitter-ads/creative/promoted_account_spec.rb
203
197
  - spec/twitter-ads/creative/tweet_previews_spec.rb
204
198
  - spec/twitter-ads/creative/media_creative_spec.rb
205
- - spec/twitter-ads/creative/promoted_account_spec.rb
206
- - spec/twitter-ads/account_spec.rb
207
- - spec/twitter-ads/utils_spec.rb
208
- - spec/twitter-ads/client_spec.rb
199
+ - spec/twitter-ads/creative/promoted_tweet_spec.rb
200
+ - spec/twitter-ads/rate_limit_spec.rb
201
+ - spec/twitter-ads/cursor_spec.rb
209
202
  - spec/twitter-ads/placements_spec.rb
203
+ - spec/twitter-ads/client_spec.rb
204
+ - spec/twitter-ads/account_spec.rb
205
+ - spec/twitter-ads/targeting/audience_summary_spec.rb
210
206
  - spec/twitter-ads/retry_count_spec.rb
211
- - spec/spec_helper.rb
212
- - spec/fixtures/promoted_tweets_all.json
213
- - spec/fixtures/campaigns_load.json
207
+ - spec/twitter-ads/utils_spec.rb
208
+ - spec/twitter-ads/campaign/app_list_spec.rb
209
+ - spec/twitter-ads/campaign/targeting_criteria_spec.rb
210
+ - spec/twitter-ads/campaign/tweet_spec.rb
211
+ - spec/twitter-ads/campaign/line_item_spec.rb
212
+ - spec/fixtures/promotable_users_load.json
214
213
  - spec/fixtures/promoted_tweets_load.json
215
- - spec/fixtures/videos_all.json
216
- - spec/fixtures/accounts_load.json
217
- - spec/fixtures/line_items_all.json
218
214
  - spec/fixtures/accounts_features.json
215
+ - spec/fixtures/campaigns_all.json
219
216
  - spec/fixtures/line_items_load.json
220
- - spec/fixtures/funding_instruments_load.json
221
- - spec/fixtures/videos_load.json
222
- - spec/fixtures/funding_instruments_all.json
223
217
  - spec/fixtures/tweet_previews.json
224
- - spec/fixtures/tailored_audiences_load.json
225
- - spec/fixtures/placements.json
218
+ - spec/fixtures/targeted_audiences.json
219
+ - spec/fixtures/videos_all.json
226
220
  - spec/fixtures/tailored_audiences_all.json
227
- - spec/fixtures/reach_estimate.json
228
- - spec/fixtures/app_lists_load.json
229
- - spec/fixtures/audience_summary.json
230
- - spec/fixtures/campaigns_all.json
221
+ - spec/fixtures/funding_instruments_load.json
222
+ - spec/fixtures/accounts_load.json
223
+ - spec/fixtures/line_items_all.json
231
224
  - spec/fixtures/app_lists_all.json
225
+ - spec/fixtures/placements.json
226
+ - spec/fixtures/app_lists_load.json
227
+ - spec/fixtures/campaigns_load.json
228
+ - spec/fixtures/accounts_all.json
232
229
  - spec/fixtures/promotable_users_all.json
230
+ - spec/fixtures/tailored_audiences_load.json
231
+ - spec/fixtures/promoted_tweets_all.json
232
+ - spec/fixtures/videos_load.json
233
+ - spec/fixtures/funding_instruments_all.json
234
+ - spec/fixtures/reach_estimate.json
233
235
  - spec/fixtures/no_content.json
234
- - spec/fixtures/accounts_all.json
235
- - spec/fixtures/promotable_users_load.json
236
+ - spec/fixtures/audience_summary.json
237
+ - spec/spec_helper.rb