Module: Douban::Client::Note

Included in:
Douban::Client
Defined in:
lib/douban_api/client/note.rb

Overview

Instance Method Summary collapse

Instance Method Details

#create_note(options = {}) ⇒ Object



5
6
7
# File 'lib/douban_api/client/note.rb', line 5

def create_note(options={})
  post "v2/notes", options
end

#create_note_comment(id, content) ⇒ Object



79
80
81
# File 'lib/douban_api/client/note.rb', line 79

def create_note_comment(id, content)
  post "v2/note/#{id}/comments", {:content => content}
end

#like_note(id) ⇒ Object



54
55
56
# File 'lib/douban_api/client/note.rb', line 54

def like_note(id)
  post "v2/note/#{id}/like"
end

#liked_notes(user_id = nil, format = "text", options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/douban_api/client/note.rb', line 21

def liked_notes(user_id=nil, format="text", options={})
  options.merge!(:format => format)
  
  if user_id.nil?
    response = get("v2/note/user_liked/#{get_user_id}", options)
  else
    response = get("v2/note/user_liked/#{user_id}", options)
  end
  
  response["notes"]
end

#note(id, format = "text") ⇒ Object



45
46
47
48
# File 'lib/douban_api/client/note.rb', line 45

def note(id, format="text")
  options.merge!(:format => format)
  get "v2/note/#{id}", options
end

#note_comment(note_id, comment_id) ⇒ Object



84
85
86
# File 'lib/douban_api/client/note.rb', line 84

def note_comment(note_id, comment_id)
  get "v2/note/#{note_id}/comment/#{comment_id}"
end

#note_comments(id, options = {}) ⇒ Object



74
75
76
77
# File 'lib/douban_api/client/note.rb', line 74

def note_comments(id, options={})
  response = get("v2/note/#{id}/comments", options)
  response["comments"]
end

#notes(user_id = nil, format = "text", options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/douban_api/client/note.rb', line 9

def notes(user_id=nil, format="text", options={})
  options.merge!(:format => format)
  
  if user_id.nil?
    response = get("v2/note/user_created/#{get_user_id}", options)
  else
    response = get("v2/note/user_created/#{user_id}", options)
  end
  
  response["notes"]
end

#notes_guesses(user_id = nil, format = "text", options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/douban_api/client/note.rb', line 33

def notes_guesses(user_id=nil, format="text", options={})
  options.merge!(:format => format)
  
  if user_id.nil?
    response = get("/v2/note/people_notes/#{get_user_id}/guesses", options)
  else
    response = get("v2/note/user_liked/#{user_id}", options)
  end
  
  response["notes"]
end

#remove_note(id) ⇒ Object



70
71
72
# File 'lib/douban_api/client/note.rb', line 70

def remove_note(id)
  delete("v2/note/#{id}")["status"] == 200
end

#remove_note_comment(note_id, comment_id) ⇒ Object



88
89
90
# File 'lib/douban_api/client/note.rb', line 88

def remove_note_comment(note_id, comment_id)
  delete "v2/note/#{note_id}/comment/#{comment_id}"
end

#unlike_note(id) ⇒ Object



58
59
60
# File 'lib/douban_api/client/note.rb', line 58

def unlike_note(id)
  delete "v2/note/#{id}/like"
end

#update_note(id, options = {}) ⇒ Object



62
63
64
# File 'lib/douban_api/client/note.rb', line 62

def update_note(id, options={})
  put "v2/note/#{id}", options
end

#upload_photon_to_note(id, options) ⇒ Object



66
67
68
# File 'lib/douban_api/client/note.rb', line 66

def upload_photon_to_note(id, options)
  post "v2/note/#{id}", options
end