Class: NamecheapApi::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/namecheap_api/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Response

Returns a new instance of Response.



7
8
9
# File 'lib/namecheap_api/response.rb', line 7

def initialize(body)
  @raw_body = body
end

Instance Attribute Details

#raw_bodyObject

Returns the value of attribute raw_body.



5
6
7
# File 'lib/namecheap_api/response.rb', line 5

def raw_body
  @raw_body
end

Instance Method Details

#commandObject



11
12
13
# File 'lib/namecheap_api/response.rb', line 11

def command
  doc.css('RequestedCommand').text
end

#docObject



21
22
23
# File 'lib/namecheap_api/response.rb', line 21

def doc
  @doc ||= Nokogiri::XML(raw_body)
end

#resultsObject



15
16
17
18
19
# File 'lib/namecheap_api/response.rb', line 15

def results
  doc.css('CommandResponse > *').map do |result|
    clean_hash_keys(result.to_h)
  end
end