module FeedBurner
Constants
- VERSION
Public Class Methods
feed(params, timeout = 10)
click to toggle source
# File lib/feed_burner.rb, line 12 def feed(params, timeout = 10) validate_params!(params) response = Timeout::timeout(timeout) do ::Faraday.get(request_uri(params)) end JSON.parse(response.body) end
Private Class Methods
encrypted_token(uri)
click to toggle source
# File lib/feed_burner.rb, line 39 def encrypted_token(uri) OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), api_key.to_s, uri) end
request_uri(params)
click to toggle source
# File lib/feed_burner.rb, line 28 def request_uri(params) uri = "http://localhost:3000/api/v1/feeds/#{params[:trip_id]}?" uri << "username=#{params[:username]}" uri << "×tamp=#{Time.now.to_i}" uri << "&text_only=#{params[:text_only]}" if params[:text_only] signature = encrypted_token(uri) uri << "&signature=#{signature}" end
validate_params!(params)
click to toggle source
# File lib/feed_burner.rb, line 22 def validate_params!(params) unless params[:trip_id].is_a?(String) && params[:username].is_a?(String) raise ArgumentError, "Invalid arguments specified: #{params}. Coordinator and Trip are required." end end