class Jigsaw::ContactSearch
Attributes
address[RW]
areaCode[RW]
city[RW]
companyId[RW]
companyName[RW]
contactId[RW]
contactSales[RW]
contactURL[RW]
country[RW]
email[RW]
firstname[RW]
graveyardStatus[RW]
lastname[RW]
owned[RW]
ownedType[RW]
phone[RW]
seoContactURL[RW]
state[RW]
title[RW]
updatedDate[RW]
zip[RW]
Public Class Methods
list(api_key, options, fetch_all=false)
click to toggle source
# File lib/jigsaw/contact_search.rb, line 34 def self.list(api_key, options, fetch_all=false) options[:token] = api_key options[:page_size] = options[:page_size] || 50 # 50 is the default. options[:offset] = options[:offset] || 0 # 0 is the default. # Camelize options camelized_options = {} options.each do |key, value| camelized_options[key.to_s.camelize(:lower)] = value end # Send one or more requests depending on the number of results, the # page size and the value of fetch_all contacts = [] total_hits = nil fetched_hits = 0 offset = options[:offset] begin response = Request.search_contact(camelized_options) total_hits = response['totalHits'] fetched_hits += response['contacts'].size contacts << response['contacts'].map do |result| self.new(result) end #Calculate the next offset. offset += options[:page_size] camelized_options[:offset] = offset end while fetch_all && (total_hits > offset) # Return the hits info and the list of contacts [total_hits, fetched_hits, contacts.flatten] end
new(json_object)
click to toggle source
# File lib/jigsaw/contact_search.rb, line 9 def initialize(json_object) @zip = json_object['zip'] @phone = json_object['phone'] @areaCode = json_object['areaCode'] @updatedDate = json_object['updatedDate'] @seoContactURL = json_object['seoContactUR'] @state = json_object['state'] @lastname = json_object['lastname'] @firstname = json_object['firstname'] @companyName = json_object['companyName'] @contactURL = json_object['contactURL'] @contactSales = json_object['contactSales'] @country = json_object['country'] @owned = json_object['owned'] @city = json_object['city'] @title = json_object['title'] @contactId = json_object['contactId'] @email = json_object['email'] @address = json_object['address'] @graveyardStatus = json_object['graveyardStatus'] @ownedType = json_object['ownedType'] @companyId = json_object['companyId'] end