Class: Blackbaud::Person

Inherits:
BlackbaudObject show all
Defined in:
lib/blackbaud-client/api/person.rb

Constant Summary collapse

USER_TYPE =
{
 :faculty => 1,
 :student => 2,
 :undefined => nil,
}

Instance Attribute Summary collapse

Attributes inherited from BlackbaudObject

#client

Instance Method Summary collapse

Methods inherited from BlackbaudObject

#format_date, #to_hash, #to_json

Constructor Details

#initialize(options) ⇒ Person

Returns a new instance of Person.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/blackbaud-client/api/person.rb', line 11

def initialize(options)
  if options.fetch(:values)["bio"]
    options.fetch(:values)["bio"].each {|k, v| options.fetch(:values)[k] = v}
    options.fetch(:values).delete("bio")
  end

  if options.fetch(:values)["contact_info"]
    options.fetch(:values)["contacts"] = options.fetch(:values)["contact_info"].map {|c| Blackbaud::Contact.new({values: c})}
    options.fetch(:values).delete("contact_info")
  else
    options.fetch(:values)["contacts"] = []
  end

  if options.fetch(:values)["relations"]
    options.fetch(:values)["relations"].map! {|r| Blackbaud::Relation.new({values: r})}
  else
    options.fetch(:values)["relations"] = []
  end

  options.fetch(:values)["birth_date"] = format_date(options.fetch(:values)["birth_date"]) if options.fetch(:values)["birth_date"]

  super
end

Instance Attribute Details

#birth_dateObject

Returns the value of attribute birth_date.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def birth_date
  @birth_date
end

#class_ofObject

Returns the value of attribute class_of.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def class_of
  @class_of
end

#contactsObject

Returns the value of attribute contacts.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def contacts
  @contacts
end

#deceasedObject

Returns the value of attribute deceased.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def deceased
  @deceased
end

#ea7_record_idObject

Returns the value of attribute ea7_record_id.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def ea7_record_id
  @ea7_record_id
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def first_name
  @first_name
end

#grade_levelObject

Returns the value of attribute grade_level.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def grade_level
  @grade_level
end

#import_idObject

Returns the value of attribute import_id.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def import_id
  @import_id
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def last_name
  @last_name
end

#middle_nameObject

Returns the value of attribute middle_name.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def middle_name
  @middle_name
end

#name_for_displayObject

Returns the value of attribute name_for_display.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def name_for_display
  @name_for_display
end

#nicknameObject

Returns the value of attribute nickname.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def nickname
  @nickname
end

#online_user_idObject

Returns the value of attribute online_user_id.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def online_user_id
  @online_user_id
end

#record_typeObject

Returns the value of attribute record_type.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def record_type
  @record_type
end

#relationsObject

Returns the value of attribute relations.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def relations
  @relations
end

#suffixObject

Returns the value of attribute suffix.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def suffix
  @suffix
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def title
  @title
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def type
  @type
end

#user_defined_idObject

Returns the value of attribute user_defined_id.



3
4
5
# File 'lib/blackbaud-client/api/person.rb', line 3

def user_defined_id
  @user_defined_id
end

Instance Method Details

#faculty?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/blackbaud-client/api/person.rb', line 35

def faculty?
  type == USER_TYPE[:faculty]
end

#student?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/blackbaud-client/api/person.rb', line 39

def student?
  type == USER_TYPE[:student]
end

#undefined_type?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/blackbaud-client/api/person.rb', line 43

def undefined_type?
  type == USER_TYPE[:undefined]
end