Class: Rapa::Responses::SearchItemsResponse

Inherits:
MultipleResourcesResponse show all
Defined in:
lib/rapa/responses/multiple_resources_response/search_items_response.rb

Instance Method Summary collapse

Methods inherited from MultipleResourcesResponse

#each, #resources

Methods inherited from BaseResponse

#body, #headers, #initialize, #status

Constructor Details

This class inherits a constructor from Rapa::Responses::BaseResponse

Instance Method Details

#errorRapa::Error

Returns:



5
6
7
8
9
# File 'lib/rapa/responses/multiple_resources_response/search_items_response.rb', line 5

def error
  if value = body.dig("ItemSearchResponse", "Items", "Request", "Errors", "Error")
    ::Rapa::Error.new(value)
  end
end

#has_error?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rapa/responses/multiple_resources_response/search_items_response.rb', line 12

def has_error?
  !error.nil?
end

#has_valid_request?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rapa/responses/multiple_resources_response/search_items_response.rb', line 17

def has_valid_request?
  body.dig("ItemSearchResponse", "Items", "Request", "IsValid") == "True"
end

#total_pagesInteger?

Returns:

  • (Integer, nil)


22
23
24
25
26
# File 'lib/rapa/responses/multiple_resources_response/search_items_response.rb', line 22

def total_pages
  if value = body.dig("ItemSearchResponse", "Items", "TotalPages")
    value.to_i
  end
end

#total_resultsInteger?

Returns:

  • (Integer, nil)


29
30
31
32
33
# File 'lib/rapa/responses/multiple_resources_response/search_items_response.rb', line 29

def total_results
  if value = body.dig("ItemSearchResponse", "Items", "TotalResults")
    value.to_i
  end
end