class RubyVibe::Response

Attributes

response[RW]

Public Class Methods

new(response) click to toggle source
# File lib/ruby-vibe/response.rb, line 6
def initialize(response)
  @response = response
end
parse(response) click to toggle source
# File lib/ruby-vibe/response.rb, line 11
def parse(response)
  response = new(response)
  response.parse
end

Public Instance Methods

parse() click to toggle source
# File lib/ruby-vibe/response.rb, line 17
def parse
  success       = true
  error_message = nil
  hash          = JSON.parse(response.body)

  unless hash.dig('status').to_i == 0
    success = false 
    error_message =  hash.dig('status_message')
  end
 
  Struct.new(:success?, :hash, :error_message).new(success, hash, error_message)
end