Class: Domainsbot
- Inherits:
-
Object
- Object
- Domainsbot
- Defined in:
- lib/domainsbot.rb
Constant Summary collapse
- BASE_URI =
'https://api.domainsbot.com/v4'
- @@api_key =
nil
Class Method Summary collapse
- .api_key ⇒ Object
-
.api_key=(key) ⇒ Object
Set the API key to be used for all requests.
-
.build_uri(path, options) ⇒ Object
Helper method for building the URI Shouldn’t ever be called directly.
-
.suggest(options = {q: '', pageSize: 25, tlds: 'com,org,net', format: 'json'}) ⇒ Object
Attributes.
Class Method Details
.api_key ⇒ Object
29 |
# File 'lib/domainsbot.rb', line 29 def self.api_key; @@api_key; end |
.api_key=(key) ⇒ Object
Set the API key to be used for all requests
Attributes
-
key
- String Domainsbot API Key
Examples
Domainsbot.api_key = "MYAPIKEY"
25 26 27 |
# File 'lib/domainsbot.rb', line 25 def self.api_key=(key) @@api_key = key end |
.build_uri(path, options) ⇒ Object
Helper method for building the URI Shouldn’t ever be called directly
52 53 54 55 56 |
# File 'lib/domainsbot.rb', line 52 def self.build_uri(path, ) #:nodoc: all uri = URI("#{BASE_URI}#{path}") uri.query = URI.encode_www_form() return uri end |
.suggest(options = {q: '', pageSize: 25, tlds: 'com,org,net', format: 'json'}) ⇒ Object
Attributes
-
options
- Hash query parameters
Examples
Domainsbot.suggest({q: 'example.com', pageSize: 2, tlds: 'com,org,net'})
41 42 43 44 45 46 47 48 |
# File 'lib/domainsbot.rb', line 41 def self.suggest(={q: '', pageSize: 25, tlds: 'com,org,net', format: 'json'}) ['auth-token'] = @@api_key [:json] = 'json' uri = build_uri('/spinner', ) response = Net::HTTP.get_response(uri) return JSON.parse(response.body) end |