Class: DiigoPinata::Client
- Inherits:
-
Object
- Object
- DiigoPinata::Client
- Defined in:
- lib/diigo-pinata/client.rb
Instance Method Summary collapse
- #add_bookmark(url, title, tags, private, description) ⇒ Object
- #add_note(title, content, tags, lists = '') ⇒ Object
-
#initialize(username, password) ⇒ Client
constructor
A new instance of Client.
- #login ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/diigo-pinata/client.rb', line 10 def initialize(username, password) @username = username @password = password @cookie = nil end |
Instance Method Details
#add_bookmark(url, title, tags, private, description) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/diigo-pinata/client.rb', line 29 def add_bookmark(url, title, , private, description) login unless @cookie data = "url=#{url}&unread=false&title=#{title}&private=#{private}&description=#{description}&tags=#{}" resp = post('www.diigo.com', '/item/save/bookmark', data) check_response(resp) end |
#add_note(title, content, tags, lists = '') ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/diigo-pinata/client.rb', line 38 def add_note(title, content, , lists='') login unless @cookie data = "title=#{title}&content=#{content}&tags=#{}&lists=#{lists}¬e_type=text" resp = post('www.diigo.com', '/item/save/note', data) check_response(resp) end |
#login ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/diigo-pinata/client.rb', line 16 def login data = "username=#{@username}&password=#{@password}&referInfo=https://www.diigo.com/user/#{@username}" resp = post('www.diigo.com', '/sign-in', data) = resp.to_hash['set-cookie'].collect { |ea| ea[/^.*?;/] }.join if .include? @username @cookie = return true end false end |