Class: Teams::Api::MessagingExtensionActionResponse

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

Overview

Response for the action-style invokes (submitAction, fetchTask): either a dialog via task: (a TaskModuleContinueResponse / TaskModuleMessageResponse) or a result via compose_extension:.

Instance Method Summary collapse

Constructor Details

#initialize(task: nil, compose_extension: nil, cache_info: nil) ⇒ MessagingExtensionActionResponse

Returns a new instance of MessagingExtensionActionResponse.



92
93
94
95
96
# File 'lib/teams/api/message_extension.rb', line 92

def initialize(task: nil, compose_extension: nil, cache_info: nil)
  @task = task
  @compose_extension = compose_extension
  @cache_info = cache_info
end

Instance Method Details

#to_hObject



98
99
100
101
102
103
104
105
106
107
# File 'lib/teams/api/message_extension.rb', line 98

def to_h
  body = {}
  body["task"] = @task.respond_to?(:to_h) ? @task.to_h : @task if @task
  if @compose_extension
    body["composeExtension"] =
      @compose_extension.respond_to?(:to_h) ? @compose_extension.to_h : @compose_extension
  end
  body["cacheInfo"] = Common::Hashes.deep_stringify_keys(@cache_info) if @cache_info
  body
end