Sha256: 5f1e0e6c868bbaeb5b2312868bb5884d67ae8bb0780ce54cbdf236aaa4fdc844

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module GiveyRuby

  class Configuration

    def client(client_options = {})
      @client ||= begin
        # TODO: ensure consumer key and secret
        @api_site   = client_options.include?(:api_site) ? client_options[:api_site] : "http://api.givey.com"
        opts        = {:site => @api_site, :authorize_url => "/#{api_version}/oauth/authorize", :token_url => "/#{api_version}/oauth/token", :raise_errors => false}
        @token_file = client_options.include?(:token_file) ? client_options[:token_file] : "../tmp/givey_token_file"
        OAuth2::Client.new(client_options[:consumer_key], client_options[:consumer_secret], opts) do |builder|
          # POST/PUT params encoders:
          builder.request :multipart
          builder.request :url_encoded
          builder.adapter :net_http
        end
      end
    end

    def api_version(version = "v1")
      @api_version  ||= version
    end

    def api_site
      @api_site
    end

    def token_file
      @token_file
    end

    def token_file=(file_path)
      @token_file = file_path
    end

  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
givey_ruby-0.0.2 lib/givey_ruby/configuration.rb
givey_ruby-0.0.1 lib/givey_ruby/configuration.rb