Class: TodoableWrapper::Client
- Inherits:
-
Object
- Object
- TodoableWrapper::Client
- Defined in:
- lib/todoable_wrapper.rb,
lib/todoable_wrapper/item.rb,
lib/todoable_wrapper/list.rb
Defined Under Namespace
Instance Method Summary collapse
- #get_token ⇒ Object
-
#initialize(u, p) ⇒ Client
constructor
A new instance of Client.
Methods included from Item
#add_item, #delete_item, #finish_item
Methods included from List
#create_list, #delete_list, #get_list_by_id, #lists, #update_list
Constructor Details
#initialize(u, p) ⇒ Client
Returns a new instance of Client.
16 17 18 19 |
# File 'lib/todoable_wrapper.rb', line 16 def initialize(u, p) @auth = { username: u, password: p } get_token end |
Instance Method Details
#get_token ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/todoable_wrapper.rb', line 21 def get_token begin = { basic_auth: @auth } response = self.class.post('/authenticate', ) @token = JSON.parse(response.body)["token"] @expires_at = JSON.parse(response.body)["expires_at"].to_datetime rescue => exception puts exception puts "Invalid credentials" end end |