Class: FellowshipOne::Communication

Inherits:
ApiObject
  • Object
show all
Defined in:
lib/api/communication.rb

Instance Attribute Summary

Attributes inherited from ApiObject

#error_messages, #marked_for_destruction

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiObject

__f1_attributes, #_default_result_key, f1_attr_accessor, #initialize_from_json_object, #save, #set_attributes, #to_attributes

Constructor Details

#initialize(person_id, reader = nil) ⇒ Communication

Constructor.

Parameters:

  • person_id

    The ID of the person to load the communication for.

  • reader (optional) (defaults to: nil)

    The object that has the data. This can be a CommunicationReader or Hash object.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/api/communication.rb', line 32

def initialize(person_id, reader = nil)      
  @writer_object = CommunicationWriter
  if reader.is_a?(CommunicationReader)
    initialize_from_json_object(reader.load_feed['communication'])
  elsif reader.is_a?(Hash)
    initialize_from_json_object(reader)
  else # new 
    reader = CommunicationReader.new(person_id, nil)
    initialize_from_json_object(reader.load_new['communication'])        
  end   
end

Class Method Details

.load_by_id(communication_id) ⇒ Object

Load the communication by the specified ID.

Returns a new Communication object.

Parameters:

  • communication_id

    The ID of the communication to load.



23
24
25
26
# File 'lib/api/communication.rb', line 23

def self.load_by_id(communication_id)
  reader = CommunicationReader.new(nil, communication_id)
  self.new(reader)
end

Instance Method Details

#_field_mapObject



53
54
55
56
# File 'lib/api/communication.rb', line 53

def _field_map
  {:id => '@id',
   :uri => '@uri'}
end

#household_idObject



44
45
46
# File 'lib/api/communication.rb', line 44

def household_id
  self.household['@id']
end

#individual_idObject Also known as: person_id



48
49
50
# File 'lib/api/communication.rb', line 48

def individual_id
  self.person['@id']
end