Sha256: 65ae38a627631e461cd11e5377aae807d67f269168015af9a34d9421e7c45b8a

Contents?: true

Size: 532 Bytes

Versions: 4

Compression:

Stored size: 532 Bytes

Contents

require 'forwardable'
require 'nokogiri'

module Peddler
  class ResponseWrapper
    extend Forwardable

    def_delegator :response, :body

    attr :response

    def initialize(response)
      @response = response
    end

    def document
      Nokogiri::XML(body)
    end

    def xml_payload
      root = document.root
      path = root.name.sub('Response', 'Result')

      root.xpath("xmlns:#{path}")
    end

    def next_token
      node = xml_payload.at_xpath('xmlns:NextToken')
      node.text if node
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
peddler-0.6.3 lib/peddler/response_wrapper.rb
peddler-0.6.2 lib/peddler/response_wrapper.rb
peddler-0.6.1 lib/peddler/response_wrapper.rb
peddler-0.6.0 lib/peddler/response_wrapper.rb