-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle rate limit and implement retry logic (#207)
* Add test * handle rate limit and implement retry logic * Expose response headers into instance variables * Fix tests * Add test for client options * remove unused code * Add test case
- Loading branch information
Showing
14 changed files
with
455 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"data_type": "tweet_previews", | ||
"request": { | ||
"params": { | ||
"tweet_ids": [ | ||
"1130942781109596160", | ||
"1101254234031370240" | ||
], | ||
"tweet_type": "PUBLISHED", | ||
"account_id": "2iqph" | ||
} | ||
}, | ||
"data": [ | ||
{ | ||
"tweet_id": "1130942781109596160", | ||
"preview": "<iframe class='tweet-preview' src='https://ton.smf1.twitter.com/ads-manager/tweet-preview/index.html?data=c29tZSByYW5kb20gYmFzZTY0IHN0cmluZ3MgaGVyZS4uLg=='>" | ||
}, | ||
{ | ||
"tweet_id": "1101254234031370240", | ||
"preview": "<iframe class='tweet-preview' src='https://ton.smf1.twitter.com/ads-manager/tweet-preview/index.html?data=c29tZSByYW5kb20gYmFzZTY0IHN0cmluZ3MgaGVyZS4uLg=='>" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
# Copyright (C) 2019 Twitter, Inc. | ||
|
||
require 'spec_helper' | ||
|
||
include TwitterAds::Enum | ||
|
||
describe TwitterAds::Creative::TweetPreview do | ||
|
||
let!(:resource) { "#{ADS_API}/accounts/2iqph/tweet_previews" } | ||
|
||
before(:each) do | ||
stub_fixture(:get, :accounts_load, "#{ADS_API}/accounts/2iqph") | ||
stub_fixture(:get, :tweet_previews, /#{resource}\?.*/) | ||
end | ||
|
||
let(:client) do | ||
Client.new( | ||
Faker::Lorem.characters(40), | ||
Faker::Lorem.characters(40), | ||
Faker::Lorem.characters(40), | ||
Faker::Lorem.characters(40) | ||
) | ||
end | ||
|
||
let(:account) { client.accounts('2iqph') } | ||
let(:instance) { described_class.new(account) } | ||
|
||
it 'inspect TweetPreview.load() response' do | ||
preview = instance.load( | ||
account, | ||
tweet_ids: %w(1130942781109596160 1101254234031370240), | ||
tweet_type: TweetType::PUBLISHED) | ||
|
||
expect(preview).to be_instance_of(Cursor) | ||
expect(preview.count).to eq 2 | ||
tweet = preview.first | ||
expect(tweet.tweet_id).to eq '1130942781109596160' | ||
end | ||
|
||
end |
Oops, something went wrong.