cdn77
Wrapper for CDN77 API that allows you to do a wide range of commands and tasks from an external script or server.
Installation
This gem works with Rails 3.2 onwards. To make it available just add following lines into your Gemfile:
gem "cdn77"
And then execute:
bundle install
Or install it yourself as:
gem install cdn77
And require in irb:
require "cdn77"
Using
To perform any requests use simple wrapper:
config = Cdn77::Configuration.new(:login => "someone@example.com", :password => "secret")
cdn = Cdn77.cdn(config)
cdn.get("account", "details")
# {:status => "ok", :description => "Request was successful.", :account => ...}
If you want to setup configuration only once you should take a look on Cdn77.configure
. For example, it is a good idea to create rails initializer with following code:
# config/initializers/cdn77.rb
Cdn77.configure do |config|
config.login = "someone@example.com"
config.password = "secret"
end
Now just call API's method in any part of your application:
Cdn77.cdn.get("account", "details")
# {:status => "ok", :description => "Request was successful.", :account => ...}
Of course, you can override global configuration if needed. For example:
Cdn77.configure do |config|
config.login = "someone@example.com"
config.password = "secret"
end
Cdn77.cdn.get("account", "details", :login => "someoneelse@example.com", :password => 'elsesecret')
To make requests using HTTP POST call post
method:
Cdn77.cdn.post("account", "edit", :full_name => "Martin Eden")
And have fun!
Contributing
- Fork it ( https://github.com/ToMesto/cdn77/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