Class: Plangrade::Resources::Participant
- Defined in:
- lib/plangrade/resources/participant.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .all(company_id, *opts) ⇒ Object
- .create(company_id, first_name, last_name, street1, street2, city, state, zip, dob, email, phone, employee_id, opts = {}) ⇒ Object
- .get(id) ⇒ Object
Instance Method Summary collapse
Methods inherited from Base
#api_handler, base_name, #base_name, #changes, #delete!, fetch, identity_map, #initialize, #load!, #loaded?, model_attributes, #modified?, #new_record?, #persisted?, #reload!, #save
Methods included from ApiHandler
#api_handler, #establish_api_handler
Constructor Details
This class inherits a constructor from Plangrade::Resources::Base
Class Method Details
.all(company_id, *opts) ⇒ Object
26 27 28 29 30 |
# File 'lib/plangrade/resources/participant.rb', line 26 def self.all(company_id, *opts) opts ||= {} opts[:company_id] = company_id api_handler.all_participants(opts) end |
.create(company_id, first_name, last_name, street1, street2, city, state, zip, dob, email, phone, employee_id, opts = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/plangrade/resources/participant.rb', line 7 def self.create(company_id, first_name, last_name, street1, street2, city, state, zip, dob, email, phone, employee_id, opts={}) if opts && !opts.nil? && opts != {} result = api_handler.create_participant(:company_id => company_id, :first_name => first_name, :last_name => last_name, :street1 => street1, :street2 => street2, :city => city, :state => state, :zip => zip, :dob => dob, :ssn => opts[:ssn], :email => email, :phone => phone, :employee_id => employee_id) else result = api_handler.create_participant(:company_id => company_id, :first_name => first_name, :last_name => last_name, :street1 => street1, :street2 => street2, :city => city, :state => state, :zip => zip, :dob => dob, :email => email, :phone => phone, :employee_id => employee_id) end return nil unless result.created? id = result.headers[:location].split('/').last.to_i new(:id => id) end |
.get(id) ⇒ Object
20 21 22 23 24 |
# File 'lib/plangrade/resources/participant.rb', line 20 def self.get(id) result = api_handler.get_participant(id) participant = result.body["participant"] new(participant) end |
Instance Method Details
#archive! ⇒ Object
32 33 34 35 36 |
# File 'lib/plangrade/resources/participant.rb', line 32 def archive! result = api_handler.archive_participant(@id) return nil unless result.success? new(result.body) end |
#update!(params) ⇒ Object
38 39 40 |
# File 'lib/plangrade/resources/participant.rb', line 38 def update!(params) api_handler.update_participant(@id, params) end |