Skip to content

Commit

Permalink
Notes api for wall, issues, and snippets notes. List, read and create.
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefvaclavik committed Dec 3, 2012
1 parent 11e4c0c commit 63c3592
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/gitlab/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Client < API

include Gitlab::Client::Users
include Gitlab::Client::Issues
include Gitlab::Client::Notes
include Gitlab::Client::Milestones
include Gitlab::Client::Snippets
include Gitlab::Client::Projects
Expand Down
106 changes: 106 additions & 0 deletions lib/gitlab/client/notes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
class Gitlab::Client
# Defines methods related to notes.
module Notes
# Gets a list of projects notes.
#
# @example
# Gitlab.notes(5)
#
# @param [Integer, String] project The ID or code name of a project.
# @return [Array<Gitlab::ObjectifiedHash>]
def notes(project)
get("/projects/#{project}/notes")
end

# Gets a list of notes for a issue.
#
# @example
# Gitlab.issue_notes(5, 10)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] issue The ID of an issue.
# @return [Array<Gitlab::ObjectifiedHash>]
def issue_notes(project, issue)
get("/projects/#{project}/issues/#{issue}/notes")
end

# Gets a list of notes for a snippet.
#
# @example
# Gitlab.snippet_notes(5, 1)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] snippet The ID of a snippet.
# @return [Array<Gitlab::ObjectifiedHash>]
def snippet_notes(project, snippet)
get("/projects/#{project}/snippets/#{snippet}/notes")
end

# Return single wall note
#
# @example
# Gitlab.note(5, 15)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] id The ID of a note.
# @return [Gitlab::ObjectifiedHash]
def note(project, id)
get("/projects/#{project}/notes/#{id}")
end

# Return single issue note
#
# @example
# Gitlab.issue_note(5, 10, 1)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] issue The ID of a issue.
# @param [Integer] id The ID of a note.
# @return [Gitlab::ObjectifiedHash]
def issue_note(project, issue, id)
get("/projects/#{project}/issues/#{issue}/notes/#{id}")
end

# Return single snippet note
#
# @example
# Gitlab.snippet_note(5, 11, 3)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] snippet The ID of an snippet.
# @param [Integer] id The ID of an note.
# @return [Gitlab::ObjectifiedHash]
def snippet_note(project, id)
get("/projects/#{project}/snippets/#{snippet}/notes/#{id}")
end

# Creates a new wall note.
#
# @param [Integer, String] project The ID or code name of a project.
# @param [String] body The body of a note.
# @return [Gitlab::ObjectifiedHash] Information about created note.
def create_note(project, body)
post("/projects/#{project}/notes", :body => {:body => body})
end

# Creates a new issue note.
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] issue The ID of an issue.
# @param [String] body The body of a note.
# @return [Gitlab::ObjectifiedHash] Information about created note.
def create_issue_note(project, issue, body)
post("/projects/#{project}/issues/#{issue}/notes", :body => {:body => body})
end

# Creates a new snippet note.
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] snippet The ID of an issue.
# @param [String] body The body of a note.
# @return [Gitlab::ObjectifiedHash] Information about created note.
def create_snippet_note(project, snippet, body)
post("/projects/#{project}/snippets/#{snippet}/notes", :body => {:body => body})
end
end
end

0 comments on commit 63c3592

Please sign in to comment.