Class: Evertils::Common::Authentication
- Inherits:
-
Generic
- Object
- Generic
- Evertils::Common::Authentication
show all
- Includes:
- Singleton
- Defined in:
- lib/evertils/common/authentication.rb
Overview
Instance Method Summary
collapse
Methods inherited from Generic
#bytesize, #deprecation_notice, #encoding, #force_encoding, #has_required_fields
Constructor Details
Returns a new instance of Authentication.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/evertils/common/authentication.rb', line 8
def initialize
begin
prepare_user
Notify.error("Evernote developer token is not configured properly!\n$EVERTILS_TOKEN == nil") if Evertils.token.nil?
Notify.error("Evernote API requires an update. Latest version is #{@version}") if requires_update
prepare_note_store
rescue Evernote::EDAM::Error::EDAMUserException => e
handle_edam_errors(e)
rescue Evernote::EDAM::Error::EDAMSystemException => e
handle_edam_errors(e)
end
end
|
Instance Method Details
#call(func, *args) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/evertils/common/authentication.rb', line 38
def call(func, *args)
begin
if args.size > 0
@noteStore.method(func.to_s).call(Evertils.token, *args)
else
@noteStore.method(func.to_s).call(Evertils.token)
end
rescue Evernote::EDAM::Error::EDAMUserException => e
handle_edam_errors(e)
rescue Evernote::EDAM::Error::EDAMSystemException => e
handle_edam_errors(e)
end
end
|
#call_user(func, *args) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/evertils/common/authentication.rb', line 52
def call_user(func, *args)
begin
if args.size > 0
@userStore.method(func.to_s).call(*args)
else
@userStore.method(func.to_s).call
end
rescue Evernote::EDAM::Error::EDAMUserException => e
handle_edam_errors(e)
rescue Evernote::EDAM::Error::EDAMSystemException => e
handle_edam_errors(e)
end
end
|
#info ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/evertils/common/authentication.rb', line 26
def info
{
user: {
name: @user.name,
username: @user.username,
id: @user.id
},
shard: @user.shardId,
api_version: @version,
}
end
|