MailruTarget
Installation
Add this line to your application's Gemfile:
gem 'mailru_target'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mailru_target
Usage
MailruTarget.client_id = YOUR_CLIENT_ID
MailruTarget.client_secret = YOUR_CLIENT_SECRET_KEY
Get authorize url and redirect user to it.
MailruTarget::Auth.
Recieve authentication code and request token:
MailruTarget::Auth.get_token code
=> {"access_token" => "xxx", "token_type" => "Bearer", "expires_in" => 86400, "refresh_token" => "xxx"}
Use refresh_token to update current token after it expires
MailruTarget::Auth.refresh_token code
=> {"access_token" => "xxx", "token_type" => "Bearer", "expires_in" => 86400, "refresh_token" => "xxx"}
Initialize new session and request restful resources:
session = MailruTarget::Session.new(token)
session.request :get, "/campaigns", status: "active"
Request with 'sudo' mode:
session = MailruTarget::Session.new(token)
session.request :get, "/campaigns", { as_user: "xxxxxxx@agency_client", status: "active" }
Contributing
- Fork it ( https://github.com/[my-github-username]/mailru_target/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request