README.md in dnsimple-ruby-1.5.5 vs README.md in dnsimple-ruby-1.6.0

- old
+ new

@@ -9,10 +9,75 @@ ## Installation $ gem install dnsimple-ruby +## DNSimple Client + +This library provides a Ruby DNSimple client you can use to interact with the [DNSimple API](http://developer.dnsimple.com/). Here's a short example. + +```ruby +require 'dnsimple' + +DNSimple::Client.username = 'YOUR_USERNAME' +DNSimple::Client.password = 'YOUR_PASSWORD' + +user = DNSimple::User.me +puts "#{user.domain_count} domains" + +puts "Domains..." +DNSimple::Domain.all.each do |domain| + puts " #{domain.name}" +end + +domain = DNSimple::Domain.find("example.com") +domain.apply("template") # applies a standard or custom template to the domain + +domain = DNSimple::Domain.create("newdomain.com") +puts "Added #{domain.name}" +domain.delete # removes from DNSimple +``` + +For the full API documentation visit http://rubydoc.info/gems/dnsimple-ruby + +### Authentication + +This client supports both the HTTP Basic and API Token authentication mechanism. + +#### HTTP Basic + +```ruby +DNSimple::Client.username = 'YOUR_USERNAME' +DNSimple::Client.password = 'YOUR_PASSWORD' + +user = DNSimple::User.me +``` + +#### HTTP Basic with two-factor authentication enabled + +See the [2FA API documentation](http://developer.dnsimple.com/authentication/#twofa). + +```ruby +# Request the 2FA exchange token +DNSimple::Client.username = 'YOUR_USERNAME' +DNSimple::Client.password = 'YOUR_PASSWORD' +token = DNSimple::User.two_factor_exchange_token('otp-token') + +# Authenticate with the exchange token +DNSimple::Client.exchange_token = token +user = DNSimple::User.me +``` + +#### API Token + +```ruby +DNSimple::Client.api_token = 'the-token' + +user = DNSimple::User.me +``` + + ## Credentials Create a file in your home directory called `.dnsimple`. In this file add the following: @@ -89,36 +154,5 @@ - country - email - phone - phone_ext (optional) - fax (optional) - -## Wrapper Classes - -In addition to the command line utility you may also use the included Ruby -classes directly in your Ruby applications. - -Here's a short example. - - require 'rubygems' - require 'dnsimple' - - DNSimple::Client.username = 'YOUR_USERNAME' - DNSimple::Client.password = 'YOUR_PASSWORD' - DNSimple::Client.http_proxy = {} - - user = DNSimple::User.me - puts "#{user.domain_count} domains" - - puts "Domains..." - DNSimple::Domain.all.each do |domain| - puts " #{domain.name}" - end - - domain = DNSimple::Domain.find("example.com") - domain.apply("template") # applies a standard or custom template to the domain - - domain = DNSimple::Domain.create("newdomain.com") - puts "Added #{domain.name}" - domain.delete # removes from DNSimple - -For the full API documentation visit http://rubydoc.info/gems/dnsimple-ruby