Class: DiigoPinata::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/diigo-pinata/client.rb

Instance Method Summary collapse

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, tags, private, description)
   unless @cookie

  data = "url=#{url}&unread=false&title=#{title}&private=#{private}&description=#{description}&tags=#{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, tags, lists='')
   unless @cookie

  data = "title=#{title}&content=#{content}&tags=#{tags}&lists=#{lists}&note_type=text"
  resp = post('www.diigo.com', '/item/save/note', data)

  check_response(resp)
end

#loginObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/diigo-pinata/client.rb', line 16

def 
  data = "username=#{@username}&password=#{@password}&referInfo=https://www.diigo.com/user/#{@username}"
  resp = post('www.diigo.com', '/sign-in', data)

  cookie_str = resp.to_hash['set-cookie'].collect { |ea| ea[/^.*?;/] }.join
  if cookie_str.include? @username
    @cookie = cookie_str
    return true
  end

  false
end