Sha256: 78c3a919bd77889dcd86e7d57fc1845a8e65b076be6d0efbcae8018faf30ea3e

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

module Rapa
  module Responses
    class SearchItemsResponse < BaseResponse
      # @return [Rapa::Error]
      def error
        if value = body.dig("ItemSearchResponse", "Items", "Request", "Errors", "Error")
          ::Rapa::Error.new(value)
        end
      end

      # @return [Boolean]
      def has_error?
        !error.nil?
      end

      # @return [Boolean]
      def has_valid_request?
        body.dig("ItemSearchResponse", "Items", "Request", "IsValid") == "True"
      end

      # @return [Integer, nil]
      def total_pages
        if value = body.dig("ItemSearchResponse", "Items", "TotalPages")
          value.to_i
        end
      end

      # @return [Integer, nil]
      def total_results
        if value = body.dig("ItemSearchResponse", "Items", "TotalResults")
          value.to_i
        end
      end

      private

      # @note Override
      def resource_class
        ::Rapa::Resources::ItemResource
      end

      # @note Override
      def source_or_sources
        body.dig("ItemSearchResponse", "Items", "Item")
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rapa-0.5.7 lib/rapa/responses/search_items_response.rb
rapa-0.5.6 lib/rapa/responses/search_items_response.rb
rapa-0.5.5 lib/rapa/responses/search_items_response.rb
rapa-0.5.4 lib/rapa/responses/search_items_response.rb
rapa-0.5.3 lib/rapa/responses/search_items_response.rb
rapa-0.5.2 lib/rapa/responses/search_items_response.rb
rapa-0.5.1 lib/rapa/responses/search_items_response.rb
rapa-0.5.0 lib/rapa/responses/search_items_response.rb
rapa-0.4.3 lib/rapa/responses/search_items_response.rb
rapa-0.4.2 lib/rapa/responses/search_items_response.rb
rapa-0.4.1 lib/rapa/responses/search_items_response.rb
rapa-0.4.0 lib/rapa/responses/search_items_response.rb
rapa-0.3.3 lib/rapa/responses/search_items_response.rb
rapa-0.3.2 lib/rapa/responses/search_items_response.rb
rapa-0.3.1 lib/rapa/responses/search_items_response.rb
rapa-0.3.0 lib/rapa/responses/search_items_response.rb