Class: BNamed::Availability
- Inherits:
-
Object
- Object
- BNamed::Availability
- Defined in:
- lib/b_named/availability.rb
Constant Summary collapse
- API_URL =
'https://www2.bNamed.net/en/api.asp'
Instance Method Summary collapse
- #check(sld, tlds = nil) ⇒ Object
-
#initialize(uid, pass_key) ⇒ Availability
constructor
A new instance of Availability.
Constructor Details
#initialize(uid, pass_key) ⇒ Availability
Returns a new instance of Availability.
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 |