Class: Twilio::REST::Knowledge::V2::SearchContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/knowledge/v2/search.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, kb_id) ⇒ SearchContext

Initialize the SearchContext

Parameters:

  • version (Version)

    Version that contains the resource

  • kb_id (String)

    A unique Knowledge Base ID using Twilio Type ID (TTID) format



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 71

def initialize(version, kb_id)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)

    # Path Solution
    @solution = { kb_id: kb_id,  }
    @uri = "/KnowledgeBases/#{@solution[:kb_id]}/Search"

    
end

Instance Method Details

#create(knowledge_search: :unset) ⇒ SearchInstance

Create the SearchInstance

Parameters:

  • knowledge_search (KnowledgeSearch) (defaults to: :unset)

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 86

def create(knowledge_search: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.create('POST', @uri, headers: headers, data: knowledge_search.to_json)
    SearchInstance.new(
        @version,
        payload,
        kb_id: @solution[:kb_id],
    )
end

#create_with_metadata(knowledge_search: :unset) ⇒ SearchInstance

Create the SearchInstanceMetadata

Parameters:

  • knowledge_search (KnowledgeSearch) (defaults to: :unset)

Returns:



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 107

def (knowledge_search: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('POST', @uri, headers: headers, data: knowledge_search.to_json)
    search_instance = SearchInstance.new(
        @version,
        response.body,
        kb_id: @solution[:kb_id],
    )
    SearchInstanceMetadata.new(
        @version,
        search_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



140
141
142
143
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 140

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Knowledge.V2.SearchContext #{context}>"
end

#to_sObject

Provide a user friendly representation



133
134
135
136
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 133

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Knowledge.V2.SearchContext #{context}>"
end