Class: CommandTower::Messaging::Inbox::ItemResult

Inherits:
Data
  • Object
show all
Defined in:
app/services/command_tower/messaging/inbox/item_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#archived_atObject (readonly)

Returns the value of attribute archived_at

Returns:

  • (Object)

    the current value of archived_at



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def archived_at
  @archived_at
end

#communication_idObject (readonly)

Returns the value of attribute communication_id

Returns:

  • (Object)

    the current value of communication_id



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def communication_id
  @communication_id
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def created_at
  @created_at
end

#deleted_atObject (readonly)

Returns the value of attribute deleted_at

Returns:

  • (Object)

    the current value of deleted_at



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def deleted_at
  @deleted_at
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def id
  @id
end

#recipient_idObject (readonly)

Returns the value of attribute recipient_id

Returns:

  • (Object)

    the current value of recipient_id



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def recipient_id
  @recipient_id
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def updated_at
  @updated_at
end

#viewed_atObject (readonly)

Returns the value of attribute viewed_at

Returns:

  • (Object)

    the current value of viewed_at



6
7
8
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 6

def viewed_at
  @viewed_at
end

Class Method Details

.build(id:, communication_id:, recipient_id:, title:, status:, viewed_at:, archived_at:, deleted_at:, created_at:, updated_at:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 18

def self.build(
  id:,
  communication_id:,
  recipient_id:,
  title:,
  status:,
  viewed_at:,
  archived_at:,
  deleted_at:,
  created_at:,
  updated_at:
)
  new(
    id:,
    communication_id:,
    recipient_id:,
    title: title.to_s,
    status: status.to_s,
    viewed_at:,
    archived_at:,
    deleted_at:,
    created_at:,
    updated_at:,
  ).freeze
end

.from_record(inbox_item) ⇒ Object

Raises:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/services/command_tower/messaging/inbox/item_result.rb', line 44

def self.from_record(inbox_item)
  communication = inbox_item.communication
  raise InvariantError, "inbox item missing communication" if communication.nil?

  build(
    id: inbox_item.id,
    communication_id: inbox_item.communication_id,
    recipient_id: communication.user_id,
    title: communication.title,
    status: inbox_item.lifecycle_label,
    viewed_at: inbox_item.viewed_at,
    archived_at: inbox_item.archived_at,
    deleted_at: inbox_item.deleted_at,
    created_at: inbox_item.created_at,
    updated_at: inbox_item.updated_at,
  )
end