Class: Plangrade::Resources::Participants

Inherits:
Base
  • Object
show all
Defined in:
lib/plangrade/resources/participant.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#api_handler, #base_name, base_name, #changes, #delete!, fetch, get, 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

.create(company_id, first_name, last_name, street1, street2, city, state, zip, dob, ssn, email, phone, employee_id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/plangrade/resources/participant.rb', line 5

def self.create(company_id, first_name, last_name, street1, street2, city, state, zip, dob, ssn, email, phone, employee_id)

  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 => ssn, :email => email, :phone => phone,
                                          :employee_id => employee_id)
  return nil unless result.created?
  id = result.headers[:location].split('/').last.to_i
  new(:id => id)
end

Instance Method Details

#update!(params) ⇒ Object



19
20
21
# File 'lib/plangrade/resources/participant.rb', line 19

def update!(params)
  api_handler.update_participant(@id, params)
end