Class: NameDotCom::API
- Inherits:
-
Object
- Object
- NameDotCom::API
- Defined in:
- lib/name-dot-com.rb
Instance Method Summary collapse
- #check_domain(params) ⇒ Object
- #hello ⇒ Object
-
#initialize(*args) ⇒ API
constructor
A new instance of API.
- #login(account, api_token) ⇒ Object
Constructor Details
#initialize(*args) ⇒ API
Returns a new instance of API.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/name-dot-com.rb', line 16 def initialize(*args) @api = Faraday.new(:url => END_POINT) do |builder| builder.request :url_encoded builder.use Faraday::Response::Mashify builder.use Faraday::Response::ParseJson builder.request :json builder.adapter :net_http end if args[0].is_a? String and args[1].is_a? String then login(args[0],args[1]) end end |
Instance Method Details
#check_domain(params) ⇒ Object
39 40 41 |
# File 'lib/name-dot-com.rb', line 39 def check_domain(params) @api.post('/api/domain/check',params,'Content-Type' => 'application/json').body end |
#hello ⇒ Object
36 37 38 |
# File 'lib/name-dot-com.rb', line 36 def hello @api.get(ACTIONS[:hello]).body end |
#login(account, api_token) ⇒ Object
33 34 35 |
# File 'lib/name-dot-com.rb', line 33 def login(account,api_token) @api.get(ACTIONS[:login],{:account => account, :api_token =>api_token}).body end |