Class: RTM::API
- Inherits:
-
Object
- Object
- RTM::API
- Defined in:
- lib/rtmilk/api.rb
Overview
API class
Direct Known Subclasses
RTM::Auth::CheckToken, RTM::Auth::GetFrob, RTM::Auth::GetToken, Lists::Add, Lists::Archive, Lists::Delete, Lists::GetList, Lists::SetDefaultList, Lists::SetName, Lists::UnArchive, Tasks::Add, Tasks::Delete, Tasks::GetList, Tasks::Notes::Add, Tasks::Notes::Delete, Tasks::Notes::Edit, Timelines::Create
Class Method Summary collapse
-
.get_auth_url(perms, frob = nil) ⇒ Object
get Auth URL (both desktop/webapp).
-
.init(key, sec, option = nil) ⇒ Object
initialize the API context.
-
.key ⇒ Object
getter methods.
- .token ⇒ Object
- .token=(token) ⇒ Object
Instance Method Summary collapse
-
#invoke ⇒ Object
invoke a method.
- #sign ⇒ Object
Class Method Details
.get_auth_url(perms, frob = nil) ⇒ Object
get Auth URL (both desktop/webapp)
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rtmilk/api.rb', line 59 def API.get_auth_url(perms, frob=nil) param = { :api_key => @@key, :perms => perms } if frob param['frob'] = frob end sig = API.sign(param) r = 'http://' + RTM_URI + AUTH_PATH + '?' r += param.collect { |k, v| [k, v].join('=') }.sort.join('&') r += '&api_sig=' + sig r end |
.init(key, sec, option = nil) ⇒ Object
initialize the API context.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rtmilk/api.rb', line 26 def API.init(key, sec, option=nil) @@key = key @@sec = sec if (option) begin @@token = option[:token] if option.has_key? :token rescue => e puts e. end end end |
.token ⇒ Object
46 |
# File 'lib/rtmilk/api.rb', line 46 def API.token; @@token; end |
.token=(token) ⇒ Object
40 41 42 |
# File 'lib/rtmilk/api.rb', line 40 def API.token=(token) @@token = token end |
Instance Method Details
#invoke ⇒ Object
invoke a method
49 50 51 52 53 54 55 56 |
# File 'lib/rtmilk/api.rb', line 49 def invoke response = URI.join(RTM_URI, make_url).read # puts '--------------------------------------------------' # puts response # puts '--------------------------------------------------' result = XmlSimple.new.xml_in(response) ret = parse_result(result) end |
#sign ⇒ Object
73 74 75 |
# File 'lib/rtmilk/api.rb', line 73 def sign API.sign(@param) end |