class ApiStruct::Errors::Client

Attributes

body[R]
error[R]
status[R]

Public Class Methods

new(response) click to toggle source
# File lib/api_struct/errors/client.rb, line 6
def initialize(response)
  if response.is_a?(Hash)
    @status = response[:status]
    @body = response[:body]
  else
    @status = response.status
    @body = parse_body(response.body.to_s)
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/api_struct/errors/client.rb, line 16
def to_s
  error
end

Private Instance Methods

parse_body(b) click to toggle source
# File lib/api_struct/errors/client.rb, line 36
def parse_body(b)
  !b.empty? ? JSON.parse(b, symbolize_names: true) : nil
rescue JSON::ParserError
  b
end