Class: BNamed::Availability

Inherits:
Object
  • Object
show all
Defined in:
lib/b_named/availability.rb

Constant Summary collapse

API_URL =
'https://www2.bNamed.net/en/api.asp'

Instance Method Summary collapse

Constructor Details

#initialize(uid, pass_key) ⇒ Availability

Returns a new instance of Availability.

Raises:

  • (ArgumentError)


5
6
7
8
9
# File 'lib/b_named/availability.rb', line 5

def initialize(uid, pass_key)
  @uid = uid
  @pass_key = pass_key
  raise ArgumentError.new("Please provide a uid and pass_key") if @uid.nil? || @pass_key.nil?
end

Instance Method Details

#check(sld, tlds = nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/b_named/availability.rb', line 11

def check(sld, tlds=nil)
  @tlds = tlds || %w(com net org info name biz)
  @slds = Array.new(@tlds.length).fill(sld)
  
  response = HTTParty.get("#{API_URL}?UID=#{@uid}&Key=#{@pass_key}&command=check&TLDList=#{@tlds.join(',')}&SLDList=#{@slds.join(',')}")
  
  mashup(response['API'])
end