Sha256: 30215bdbbc3e3d40843175d515638792c6501bc93b98195e4510be90bebde586

Contents?: true

Size: 369 Bytes

Versions: 4

Compression:

Stored size: 369 Bytes

Contents

require "json"

module DiscountNetwork
  class Response
    attr_reader :response

    def initialize(response)
      @response = response
    end

    def parse
      JSON.parse(response, object_class: ResponseObject)
    rescue JSON::ParserError => error
      ResponseObject.new(error: error, content: "")
    end
  end

  class ResponseObject < OpenStruct; end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
discountnetwork-0.1.3 lib/discountnetwork/response.rb
discountnetwork-0.1.2 lib/discountnetwork/response.rb
discountnetwork-0.1.1 lib/discountnetwork/response.rb
discountnetwork-0.1.0 lib/discountnetwork/response.rb