Sha256: 32b748ce704a0f59705c4e7797718ca9f84d627b5fa71c06d33040fa07a3244d

Contents?: true

Size: 579 Bytes

Versions: 6

Compression:

Stored size: 579 Bytes

Contents

module OmiseGO
  class Response
    def initialize(body, client)
      @body = body
      @client = client
      @config = @client.config
    end

    def success?
      @success ||= @body['success'] == true
    end

    def version
      @version ||= @body['version']
    end

    def data
      type = @body['data']['object'].to_sym
      unless @config[:models] && @config[:models].keys.include?(type)
        raise "Unknown Object '#{@body['data']['object']}'"
      end

      klass = @config[:models][type]
      klass.new(@body['data'], client: @client)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
omisego-0.12.0 lib/omisego/response.rb
omisego-0.11.0 lib/omisego/response.rb
omisego-0.10.0 lib/omisego/response.rb
omisego-0.9.6 lib/omisego/response.rb
omisego-0.9.5 lib/omisego/response.rb
omisego-0.9.4 lib/omisego/response.rb