lib/firstgiving/base.rb in firstgiving-1.0.0 vs lib/firstgiving/base.rb in firstgiving-1.0.1
- old
+ new
@@ -1,15 +1,13 @@
require 'faraday'
module FirstGiving
-
module Base
+ DONATION_SANDBOX_ENDPOINT = 'http://usapisandbox.fgdev.net'
+ DONATION_PRODUCTION_ENDPOINT = 'https://api.firstgiving.com'
+ SEARCH_ENDPOINT = 'http://graphapi.firstgiving.com'
- DONATION_SANDBOX_ENDPOINT = "http://usapisandbox.fgdev.net"
- DONATION_PRODUCTION_ENDPOINT = "https://api.firstgiving.com"
- SEARCH_ENDPOINT = "http://graphapi.firstgiving.com"
-
def headers_json
{
'User-Agent' => 'FirstGiving Ruby SDK',
'Content-Type' => 'application/json'
}
@@ -21,37 +19,35 @@
'JG_SECURITYTOKEN' => "#{FirstGiving.configuration.security_token}"
}
end
def post_call(api_endpoint, action, params, headers)
- conn = Faraday.new(:url => api_endpoint) do |faraday|
+ conn = Faraday.new(url: api_endpoint) do |faraday|
faraday.request :url_encoded
faraday.adapter Faraday.default_adapter
end
- response = conn.post do |req|
+ conn.post do |req|
req.url action
req.params = params
req.headers = headers
end
end
def get_call(api_endpoint, action, params, headers)
- conn = Faraday.new(:url => api_endpoint) do |faraday|
+ conn = Faraday.new(url: api_endpoint) do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
- response = conn.get do |req|
+ conn.get do |req|
req.url action
req.params = params
req.headers = headers
end
end
def logging(msg)
puts "[FG-LOG] #{msg}" if FirstGiving.configuration.options[:verbose]
end
-
end
end
-