Module: RockRMS::Client::Person

Included in:
RockRMS::Client
Defined in:
lib/rock_rms/resources/person.rb

Constant Summary collapse

NAME_SEARCH_DEFAULTS =
{
  includeHtml: false,
  includeDetails: true,
  includeBusinesses: false,
  includeDeceased: false
}.freeze

Instance Method Summary collapse

Instance Method Details

#create_person(first_name:, last_name:, email:) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/rock_rms/resources/person.rb', line 38

def create_person(first_name:, last_name:, email:)
  options = {
    'IsSystem' => false,
    'FirstName' => first_name,
    'LastName' => last_name,
    'Email' => email,
    'Gender' => 1
  }
  post(people_path, options)
end

#find_person(id) ⇒ Object



9
10
11
12
# File 'lib/rock_rms/resources/person.rb', line 9

def find_person(id)
  res = get(people_path(id))
  Response::Person.format(res)
end

#find_person_by_alias_id(id) ⇒ Object



14
15
16
# File 'lib/rock_rms/resources/person.rb', line 14

def find_person_by_alias_id(id)
  Response::Person.format(get("People/GetByPersonAliasId/#{id}"))
end

#find_person_by_email(email) ⇒ Object



18
19
20
21
# File 'lib/rock_rms/resources/person.rb', line 18

def find_person_by_email(email)
  res = get("People/GetByEmail/#{email}")
  Response::Person.format(res)
end

#find_person_by_name(full_name, options = {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/rock_rms/resources/person.rb', line 30

def find_person_by_name(full_name, options = {})
  priority = options.merge(name: full_name)

  Response::Person.format(
    get('People/Search', NAME_SEARCH_DEFAULTS.merge(priority))
  )
end

#list_people(options = {}) ⇒ Object



4
5
6
7
# File 'lib/rock_rms/resources/person.rb', line 4

def list_people(options = {})
  res = get(people_path, options)
  Response::Person.format(res)
end

#update_person(id, options = {}) ⇒ Object



49
50
51
# File 'lib/rock_rms/resources/person.rb', line 49

def update_person(id, options = {})
  put(people_path(id), options)
end