lib/vacuum/response.rb in vacuum-2.2.0 vs lib/vacuum/response.rb in vacuum-3.0.0
- old
+ new
@@ -1,36 +1,25 @@
# frozen_string_literal: true
require 'delegate'
require 'forwardable'
-require 'multi_xml'
+require 'json'
module Vacuum
- # A wrapper around the Amazon Product Advertising API response.
+ # A wrapper around the API response
class Response < SimpleDelegator
extend Forwardable
- class << self
- attr_accessor :parser
- end
-
+ # @!method dig(*key)
+ # Delegates to {Response#to_h} to extract a nested value specified by the
+ # sequence of keys
+ # @param [String] key
+ # @see Hash#dig
def_delegator :to_h, :dig
- attr_writer :parser
-
- def parser
- @parser || self.class.parser
- end
-
- def parse
- parser ? parser.parse(body) : to_h
- end
-
+ # Casts body to Hash
+ # @return [Hash]
def to_h
- MultiXml.parse(body)
- end
-
- def body
- (+__getobj__.body).force_encoding(Encoding::UTF_8)
+ JSON.parse(body)
end
end
end