xdevplatform / twitter-ruby-ads-sdk

A Twitter supported and maintained Ads API SDK for Ruby.
https://twitterdev.github.io/twitter-ruby-ads-sdk/
MIT License
67 stars 71 forks source link

handle rate limit and implement retry logic #207

Closed smaeda-ks closed 5 years ago

smaeda-ks commented 5 years ago

Adding rate limit handling and retry logic.

Usage

account = client.accounts(ADS_ACCOUNT) campaigns = TwitterAds::Campaign.all(account)


- retry
```ruby
client = TwitterAds::Client.new(
  CONSUMER_KEY,
  CONSUMER_SECRET,
  ACCESS_TOKEN,
  ACCESS_TOKEN_SECRET,
  options: {
    retry_max: 3, # default is 0
    retry_delay: 5000, # milliseconds (default is 1500)
    retry_on_status: [404, 500, 503] # status codes you want to retry on
  }
)

account = client.accounts(ADS_ACCOUNT)
campaigns = TwitterAds::Campaign.all(account)

account = client.accounts(ADS_ACCOUNT) campaigns = TwitterAds::Campaign.all(account)

smaeda-ks commented 5 years ago

Would be good to get one more approval just since it's a large / important change...

Thanks! Maybe @osowskit or @tushdante when you have time? 🙏I'll start v6 work after this PR gets merged.