Class: OmiseGO::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/omisego/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(body, client) ⇒ Response

Returns a new instance of Response.



3
4
5
6
7
# File 'lib/omisego/response.rb', line 3

def initialize(body, client)
  @body = body
  @client = client
  @config = @client.config
end

Instance Method Details

#dataObject



17
18
19
20
21
22
23
24
25
# File 'lib/omisego/response.rb', line 17

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

#success?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/omisego/response.rb', line 9

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

#versionObject



13
14
15
# File 'lib/omisego/response.rb', line 13

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