Class: OmiseGO::Response
- Inherits:
-
Object
- Object
- OmiseGO::Response
- Defined in:
- lib/omisego/response.rb
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(body, client) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #version ⇒ Object
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
#data ⇒ Object
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
9 10 11 |
# File 'lib/omisego/response.rb', line 9 def success? @success ||= @body['success'] == true end |
#version ⇒ Object
13 14 15 |
# File 'lib/omisego/response.rb', line 13 def version @version ||= @body['version'] end |