Class: Teams::Api::SearchResponse

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

Overview

Response body for application/search invokes (Adaptive Card dynamic typeahead Input.ChoiceSet queries). results accepts SearchInvokeResult objects or value: hashes.

Instance Method Summary collapse

Constructor Details

#initialize(results, status_code: 200) ⇒ SearchResponse

Returns a new instance of SearchResponse.



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

def initialize(results, status_code: 200)
  @results = results
  @status_code = status_code
end

Instance Method Details

#to_hObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/teams/api/search.rb', line 27

def to_h
  {
    "statusCode" => @status_code,
    "type" => "application/vnd.microsoft.search.searchResponse",
    "value" => {
      "results" => Array(@results).map do |result|
        body = result.is_a?(Hash) ? result : result.to_h
        Common::Hashes.deep_stringify_keys(body)
      end
    }
  }
end