Skip to content

Commit e55c371

Browse files
authored
Deprecation August, 2019 (#206)
* remove Audience Intelligence * remove old preview endpoints * fix Faker gem version (~> 1.0) workaround for breaking change in Faker 2.x: https://github.com/faker-ruby/faker/releases/tag/2.0
1 parent abfa468 commit e55c371

10 files changed

Lines changed: 3 additions & 300 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem 'rake'
77
group :development, :test do
88
gem 'codeclimate-test-reporter', platforms: :mri
99
gem 'cucumber'
10-
gem 'faker'
10+
gem 'faker', '~> 1.0' # fix for breaking change in faker 2.x
1111
gem 'rspec'
1212
gem 'rubocop', '~> 0.50.0'
1313
gem 'simplecov', '~> 0.13' # fix for breaking change in simplecov

examples/audience_intelligence.rb

Lines changed: 0 additions & 58 deletions
This file was deleted.

examples/tweet_preview.rb

Lines changed: 0 additions & 40 deletions
This file was deleted.

lib/twitter-ads.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
require 'twitter-ads/http/request'
2828
require 'twitter-ads/http/response'
2929

30-
require 'twitter-ads/audiences/audience_intelligence'
3130
require 'twitter-ads/audiences/tailored_audience'
3231

3332
require 'twitter-ads/campaign/app_list'

lib/twitter-ads/audiences/audience_intelligence.rb

Lines changed: 0 additions & 68 deletions
This file was deleted.

lib/twitter-ads/campaign/tweet.rb

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,11 @@ module Tweet
77
# cannot instaniate Tweet, only including class methods for stats
88
extend TwitterAds::Analytics::ClassMethods
99

10-
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
11-
'accounts/%{account_id}/tweet/preview' # @api private
12-
RESOURCE = "/#{TwitterAds::API_VERSION}/" \
13-
'accounts/%{account_id}/tweet/preview/%{id}' # @api private
14-
RESOURCE_CREATE = "/#{TwitterAds::API_VERSION}/" \
15-
'accounts/%{account_id}/tweet' # @api private
10+
RESOURCE_CREATE = "/#{TwitterAds::API_VERSION}/" \
11+
'accounts/%{account_id}/tweet' # @api private
1612

1713
class << self
1814

19-
# Returns an HTML preview of a tweet, either new or existing
20-
#
21-
# @example
22-
# Tweet.preview(account, text: 'potatoes can be deadly...')
23-
# Tweet.preview(account, id: 634798319504617472)
24-
#
25-
# @param client [Client] The Client object instance.
26-
# @param account [Account] The Account object instance.
27-
# @param opts [Hash] A hash of options.
28-
#
29-
# @option opts [Integer] :id The ID of an existing Tweet you want to preview.
30-
# @option opts [String] :text The text of your status update.
31-
# @option opts [Array] :media_ids A list of up to four media IDs to associate with the Tweet.
32-
# @option opts [String] :card_id The base-36 ID of a revenue card to be embedded in the Tweet.
33-
# @option opts [String] :preview_target The target to render the Tweet preview
34-
# for (eg. TWITTER_TIMELINES).
35-
#
36-
# @return [Array] An array containing platforms & their respective tweet previews
37-
#
38-
# @since 0.2.0
39-
# @see https://dev.twitter.com/ads/reference/get/accounts/%3Aaccount_id/tweet/preview
40-
def preview(account, opts = {})
41-
resource = opts.key?(:id) ? RESOURCE : RESOURCE_COLLECTION
42-
resource = resource % { account_id: account.id, id: opts.delete(:id) }
43-
44-
# url encodes status message if present
45-
opts[:text] = URI.escape(opts[:text]) if opts.key?(:text)
46-
47-
# handles array to string conversion for media IDs
48-
if opts.key?(:media_ids) && opts[:media_ids].respond_to?(:join)
49-
opts[:media_ids] = opts[:media_ids].join(',')
50-
end
51-
52-
response = TwitterAds::Request.new(account.client, :get, resource, params: opts).perform
53-
response.body[:data]
54-
end
55-
5615
# Creates a "Promoted-Only" Tweet using the specialized Ads API end point.
5716
#
5817
# @param opts [Hash] A hash of options.

lib/twitter-ads/creative/draft_tweet.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,12 @@ class DraftTweet
3030
'accounts/%{account_id}/draft_tweets' # @api private
3131
RESOURCE = "/#{TwitterAds::API_VERSION}/" \
3232
'accounts/%{account_id}/draft_tweets/%{id}' # @api private
33-
PREVIEW = "/#{TwitterAds::API_VERSION}/" \
34-
'accounts/%{account_id}/draft_tweets/preview/%{id}' # @api private
3533

3634
def initialize(account)
3735
@account = account
3836
self
3937
end
4038

41-
def preview(account: @account, draft_tweet_id: nil)
42-
if !draft_tweet_id.nil?
43-
resource = self.class::PREVIEW % { account_id: account.id, id: draft_tweet_id }
44-
elsif @id
45-
resource = self.class::PREVIEW % { account_id: account.id, id: id }
46-
else
47-
raise ArgumentError.new(
48-
"object has no 'draft_tweet_id' to preview")
49-
end
50-
response = TwitterAds::Request.new(account.client, :post, resource).perform
51-
response.body
52-
end
53-
5439
end
5540
end
5641
end

lib/twitter-ads/creative/scheduled_tweet.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ class ScheduledTweet
3535
'accounts/%{account_id}/scheduled_tweets' # @api private
3636
RESOURCE = "/#{TwitterAds::API_VERSION}/" \
3737
'accounts/%{account_id}/scheduled_tweets/%{id}' # @api private
38-
PREVIEW = "/#{TwitterAds::API_VERSION}/" \
39-
'accounts/%{account_id}/scheduled_tweets/preview/%{id}' # @api private
40-
41-
def preview(account, opts = {})
42-
if @id
43-
resource = self.class::PREVIEW % { account_id: account.id, id: id }
44-
response = TwitterAds::Request.new(account.client, :get, resource, params: opts).perform
45-
response.body[:data]
46-
end
47-
end
4838

4939
def initialize(account)
5040
@account = account

lib/twitter-ads/enum.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ module ConversationType
218218
HASHTAG = 'HASHTAG'
219219
end
220220

221-
module AudienceDefinition
222-
TARGETING_CRITERIA = 'TARGETING_CRITERIA'
223-
KEYWORD_AUDIENCE = 'KEYWORD_AUDIENCE'
224-
end
225-
226221
module LookalikeExpansion
227222
DEFINED = 'DEFINED'
228223
EXPANDED = 'EXPANDED'

spec/twitter-ads/campaign/tweet_spec.rb

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -21,63 +21,4 @@
2121

2222
let(:account) { client.accounts.first }
2323

24-
describe '#tweet_preview' do
25-
26-
let!(:resource_collection) { "#{ADS_API}/accounts/#{account.id}/tweet/preview" }
27-
28-
before(:each) do
29-
stub_fixture(:get, :tweet_preview, /#{resource_collection}.*/)
30-
end
31-
32-
context 'with an existing tweet id' do
33-
34-
it 'successfully returns a preview of the specified tweet' do
35-
params = { id: 634798319504617472 }
36-
result = subject.preview(account, params)
37-
expect(result.size).not_to be_nil
38-
expect(result).to all(include(:platform, :preview))
39-
end
40-
41-
end
42-
43-
context 'when previewing a new tweet' do
44-
45-
it 'url encodes the status content' do
46-
params = { text: 'Hello World!', card_id: '19v69' }
47-
expect(URI).to receive(:escape).at_least(:once).and_call_original
48-
result = subject.preview(account, params)
49-
expect(result.size).not_to be_nil
50-
expect(result).to all(include(:platform, :preview))
51-
end
52-
53-
it 'allows a single value for the media_ids param' do
54-
resource = "/#{TwitterAds::API_VERSION}/accounts/#{account.id}/tweet/preview"
55-
expected = { text: 'Hello%20World!', media_ids: 634458428836962304 }
56-
57-
expect(TwitterAds::Request).to receive(:new).with(
58-
account.client, :get, resource, params: expected).and_call_original
59-
60-
params = { text: 'Hello World!', media_ids: 634458428836962304 }
61-
result = subject.preview(account, params)
62-
expect(result.size).not_to be_nil
63-
expect(result).to all(include(:platform, :preview))
64-
end
65-
66-
it 'allows an array of values for the media_ids param' do
67-
resource = "/#{TwitterAds::API_VERSION}/accounts/#{account.id}/tweet/preview"
68-
expected = { text: 'Hello%20World!', media_ids: '634458428836962304,634458428836962305' }
69-
70-
expect(TwitterAds::Request).to receive(:new).with(
71-
account.client, :get, resource, params: expected).and_call_original
72-
73-
params = { text: 'Hello World!', media_ids: [634458428836962304, 634458428836962305] }
74-
result = subject.preview(account, params)
75-
expect(result.size).not_to be_nil
76-
expect(result).to all(include(:platform, :preview))
77-
end
78-
79-
end
80-
81-
end
82-
8324
end

0 commit comments

Comments
 (0)