campaignmonitor/createsend-ruby — pull request #22 by jdennes (2013-03-27 22:50:59+00:00)
Title: Better refreshing of OAuth tokens when using class methods

If you're using class methods such as `CreateSend::Subscriber.add`, doing something like this:

```ruby
auth = {
:access_token => 'access token',
:refresh_token => 'refresh token'
}
begin
tries ||= 2
CreateSend::Subscriber.add auth, list_id, email, name, custom_fields, true
rescue CreateSend::ExpiredOAuthToken => eot
access_token, expires_in, refresh_token =
CreateSend::CreateSend.new(auth).refresh_token
retry unless (tries -= 1).zero?
p "Error: #{eot}"
end
```

It's annoying that you can't refresh an OAuth token using a class method (in this case you have to do `CreateSend::CreateSend.new(auth).refresh_token`). Add a class method CreateSend::CreateSend.refresh_oauth_token(refresh_token) to make this easier.