Sha256: b88b045d8ba437052323c09b779b50d607a102cddcc8486c36fbd8dbfd584737
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'rest-client' require 'oj' module SiebelDonations class Base def initialize(json = {}) json.each do |key, value| instance_variable_set("@#{key.underscore}", value) end end def self.get(path, params) raise 'You need to configure SiebelDonations with your oauth_token.' unless SiebelDonations.oauth_token params[:response_timeout] ||= SiebelDonations.default_timeout url = SiebelDonations.base_url + path RestClient::Request.execute(:method => :get, :url => url, :headers => {params: params, authorization: "Bearer #{SiebelDonations.oauth_token}"}, :timeout => -1) { |response, request, result, &block| case response.code when 200 Oj.load(response) when 400 raise RestClient::ExceptionWithResponse, response.to_s else puts response.inspect puts request.inspect raise result.inspect end } end def self.find(params) get(path, params).collect { |json| new(json) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
siebel_donations-1.0.3 | lib/siebel_donations/base.rb |