Class: VAProfile::Models::CommunicationItemGroup

Inherits:
CommunicationBase show all
Defined in:
lib/va_profile/models/communication_item_group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#communication_itemsObject

Returns the value of attribute communication_items.



9
10
11
# File 'lib/va_profile/models/communication_item_group.rb', line 9

def communication_items
  @communication_items
end

#descriptionObject

Returns the value of attribute description.



9
10
11
# File 'lib/va_profile/models/communication_item_group.rb', line 9

def description
  @description
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/va_profile/models/communication_item_group.rb', line 9

def id
  @id
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/va_profile/models/communication_item_group.rb', line 9

def name
  @name
end

Class Method Details

.create_groups(items_res, permission_res) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/va_profile/models/communication_item_group.rb', line 11

def self.create_groups(items_res, permission_res)
  groups = {}

  items_res['bios'].each do |communication_item|
    communication_item_group = communication_item['communication_item_groups'][0]
    communication_group_id = communication_item_group['communication_group_id']

    groups[communication_group_id] ||= new(
      id: communication_group_id,
      name: communication_item_group['communication_group']['name'],
      description: communication_item_group['communication_group']['description'],
      communication_items: []
    )

    groups[communication_group_id].communication_items <<
      VAProfile::Models::CommunicationItem.create_from_api(communication_item, permission_res)
  end

  groups.values
end