lib/dailycred.rb in dailycred-0.1.21 vs lib/dailycred.rb in dailycred-0.1.22

- old
+ new

@@ -2,24 +2,31 @@ require "omniauth/strategies/dailycred" require "middleware/middleware" class Dailycred - attr_accessor :client_id, :secret_key, :options + attr_accessor :client_id, :secret_key, :options, :url + URL = "https://www.dailycred.com" + + ROUTES = { + :signup => "/user/api/signup.json", + :login => "/user/api/signin.json" + } + # Initializes a dailycred object # @param [String] client_id the client's daiycred client id # @param [String] secret_key the clients secret key # @param [Hash] opts a hash of options def initialize(client_id, secret_key="", opts={}) @client_id = client_id @secret_key = secret_key @options = opts + opts[:client_options] ||= {} + @url = opts[:client_options][:site] || Dailycred::URL end - URL = "https://www.dailycred.com" - # Generates a Dailycred event # @param [String] user_id the user's dailycred user id # @param [String] key the name of the event type # @param [String] val the value of the event (optional) def event(user_id, key, val="") @@ -40,37 +47,32 @@ :tag => tag } post "/admin/api/user/tag.json", opts end - # Untag a user in dailycred + # Untag a user in dailycred # (see #tag) def untag(user_id, tag) opts = { :user_id => user_id, :tag => tag } post "/admin/api/user/untag.json", opts end - private - def post(url, opts) opts.merge! base_opts - p opts response = get_conn.post url, opts - p response.body end + private + def ssl_opts opts = {} - p @options - p " ^^^^ @options " if @options[:client_options] && @options[:client_options][:ssl] opts[:ssl] = @options[:client_options][:ssl] end - p opts opts end def base_opts { @@ -78,9 +80,8 @@ :client_secret => @secret_key } end def get_conn - p ssl_opts - Faraday::Connection.new Dailycred::URL, ssl_opts + Faraday::Connection.new @url, ssl_opts end end