Class: Teams::Api::SentActivity

Inherits:
Object
  • Object
show all
Defined in:
lib/teams/api/sent_activity.rb

Overview

Represents an activity that was sent: the outbound activity merged with the server response, so the server-assigned id is always available. Mirrors the SDKs' SentActivity.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw = {}) ⇒ SentActivity

Returns a new instance of SentActivity.



19
20
21
# File 'lib/teams/api/sent_activity.rb', line 19

def initialize(raw = {})
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



9
10
11
# File 'lib/teams/api/sent_activity.rb', line 9

def raw
  @raw
end

Class Method Details

.merge(activity, response) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/teams/api/sent_activity.rb', line 11

def self.merge(activity, response)
  activity_hash = activity.respond_to?(:to_h) ? activity.to_h : activity
  activity_hash = {} unless activity_hash.is_a?(Hash)
  response_hash = response.is_a?(Hash) ? response : {}

  new(activity_hash.merge(response_hash))
end

Instance Method Details

#[](key) ⇒ Object



39
40
41
# File 'lib/teams/api/sent_activity.rb', line 39

def [](key)
  raw[key]
end

#conversation_idObject



35
36
37
# File 'lib/teams/api/sent_activity.rb', line 35

def conversation_id
  raw.dig("conversation", "id")
end

#idObject



23
24
25
# File 'lib/teams/api/sent_activity.rb', line 23

def id
  raw["id"] || raw[:id]
end

#textObject



31
32
33
# File 'lib/teams/api/sent_activity.rb', line 31

def text
  raw["text"]
end

#to_hObject



43
44
45
# File 'lib/teams/api/sent_activity.rb', line 43

def to_h
  raw.dup
end

#typeObject



27
28
29
# File 'lib/teams/api/sent_activity.rb', line 27

def type
  raw["type"]
end