Class: EvernoteOAuth::Client
- Inherits:
-
Object
- Object
- EvernoteOAuth::Client
- Includes:
- BusinessNoteStore, BusinessUtils, NoteStore, SharedNoteStore, UserStore
- Defined in:
- lib/evernote_oauth/client.rb
Instance Method Summary collapse
- #authorize(token, secret, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #request_token(options = {}) ⇒ Object
Methods included from BusinessUtils
#create_business_notebook, #create_note_in_business_notebook, #get_corresponding_notebook, #list_business_notebooks
Methods included from BusinessNoteStore
Methods included from UserStore
Methods included from SharedNoteStore
Methods included from NoteStore
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/evernote_oauth/client.rb', line 9 def initialize(={}) config_file = "config/evernote.yml" if File.exist?(config_file) require 'erb' if defined?(Rails) config = YAML.load(ERB.new(File.read(config_file)).result)[Rails.env] else config = YAML.load(ERB.new(File.read(config_file)).result) end @consumer_key = config['consumer_key'] @consumer_secret = config['consumer_secret'] @sandbox = config['sandbox'] ? true : false end @consumer_key = [:consumer_key] || @consumer_key @consumer_secret = [:consumer_secret] || @consumer_secret @sandbox = true if @sandbox == nil @sandbox = ([:sandbox] == nil ? @sandbox : [:sandbox]) @service_host = [:service_host] || (@sandbox ? 'sandbox.evernote.com' : 'www.evernote.com') @additional_headers = [:additional_headers] @token = [:token] @secret = [:secret] end |
Instance Method Details
#authorize(token, secret, options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/evernote_oauth/client.rb', line 33 def (token, secret, ={}) request_token = OAuth::RequestToken.new(consumer, token, secret) @access_token = request_token.get_access_token() @token = @access_token.token @secret = @access_token.secret @access_token end |
#request_token(options = {}) ⇒ Object
41 42 43 44 |
# File 'lib/evernote_oauth/client.rb', line 41 def request_token(={}) consumer.[:authorize_path] = '/OAuth.action' consumer.get_request_token() end |