Module: RockRMS::Client::Group

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

Instance Method Summary collapse

Instance Method Details

#create_group(name:, group_type_id:, campus_id: nil, foreign_key: nil, foreign_id: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rock_rms/resources/group.rb', line 12

def create_group(
  name:,
  group_type_id:,
  campus_id: nil,
  foreign_key: nil,
  foreign_id: nil
)
  options = {
    'Name' => name,
    'GroupTypeId' => group_type_id,
    'CampusId' => campus_id,
    'ForeignKey' => foreign_key,
    'ForeignId' => foreign_id
  }

  post(group_path, options)
end

#find_group(id) ⇒ Object



8
9
10
# File 'lib/rock_rms/resources/group.rb', line 8

def find_group(id)
  Response::Group.format(get(group_path(id)))
end

#list_families_for_person(person_id, options = {}) ⇒ Object



40
41
42
43
44
# File 'lib/rock_rms/resources/group.rb', line 40

def list_families_for_person(person_id, options = {})
  Response::Group.format(
    get("Groups/GetFamilies/#{person_id}", options)
  )
end

#list_groups(options = {}) ⇒ Object



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

def list_groups(options = {})
  Response::Group.format(get(group_path, options))
end

#list_groups_for_person(person_id, options = {}) ⇒ Object



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

def list_groups_for_person(person_id, options = {})
  opts = options.dup
  opts['$filter'] = Array(opts['$filter'])
    .push("Members/any(m: m/PersonId eq #{person_id})")
    .join(' and ')
  opts['$expand'] ||= 'Members'

  list_groups(opts)
end

#save_group_address(group_id:, location_type_id:, address:) ⇒ Object

address_format

street1:,
street2:,
city:,
state:,
postal_code:,
country:,



57
58
59
60
61
# File 'lib/rock_rms/resources/group.rb', line 57

def save_group_address(group_id:, location_type_id:, address:)
  url_params = TransformHashKeys.camelize_keys(address)

  put("Groups/SaveAddress/#{group_id}/#{location_type_id}?#{URI.encode_www_form(url_params)}")
end