Sha256: 26891b4e569e66525f19edea243167a07618aaf7d2944318bb6d2aecd6a6a267
Contents?: true
Size: 1.25 KB
Versions: 12
Compression:
Stored size: 1.25 KB
Contents
module RestfulResource class HttpClient class UnprocessableEntity < RuntimeError attr_reader :response def initialize(response) @response = Response.new(body: response.body, headers: response.headers, status: response.code) end end def initialize(authorization: nil) @authorization = authorization end def get(url) response = RestClient.get(url, :accept => :json, authorization: @authorization) Response.new(body: response.body, headers: response.headers, status: response.code) end def put(url, data: {}) begin response = RestClient.put(url, data, :accept => :json, authorization: @authorization) rescue RestClient::UnprocessableEntity => e raise HttpClient::UnprocessableEntity.new(e.response) end Response.new(body: response.body, headers: response.headers, status: response.code) end def post(url, data: {}) begin response = RestClient.post(url, data, :accept => :json, authorization: @authorization) rescue RestClient::UnprocessableEntity => e raise HttpClient::UnprocessableEntity.new(e.response) end Response.new(body: response.body, headers: response.headers, status: response.code) end end end
Version data entries
12 entries across 12 versions & 1 rubygems