Project

cdn77

0.0
No commit activity in last 3 years
No release in over 3 years
CDN77 API allows you to do a wide range of commands and tasks from an external script or server.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
~> 3.2
~> 1.20
 Project Readme

cdn77

Gem Version Build Status

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

  1. Fork it ( https://github.com/ToMesto/cdn77/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request