Class: NgpVan::Client

Inherits:
Object
  • Object
show all
Includes:
ActivistCodes, CanvassResponses, Codes, Demographics, DistrictFields, Echoes, EventTypes, Events, ExportJobs, Locations, MinivanExports, Notes, People, Phones, PrintedLists, SavedLists, Signups, Stories, SupporterGroups, SurveyQuestions, Users, Connection, Request, Response
Defined in:
lib/ngp_van/client.rb,
lib/ngp_van/client/codes.rb,
lib/ngp_van/client/notes.rb,
lib/ngp_van/client/users.rb,
lib/ngp_van/client/echoes.rb,
lib/ngp_van/client/events.rb,
lib/ngp_van/client/people.rb,
lib/ngp_van/client/phones.rb,
lib/ngp_van/client/signups.rb,
lib/ngp_van/client/stories.rb,
lib/ngp_van/client/locations.rb,
lib/ngp_van/client/event_types.rb,
lib/ngp_van/client/export_jobs.rb,
lib/ngp_van/client/saved_lists.rb,
lib/ngp_van/client/demographics.rb,
lib/ngp_van/client/printed_lists.rb,
lib/ngp_van/client/activist_codes.rb,
lib/ngp_van/client/district_fields.rb,
lib/ngp_van/client/minivan_exports.rb,
lib/ngp_van/client/supporter_groups.rb,
lib/ngp_van/client/survey_questions.rb,
lib/ngp_van/client/canvass_responses.rb

Defined Under Namespace

Modules: ActivistCodes, CanvassResponses, Codes, Demographics, DistrictFields, Echoes, EventTypes, Events, ExportJobs, Locations, MinivanExports, Notes, People, Phones, PrintedLists, SavedLists, Signups, Stories, SupporterGroups, SurveyQuestions, Users

Instance Method Summary collapse

Methods included from Users

#create_user_district_field_values, #update_user_district_field_values, #user_district_field_values

Methods included from SurveyQuestions

#survey_question, #survey_questions

Methods included from SupporterGroups

#add_person_to_supporter_group, #create_supporter_group, #delete_supporter_group, #remove_person_from_supporter_group, #supporter_group, #supporter_groups

Methods included from Stories

#create_story, #story

Methods included from Signups

#create_signup, #delete_signup, #signup, #signup_statuses, #signups, #update_signup

Methods included from SavedLists

#saved_list, #saved_lists

Methods included from MinivanExports

#minivan_export, #minivan_exports

Methods included from PrintedLists

#printed_list, #printed_lists

Methods included from Phones

#is_cell_statuses

Methods included from People

#apply_code_to_person, #create_canvass_responses_for_person, #create_canvass_responses_for_person_by_type, #create_notes_for_person, #create_notes_for_person_by_type, #delete_code_from_person, #find_or_create_person, #find_person, #get_person_by_van_id, #person, #person_by_type, #update_person_by_van_id

Methods included from Notes

#note_categories, #note_category, #note_category_types

Methods included from Locations

#create_location, #delete_location, #find_or_create_location, #location, #locations

Methods included from ExportJobs

#create_export_job, #export_job, #export_job_types

Methods included from EventTypes

#event_type, #event_types

Methods included from Events

#create_event, #create_event_shift, #delete_event, #event, #events, #update_event

Methods included from Echoes

#echoes

Methods included from DistrictFields

#district_field, #district_fields

Methods included from Demographics

#pronouns, #reported_ethnicities, #reported_genders, #reported_language_preferences, #reported_races, #reported_sexual_orientations

Methods included from Codes

#code, #code_supported_entities, #codes, #create_code, #delete_code, #update_code

Methods included from CanvassResponses

#canvass_responses_contact_types, #canvass_responses_input_types, #canvass_responses_result_codes

Methods included from ActivistCodes

#activist_code, #activist_codes

Methods included from Response

create

Methods included from Request

#delete, #get, #post, #put

Constructor Details

#initialize(configuration = nil) ⇒ Client

Returns a new instance of Client.


30
31
32
# File 'lib/ngp_van/client.rb', line 30

def initialize(configuration = nil)
  @config = configuration
end

Instance Method Details

#configObject


34
35
36
# File 'lib/ngp_van/client.rb', line 34

def config
  @config || NgpVan.configuration
end

#valid_id?(id) ⇒ Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/ngp_van/client.rb', line 38

def valid_id?(id)
  id.to_s =~ /\A[a-z0-9\-:]+\z/i ? true : false
end

#verify_id(*ids) ⇒ Object Also known as: verify_ids


42
43
44
45
46
47
# File 'lib/ngp_van/client.rb', line 42

def verify_id(*ids)
  ids.each do |id|
    raise NgpVan::InvalidID unless valid_id?(id)
  end
  nil
end