class Bsale::Base

Constants

BASE_URL

Public Instance Methods

raise_if_invalid!(resp) click to toggle source
# File lib/bsale/base.rb, line 11
def raise_if_invalid!(resp)
  raise ServerError, "Server Error" if resp.status > 499
  raise NotFoundError, "Not Found" if resp.status == 404
  raise UnauthorizedError, "Unauthorized request" if resp.status == 401
  raise AccessForbiddenError, "Access Forbidden" if resp.status == 403
end
to_h(empty = true) click to toggle source
# File lib/bsale/base.rb, line 5
def to_h(empty = true)
  hash = self.instance_variables.each_with_object({}) { |v, h| h[v.to_s.delete("@")] = self.instance_variable_get(v) }
  hash.delete("connection")
  hash.delete_if {|k,v| v.nil? }
end