module NetProspex::QueryMethods
Public Instance Methods
find_people(query)
click to toggle source
# File lib/netprospex/query_methods.rb, line 21 def find_people(query) # these are boolean but the API wants 0 or 1 [:calc_found_rows, :preview].each do |k| query[k] = 1 if query[k] end response = get('/person/list.json', query) store_balance(response) if persons = response.fetch(:response,{}).fetch(:person_list,{})[:persons] return persons.map{|p| NetProspex::Api::Person.new(p)} else return [] #TODO should this raise an error? end end
find_person(query)
click to toggle source
# File lib/netprospex/query_methods.rb, line 3 def find_person(query) response = get('/person/profile.json', query) store_balance(response) if p = response.fetch(:response,{}).fetch(:person_profile,{})[:person] return NetProspex::Api::Person.new(p) else return nil end end
find_person_by_email(email)
click to toggle source
# File lib/netprospex/query_methods.rb, line 17 def find_person_by_email(email) find_person(email: email) end
find_person_by_id(id)
click to toggle source
# File lib/netprospex/query_methods.rb, line 13 def find_person_by_id(id) find_person(person_id: id) end
Protected Instance Methods
store_balance(hash)
click to toggle source
# File lib/netprospex/query_methods.rb, line 36 def store_balance(hash) balance = hash.fetch(:response,{}).fetch(:transaction,{})[:account_end_balance] @account_balance = balance if balance end