Skip to content
forked from voxxit/opensrs

Provides support to utilise the OpenSRS API with Ruby/Rails.

License

Notifications You must be signed in to change notification settings

ultraspeed/opensrs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenSRS

Provides basic support to connect to, and utilise the OpenSRS API. This library has been well-tested in a high performance production environment. More information on the API can be located here:

opensrs.com/resources/documentation/opensrs_xmlapi.pdf

Installation

You can install this gem by doing the following:

$ gem install opensrs

You can then include it in a Ruby project, like so:

require 'opensrs'

Alternatively, you can include it in a Rails 2.x project in the environment.rb file, like so:

config.gem "opensrs"

For Rails 3.x, use the Gemfile:

gem "opensrs"

Usage

This library provides basic functionality for interacting with the OpenSRS XML API.

  • Connection handling

  • Error reporting

  • XML encoding

  • XML decoding

To connect, instantiate a new OpenSRS::Server object:

server = OpenSRS::Server.new(
  :server   => "https://rr-n1-tor.opensrs.net:55443/",
  :username => "testing",
  :password => "53cr3t",
  :key      => "c633be3170c7fb3fb29e2f99b84be2410..."
)

NOTE: Connecting to OpenSRS requires that you add the IP(s) you’re connecting from to their whitelist. Login to the testing or production servers, and add your IP(s) under Profile Management > Add IPs for Script/API Access. IP changes take about one hour to take effect.

Once you have this, you can build from this to create the methods that you need. For instance, let’s say we want to grab our account balance. The OpenSRS XML API takes a couple of attributes for all commands. You can include those here:

def get_balance
  server.call(
    :action => "GET_BALANCE",
    :object => "BALANCE"
  )
end

Sometimes you might need to include attributes for the command, such as a cookie, or the data attributes themselves. You can do this, too:

def create_nameserver(nameserver)
  server.call(
    :action => "CREATE",
    :object => "NAMESERVER",
    :cookie => "366828736:3210384",
    :attributes => {
      :name => nameserver.hostname,
      :ipaddress => "212.112.123.11"
    }
  )
end

Responses from OpenSRS are returned in an OpenSRS::Response object, which gives you access to a multitude of things.

  • response.response - This gives you the response in a Hash form, which is highly accessible to most other actions in your application.

  • response.errors - If there are errors which come back from OpenSRS, they are returned here. If not, it returns nil.

  • response.success? - Returns true if the response was labeled as successful. If not, it returns false.

  • response.request_xml - Returns raw request XML.

  • response.response_xml - Returns raw response XML.

Bugs/Feature Requests

If you have any bugs or feature requests for this gem, feel free to add them in the Issues portion of the GitHub repository here:

github.com/voxxit/opensrs/issues

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. If you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull.

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Josh Delsman. See LICENSE for details.

About

Provides support to utilise the OpenSRS API with Ruby/Rails.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published