module SocialPilot
Constants
- API_BASE
- VERSION
Attributes
access_token[W]
Public Class Methods
access_token()
click to toggle source
# File lib/social_pilot.rb, line 18 def access_token end
request(method, resource, params={})
click to toggle source
# File lib/social_pilot.rb, line 24 def request method, resource, params={} vd_access_token = params[:access_token] || SocialPilot.access_token params.merge!({access_token: vd_access_token}) defined? vd_access_token or raise( ConfigurationError, "SocialPilot access token not configured" ) defined? method or raise( ArgumentError, "Request method has not been specified" ) defined? resource or raise( ArgumentError, "Request resource has not been specified" ) headers = { :accept => :json, content_type: :json }.merge({params: params}) RestClient::Request.new({ method: method, url: API_BASE + resource, headers: headers }).execute do |response, request, result| str_response = response.to_str str_response.blank? ? '' : JSON.parse(str_response) end end