Class: GiveyRuby::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/givey_ruby/configuration.rb

Instance Method Summary collapse

Instance Method Details

#api_siteObject



24
25
26
# File 'lib/givey_ruby/configuration.rb', line 24

def api_site
  @api_site
end

#api_version(version = "v1") ⇒ Object



20
21
22
# File 'lib/givey_ruby/configuration.rb', line 20

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

#client(client_options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/givey_ruby/configuration.rb', line 5

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

#token_fileObject



28
29
30
# File 'lib/givey_ruby/configuration.rb', line 28

def token_file
  @token_file
end

#token_file=(file_path) ⇒ Object



32
33
34
# File 'lib/givey_ruby/configuration.rb', line 32

def token_file=(file_path)
  @token_file = file_path
end