Class: Mindee::V2::Parsing::Search::BaseSearchResponse

Inherits:
CommonResponse
  • Object
show all
Defined in:
lib/mindee/v2/parsing/search/base_search_response.rb

Overview

Base class for search responses.

Instance Attribute Summary collapse

Attributes inherited from CommonResponse

#raw_http

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ BaseSearchResponse

Returns a new instance of BaseSearchResponse.

Parameters:

  • http_response (Hash) —

    The parsed JSON payload from the API.



14
15
16
17
18
# File 'lib/mindee/v2/parsing/search/base_search_response.rb', line 14

def initialize(http_response)
  super

  @pagination = PaginationMetadata.new(http_response['pagination'])
end

Instance Attribute Details

#pagination ⇒ Mindee::V2::Parsing::Search::PaginationMetadata (readonly)

Pagination metadata.



11
12
13
# File 'lib/mindee/v2/parsing/search/base_search_response.rb', line 11

def pagination
  @pagination
end

Instance Method Details

#body_lines ⇒ Array<String>

Lines composing the response-specific body (header + items).

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/mindee/v2/parsing/search/base_search_response.rb', line 22

def body_lines
  raise NotImplementedError, 'body_lines must be implemented in subclasses'
end

#pagination_metadata ⇒ Mindee::V2::Parsing::Search::PaginationMetadata

Deprecated.

Use #pagination instead.

Pagination metadata (Obsolete).



29
30
31
# File 'lib/mindee/v2/parsing/search/base_search_response.rb', line 29

def 
  pagination
end

#to_s ⇒ String

String representation of the search response.

Returns:

  • (String)


35
36
37
38
39
40
41
42
# File 'lib/mindee/v2/parsing/search/base_search_response.rb', line 35

def to_s
  lines = body_lines
  lines.push('Pagination Metadata')
  lines.push('###################')
  lines.push(@pagination.to_s)

  lines.join("\n")
end