Class: Queryitis::Query

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

Class Method Summary collapse

Class Method Details

.query_by_name(search_key) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/queryitis.rb', line 6

def self.query_by_name(search_key)
 @@client = Savon.client(wsdl: "http://www.itis.gov/ITISWebService.xml", log: false, pretty_print_xml: true)
    # first try searching by common name
    @@response = @@client.call(:search_for_any_match, message: { srchKey: search_key } )

    # convert the response into an array containing hashes for each itis entry returned
    Response.new(@@response.body[:search_for_any_match_response][:return][:any_match_list])
end