Class: GiveyRuby::Configuration

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

Instance Method Summary collapse

Instance Method Details

#api_siteObject



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

def api_site
  @api_site
end

#api_versionObject



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

def api_version
  @api_version
end

#client(client_options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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"
    @api_version = client_options.include?(:api_version) ? client_options[:api_version] : "v2"
    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



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

def token_file
  @token_file
end

#token_file=(file_path) ⇒ Object



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

def token_file=(file_path)
  @token_file = file_path
end