evernote_oauth 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
+ [![Gem Version](https://badge.fury.io/rb/evernote_oauth.png)](http://badge.fury.io/rb/evernote_oauth)
2
+
1
3
  Evernote OAuth / Thrift API client library for Ruby
2
4
  ===================================================
3
- - Evernote OAuth version 0.1.4
5
+ - Evernote OAuth version 0.1.6
4
6
 
5
7
  Install the gem
6
8
  ---------------
@@ -57,21 +59,14 @@ notebooks = note_store.listNotebooks(token)
57
59
  Once you acquire token, you can use UserStore. For example, if you want to call UserStore.getUser:
58
60
  ```ruby
59
61
  user_store = EvernoteOAuth::Client.new(token: token).user_store
60
- user_store.getUser(token)
61
- ```
62
- You can also omit authenticationToken in the arguments of UserStore functions:
63
- ```ruby
64
62
  user_store.getUser
65
63
  ```
64
+ You can omit authenticationToken in the arguments of UserStore/NoteStore functions:
66
65
 
67
66
  ### NoteStore ###
68
67
  If you want to call NoteStore.listNotebooks:
69
68
  ```ruby
70
69
  note_store = EvernoteOAuth::Client.new(token: token).note_store
71
- note_store.listNotebooks(token)
72
- ```
73
- You can also omit authenticationToken in the arguments of NoteStore functions:
74
- ```ruby
75
70
  note_store.listNotebooks
76
71
  ```
77
72
 
@@ -80,12 +75,6 @@ If you want to get tags for linked notebooks:
80
75
  ```ruby
81
76
  linked_notebook = note_store.listLinkedNotebooks.first # any notebook
82
77
  shared_note_store = client.shared_note_store(linked_notebook)
83
- stoken = shared_note_store.token
84
- shared_notebook = shared_note_store.getSharedNotebookByAuth(stoken)
85
- shared_note_store.listTagsByNotebook(stoken, shared_notebook.notebookGuid)
86
- ```
87
- You can also omit authenticationToken in the arguments of NoteStore functions:
88
- ```ruby
89
78
  shared_notebook = shared_note_store.getSharedNotebookByAuth
90
79
  shared_note_store.listTagsByNotebook(shared_notebook.notebookGuid)
91
80
  ```
@@ -93,14 +82,12 @@ shared_note_store.listTagsByNotebook(shared_notebook.notebookGuid)
93
82
  ### NoteStore for Business ###
94
83
  If you want to get the list of notebooks in your business account:
95
84
  ```ruby
85
+ user_store = client.user_store
86
+ user = user_store.getUser
96
87
  business_note_store = client.business_note_store
97
- btoken = business_note_store.token
98
- business_note_store.listNotebooks(btoken)
99
- ```
100
- You can also omit authenticationToken in the arguments of NoteStore functions:
101
- ```ruby
102
- business_note_store = client.business_note_store
103
- business_note_store.listNotebooks
88
+ if user.belongs_to_business?
89
+ business_note_store.listNotebooks
90
+ end
104
91
  ```
105
92
 
106
93
  ### Method Chaining ###
@@ -0,0 +1,14 @@
1
+ module Evernote
2
+ module EDAM
3
+ module Type
4
+ class User
5
+ def belongs_to_business?
6
+ self.accounting.businessId != nil
7
+ end
8
+ def business_name
9
+ self.accounting.businessName
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -59,9 +59,15 @@ module EvernoteOAuth
59
59
  end
60
60
 
61
61
  def thrift_client(client_class, url)
62
+ if m = /:A=(.+):/.match(@token)
63
+ key_id = m[1]
64
+ else
65
+ key_id = @consumer_key || 'nil'
66
+ end
67
+
62
68
  transport = Thrift::HTTPClientTransport.new(url)
63
69
  transport.add_headers(
64
- 'User-Agent' => "EvernoteOAuth / #{::EvernoteOAuth::VERSION}; Ruby / #{RUBY_VERSION};"
70
+ 'User-Agent' => "#{key_id} / #{::EvernoteOAuth::VERSION}; Ruby / #{RUBY_VERSION};"
65
71
  )
66
72
  transport.add_headers(@additional_headers) if @additional_headers
67
73
  protocol = Thrift::BinaryProtocol.new(transport)
@@ -1,3 +1,3 @@
1
1
  module EvernoteOAuth
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'evernote_oauth/store_attachable'
2
2
 
3
+ require 'evernote/edam/type/user'
3
4
  require 'evernote/edam/type/note'
4
5
  require 'evernote/edam/type/resource'
5
6
  require 'evernote/edam/type/shared_notebook'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evernote_oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-14 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
@@ -77,6 +77,7 @@ files:
77
77
  - lib/evernote/edam/type/resource.rb
78
78
  - lib/evernote/edam/type/shared_notebook.rb
79
79
  - lib/evernote/edam/type/tag.rb
80
+ - lib/evernote/edam/type/user.rb
80
81
  - lib/evernote_oauth/business_note_store.rb
81
82
  - lib/evernote_oauth/client.rb
82
83
  - lib/evernote_oauth/note_store.rb