Class: Mudbase::SearchApi

Inherits:
Object
  • Object
show all
Defined in:
lib/mudbase/api/search_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ SearchApi



19
20
21
# File 'lib/mudbase/api/search_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/mudbase/api/search_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#search_get_analytics(project_id, opts = {}) ⇒ SearchGetAnalytics200Response

Get search analytics Get search analytics including top queries, search volume, and performance metrics. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Options Hash (opts):

  • :timeframe (String)

    Timeframe for analytics (1d, 7d, or 30d). (default to ‘7d’)



28
29
30
31
# File 'lib/mudbase/api/search_api.rb', line 28

def search_get_analytics(project_id, opts = {})
  data, _status_code, _headers = search_get_analytics_with_http_info(project_id, opts)
  data
end

#search_get_analytics_with_http_info(project_id, opts = {}) ⇒ Array<(SearchGetAnalytics200Response, Integer, Hash)>

Get search analytics Get search analytics including top queries, search volume, and performance metrics. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Options Hash (opts):

  • :timeframe (String)

    Timeframe for analytics (1d, 7d, or 30d). (default to ‘7d’)



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/mudbase/api/search_api.rb', line 39

def search_get_analytics_with_http_info(project_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SearchApi.search_get_analytics ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling SearchApi.search_get_analytics"
  end
  allowable_values = ["1d", "7d", "30d"]
  if @api_client.config.client_side_validation && opts[:'timeframe'] && !allowable_values.include?(opts[:'timeframe'])
    fail ArgumentError, "invalid value for \"timeframe\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/search/projects/{projectId}/search/analytics'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'timeframe'] = opts[:'timeframe'] if !opts[:'timeframe'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SearchGetAnalytics200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"SearchApi.search_get_analytics",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SearchApi#search_get_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_get_suggestions(project_id, q, opts = {}) ⇒ SearchGetSuggestions200Response

Get search suggestions Get search query suggestions based on partial input. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Options Hash (opts):

  • :limit (Integer)

    Maximum number of suggestions to return (1–20). (default to 10)



99
100
101
102
# File 'lib/mudbase/api/search_api.rb', line 99

def search_get_suggestions(project_id, q, opts = {})
  data, _status_code, _headers = search_get_suggestions_with_http_info(project_id, q, opts)
  data
end

#search_get_suggestions_with_http_info(project_id, q, opts = {}) ⇒ Array<(SearchGetSuggestions200Response, Integer, Hash)>

Get search suggestions Get search query suggestions based on partial input. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Options Hash (opts):

  • :limit (Integer)

    Maximum number of suggestions to return (1–20). (default to 10)



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/mudbase/api/search_api.rb', line 111

def search_get_suggestions_with_http_info(project_id, q, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SearchApi.search_get_suggestions ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling SearchApi.search_get_suggestions"
  end
  # verify the required parameter 'q' is set
  if @api_client.config.client_side_validation && q.nil?
    fail ArgumentError, "Missing the required parameter 'q' when calling SearchApi.search_get_suggestions"
  end
  if @api_client.config.client_side_validation && q.to_s.length > 50
    fail ArgumentError, 'invalid value for "q" when calling SearchApi.search_get_suggestions, the character length must be smaller than or equal to 50.'
  end

  if @api_client.config.client_side_validation && q.to_s.length < 2
    fail ArgumentError, 'invalid value for "q" when calling SearchApi.search_get_suggestions, the character length must be greater than or equal to 2.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 20
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SearchApi.search_get_suggestions, must be smaller than or equal to 20.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SearchApi.search_get_suggestions, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/api/search/projects/{projectId}/search/suggestions'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'q'] = q
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SearchGetSuggestions200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"SearchApi.search_get_suggestions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SearchApi#search_get_suggestions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_search(project_id, q, opts = {}) ⇒ SearchResponse

Full-text search Perform full-text search across collections in a project. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Options Hash (opts):

  • :collections (String)

    Comma-separated collection slugs or IDs to limit search scope.

  • :fields (String)

    Comma-separated field names to search or return in highlights.

  • :limit (Integer)

    Maximum number of results to return per page. (default to 20)

  • :page (Integer)

    Page number for pagination (1-based). (default to 1)



191
192
193
194
# File 'lib/mudbase/api/search_api.rb', line 191

def search_search(project_id, q, opts = {})
  data, _status_code, _headers = search_search_with_http_info(project_id, q, opts)
  data
end

#search_search_with_http_info(project_id, q, opts = {}) ⇒ Array<(SearchResponse, Integer, Hash)>

Full-text search Perform full-text search across collections in a project. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

Options Hash (opts):

  • :collections (String)

    Comma-separated collection slugs or IDs to limit search scope.

  • :fields (String)

    Comma-separated field names to search or return in highlights.

  • :limit (Integer)

    Maximum number of results to return per page. (default to 20)

  • :page (Integer)

    Page number for pagination (1-based). (default to 1)



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/mudbase/api/search_api.rb', line 206

def search_search_with_http_info(project_id, q, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SearchApi.search_search ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling SearchApi.search_search"
  end
  # verify the required parameter 'q' is set
  if @api_client.config.client_side_validation && q.nil?
    fail ArgumentError, "Missing the required parameter 'q' when calling SearchApi.search_search"
  end
  # resource path
  local_var_path = '/api/search/projects/{projectId}/search'.sub('{' + 'projectId' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'q'] = q
  query_params[:'collections'] = opts[:'collections'] if !opts[:'collections'].nil?
  query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SearchResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['BearerToken']

  new_options = opts.merge(
    :operation => :"SearchApi.search_search",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SearchApi#search_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end