Class: FellowshipOne::HouseholdListReader

Inherits:
ApiReader
  • Object
show all
Defined in:
lib/readers/household_list_reader.rb

Instance Attribute Summary

Attributes inherited from ApiReader

#headers

Instance Method Summary collapse

Methods inherited from ApiReader

#load_feed, #load_new

Constructor Details

#initialize(options = {}) ⇒ HouseholdListReader

Constructor.

Options: :page - (optional) The page number to get. :per_page - (optional) The number of items to return per page. :household_id - The household ID to pull the info for. :search_for - (optional) Search for name in the request.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/readers/household_list_reader.rb', line 12

def initialize(options = {})
  raise 'Household ID not specified' if options[:household_id].nil? and options[:search_for].nil?

  page = options[:page] || 1
  per_page = options[:per_page] || 100
  
  @url_data_params = {}
  @url_data_path = options[:search_for].nil? ? "/v1/Households/#{options[:household_id].to_i}/People" : '/v1/Households/Search'

  @url_data_params.merge!({:page => page}) if page
  @url_data_params.merge!({:recordsPerPage => per_page}) if per_page
  @url_data_params.merge!({:search_for => options[:search_for]}) if options[:search_for]      
end