Class: Teams::Api::ConversationReference
- Inherits:
-
Object
- Object
- Teams::Api::ConversationReference
- Defined in:
- lib/teams/api/conversation_reference.rb
Instance Attribute Summary collapse
-
#activity_id ⇒ Object
readonly
Returns the value of attribute activity_id.
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#conversation ⇒ Object
readonly
Returns the value of attribute conversation.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#service_url ⇒ Object
readonly
Returns the value of attribute service_url.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #conversation_id ⇒ Object
-
#initialize(activity_id: nil, user: nil, locale: nil, bot:, conversation:, channel_id:, service_url:) ⇒ ConversationReference
constructor
A new instance of ConversationReference.
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(activity_id: nil, user: nil, locale: nil, bot:, conversation:, channel_id:, service_url:) ⇒ ConversationReference
Returns a new instance of ConversationReference.
36 37 38 39 40 41 42 43 44 |
# File 'lib/teams/api/conversation_reference.rb', line 36 def initialize(activity_id: nil, user: nil, locale: nil, bot:, conversation:, channel_id:, service_url:) @activity_id = activity_id @user = wrap_account(user) @locale = locale @bot = wrap_account(bot) @conversation = wrap_conversation(conversation) @channel_id = channel_id @service_url = service_url end |
Instance Attribute Details
#activity_id ⇒ Object (readonly)
Returns the value of attribute activity_id.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def activity_id @activity_id end |
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def bot @bot end |
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def channel_id @channel_id end |
#conversation ⇒ Object (readonly)
Returns the value of attribute conversation.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def conversation @conversation end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def locale @locale end |
#service_url ⇒ Object (readonly)
Returns the value of attribute service_url.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def service_url @service_url end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/teams/api/conversation_reference.rb', line 8 def user @user end |
Class Method Details
.from_activity(activity) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/teams/api/conversation_reference.rb', line 10 def self.from_activity(activity) new( activity_id: activity.id, user: activity.from, locale: activity.locale, bot: activity.recipient, conversation: activity.conversation, channel_id: activity.channel_id, service_url: activity.service_url ) end |
.from_h(raw) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/teams/api/conversation_reference.rb', line 22 def self.from_h(raw) raw = raw.to_h if raw.respond_to?(:to_h) new( activity_id: raw["activityId"] || raw["activity_id"] || raw[:activityId] || raw[:activity_id], user: raw["user"] || raw[:user], locale: raw["locale"] || raw[:locale], bot: raw.fetch("bot") { raw.fetch(:bot) }, conversation: raw.fetch("conversation") { raw.fetch(:conversation) }, channel_id: raw["channelId"] || raw["channel_id"] || raw[:channelId] || raw[:channel_id], service_url: raw["serviceUrl"] || raw["service_url"] || raw[:serviceUrl] || raw[:service_url] ) end |
Instance Method Details
#conversation_id ⇒ Object
46 47 48 |
# File 'lib/teams/api/conversation_reference.rb', line 46 def conversation_id conversation.id end |
#to_h ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/teams/api/conversation_reference.rb', line 50 def to_h body = { "bot" => bot.to_h, "conversation" => conversation.to_h, "channelId" => channel_id, "serviceUrl" => service_url } body["activityId"] = activity_id if activity_id body["user"] = user.to_h if user body["locale"] = locale if locale body end |
#to_json(*args) ⇒ Object
63 64 65 |
# File 'lib/teams/api/conversation_reference.rb', line 63 def to_json(*args) JSON.generate(to_h, *args) end |