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 +4 -4
- data/lib/twitter-ads/audiences/tailored_audience.rb +56 -1
- data/lib/twitter-ads/campaign/targeting_criteria.rb +1 -0
- data/lib/twitter-ads/client.rb +1 -1
- data/lib/twitter-ads/creative/promoted_tweet.rb +1 -1
- data/lib/twitter-ads/enum.rb +3 -4
- data/lib/twitter-ads/targeting_criteria/event.rb +1 -0
- data/lib/twitter-ads/version.rb +1 -1
- data/spec/fixtures/tailored_audiences_all.json +3 -0
- data/spec/fixtures/targeted_audiences.json +33 -0
- data/spec/twitter-ads/audiences/tailored_audience_spec.rb +25 -2
- data/spec/twitter-ads/campaign/targeting_criteria_spec.rb +1 -0
- data/spec/twitter-ads/creative/promoted_tweet_spec.rb +18 -0
- metadata +35 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffe2cf6607163db38e5a09d5cc26e6bd38e700ac5a9a63be8bfaac8837f15725
|
4
|
+
data.tar.gz: 58becc51cdae11dbb55f40f7bc5aaccb024efb250e6f34d3020cc310cfeb3cdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
data/lib/twitter-ads/client.rb
CHANGED
@@ -48,7 +48,7 @@ module TwitterAds
|
|
48
48
|
|
49
49
|
# convert to `tweet_ids` param
|
50
50
|
params = to_params
|
51
|
-
params[:tweet_ids] =
|
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)
|
data/lib/twitter-ads/enum.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
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
|
data/lib/twitter-ads/version.rb
CHANGED
@@ -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,
|
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
|
@@ -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:
|
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-
|
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.
|
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/
|
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/
|
206
|
-
- spec/twitter-ads/
|
207
|
-
- spec/twitter-ads/
|
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/
|
212
|
-
- spec/
|
213
|
-
- spec/
|
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/
|
225
|
-
- spec/fixtures/
|
218
|
+
- spec/fixtures/targeted_audiences.json
|
219
|
+
- spec/fixtures/videos_all.json
|
226
220
|
- spec/fixtures/tailored_audiences_all.json
|
227
|
-
- spec/fixtures/
|
228
|
-
- spec/fixtures/
|
229
|
-
- spec/fixtures/
|
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/
|
235
|
-
- spec/
|
236
|
+
- spec/fixtures/audience_summary.json
|
237
|
+
- spec/spec_helper.rb
|