Class: VAProfile::Models::CommunicationItem
- Inherits:
-
CommunicationBase
- Object
- CommunicationBase
- VAProfile::Models::CommunicationItem
- Defined in:
- lib/va_profile/models/communication_item.rb
Instance Attribute Summary collapse
-
#communication_channel ⇒ Object
Returns the value of attribute communication_channel.
-
#communication_channels ⇒ Object
Returns the value of attribute communication_channels.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#communication_channel ⇒ Object
Returns the value of attribute communication_channel.
10 11 12 |
# File 'lib/va_profile/models/communication_item.rb', line 10 def communication_channel @communication_channel end |
#communication_channels ⇒ Object
Returns the value of attribute communication_channels.
9 10 11 |
# File 'lib/va_profile/models/communication_item.rb', line 9 def communication_channels @communication_channels end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/va_profile/models/communication_item.rb', line 9 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/va_profile/models/communication_item.rb', line 9 def name @name end |
Class Method Details
.create_from_api(communication_res, permission_res) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/va_profile/models/communication_item.rb', line 16 def self.create_from_api(communication_res, ) new( id: communication_res['communication_item_id'], name: communication_res['common_name'], communication_channels: communication_res['communication_item_channels'].map do |communication_item_channel| communication_channel = communication_item_channel['communication_channel'] VAProfile::Models::CommunicationChannel.create_from_api( communication_channel, communication_res['communication_item_id'], communication_item_channel['default_send_indicator'], ) end ) end |
Instance Method Details
#communication_channel_valid ⇒ Object (private)
68 69 70 71 72 |
# File 'lib/va_profile/models/communication_item.rb', line 68 def communication_channel_valid if communication_channel.present? && communication_channel.invalid? errors.add(:communication_channel, communication_channel.errors..join(',')) end end |
#http_verb ⇒ Object
42 43 44 |
# File 'lib/va_profile/models/communication_item.rb', line 42 def http_verb communication_channel..id.present? ? :put : :post end |
#in_json(va_profile_id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/va_profile/models/communication_item.rb', line 46 def in_json(va_profile_id) { bio: { allowed: communication_channel..allowed, communicationChannelId: communication_channel.id, communicationItemId: id, vaProfileId: va_profile_id.to_i, sourceDate: Time.zone.now.iso8601 }.merge(lambda do = communication_channel. if .id.present? { communicationPermissionId: .id } else {} end end.call) }.to_json end |