brat 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +24 -0
  6. data/README.md +103 -0
  7. data/Rakefile +9 -0
  8. data/bin/brat +7 -0
  9. data/brat.gemspec +26 -0
  10. data/lib/brat.rb +37 -0
  11. data/lib/brat/api.rb +17 -0
  12. data/lib/brat/cli.rb +47 -0
  13. data/lib/brat/cli_helpers.rb +175 -0
  14. data/lib/brat/client.rb +18 -0
  15. data/lib/brat/client/branches.rb +79 -0
  16. data/lib/brat/client/groups.rb +88 -0
  17. data/lib/brat/client/issues.rb +92 -0
  18. data/lib/brat/client/merge_requests.rb +107 -0
  19. data/lib/brat/client/milestones.rb +57 -0
  20. data/lib/brat/client/notes.rb +106 -0
  21. data/lib/brat/client/projects.rb +298 -0
  22. data/lib/brat/client/repositories.rb +78 -0
  23. data/lib/brat/client/snippets.rb +86 -0
  24. data/lib/brat/client/system_hooks.rb +58 -0
  25. data/lib/brat/client/users.rb +123 -0
  26. data/lib/brat/configuration.rb +40 -0
  27. data/lib/brat/error.rb +42 -0
  28. data/lib/brat/help.rb +44 -0
  29. data/lib/brat/objectified_hash.rb +24 -0
  30. data/lib/brat/request.rb +101 -0
  31. data/lib/brat/shell.rb +49 -0
  32. data/lib/brat/version.rb +3 -0
  33. data/spec/brat/cli_spec.rb +80 -0
  34. data/spec/brat/client/branches_spec.rb +103 -0
  35. data/spec/brat/client/groups_spec.rb +111 -0
  36. data/spec/brat/client/issues_spec.rb +122 -0
  37. data/spec/brat/client/merge_requests_spec.rb +124 -0
  38. data/spec/brat/client/milestones_spec.rb +66 -0
  39. data/spec/brat/client/notes_spec.rb +156 -0
  40. data/spec/brat/client/projects_spec.rb +357 -0
  41. data/spec/brat/client/repositories_spec.rb +92 -0
  42. data/spec/brat/client/snippets_spec.rb +85 -0
  43. data/spec/brat/client/system_hooks_spec.rb +69 -0
  44. data/spec/brat/client/users_spec.rb +192 -0
  45. data/spec/brat/objectified_hash_spec.rb +23 -0
  46. data/spec/brat/request_spec.rb +48 -0
  47. data/spec/brat_spec.rb +65 -0
  48. data/spec/fixtures/branch.json +1 -0
  49. data/spec/fixtures/branches.json +1 -0
  50. data/spec/fixtures/comment_merge_request.json +1 -0
  51. data/spec/fixtures/create_branch.json +1 -0
  52. data/spec/fixtures/create_merge_request.json +1 -0
  53. data/spec/fixtures/error_already_exists.json +1 -0
  54. data/spec/fixtures/group.json +60 -0
  55. data/spec/fixtures/group_create.json +1 -0
  56. data/spec/fixtures/group_member.json +1 -0
  57. data/spec/fixtures/group_member_delete.json +1 -0
  58. data/spec/fixtures/group_members.json +1 -0
  59. data/spec/fixtures/groups.json +2 -0
  60. data/spec/fixtures/issue.json +1 -0
  61. data/spec/fixtures/issues.json +1 -0
  62. data/spec/fixtures/key.json +1 -0
  63. data/spec/fixtures/keys.json +1 -0
  64. data/spec/fixtures/merge_request.json +1 -0
  65. data/spec/fixtures/merge_request_comments.json +1 -0
  66. data/spec/fixtures/merge_requests.json +1 -0
  67. data/spec/fixtures/milestone.json +1 -0
  68. data/spec/fixtures/milestones.json +1 -0
  69. data/spec/fixtures/note.json +1 -0
  70. data/spec/fixtures/notes.json +1 -0
  71. data/spec/fixtures/project.json +1 -0
  72. data/spec/fixtures/project_commit.json +13 -0
  73. data/spec/fixtures/project_commit_diff.json +10 -0
  74. data/spec/fixtures/project_commits.json +1 -0
  75. data/spec/fixtures/project_delete_key.json +8 -0
  76. data/spec/fixtures/project_events.json +1 -0
  77. data/spec/fixtures/project_for_user.json +1 -0
  78. data/spec/fixtures/project_fork_link.json +1 -0
  79. data/spec/fixtures/project_hook.json +1 -0
  80. data/spec/fixtures/project_hooks.json +1 -0
  81. data/spec/fixtures/project_issues.json +1 -0
  82. data/spec/fixtures/project_key.json +6 -0
  83. data/spec/fixtures/project_keys.json +6 -0
  84. data/spec/fixtures/project_tags.json +1 -0
  85. data/spec/fixtures/projects.json +1 -0
  86. data/spec/fixtures/protect_branch.json +1 -0
  87. data/spec/fixtures/session.json +1 -0
  88. data/spec/fixtures/snippet.json +1 -0
  89. data/spec/fixtures/snippets.json +1 -0
  90. data/spec/fixtures/system_hook.json +1 -0
  91. data/spec/fixtures/system_hook_test.json +1 -0
  92. data/spec/fixtures/system_hooks.json +1 -0
  93. data/spec/fixtures/tag.json +1 -0
  94. data/spec/fixtures/team_member.json +1 -0
  95. data/spec/fixtures/team_members.json +1 -0
  96. data/spec/fixtures/unprotect_branch.json +1 -0
  97. data/spec/fixtures/update_merge_request.json +1 -0
  98. data/spec/fixtures/user.json +1 -0
  99. data/spec/fixtures/users.json +1 -0
  100. data/spec/spec_helper.rb +74 -0
  101. metadata +281 -0
@@ -0,0 +1,18 @@
1
+ module Brat
2
+ # Wrapper for the Brat REST API.
3
+ class Client < API
4
+ Dir[File.expand_path('../client/*.rb', __FILE__)].each {|f| require f}
5
+
6
+ include Branches
7
+ include Groups
8
+ include Issues
9
+ include MergeRequests
10
+ include Milestones
11
+ include Notes
12
+ include Projects
13
+ include Repositories
14
+ include Snippets
15
+ include SystemHooks
16
+ include Users
17
+ end
18
+ end
@@ -0,0 +1,79 @@
1
+ class Brat::Client
2
+ # Defines methods related to repositories.
3
+ module Branches
4
+ # Gets a list of project repositiory branches.
5
+ #
6
+ # @example
7
+ # Brat.branches(42)
8
+ #
9
+ # @param [Integer] project The ID of a project.
10
+ # @param [Hash] options A customizable set of options.
11
+ # @option options [Integer] :page The page number.
12
+ # @option options [Integer] :per_page The number of results per page.
13
+ # @return [Array<Brat::ObjectifiedHash>]
14
+ def branches(project, options={})
15
+ get("/projects/#{project}/repository/branches", :query => options)
16
+ end
17
+ alias_method :repo_branches, :branches
18
+
19
+ # Gets information about a repository branch.
20
+ #
21
+ # @example
22
+ # Brat.branch(3, 'api')
23
+ # Brat.repo_branch(5, 'master')
24
+ #
25
+ # @param [Integer] project The ID of a project.
26
+ # @param [String] branch The name of the branch.
27
+ # @return [Brat::ObjectifiedHash]
28
+ def branch(project, branch)
29
+ get("/projects/#{project}/repository/branches/#{branch}")
30
+ end
31
+
32
+ alias_method :repo_branch, :branch
33
+
34
+ # Protects a repository branch.
35
+ #
36
+ # @example
37
+ # Brat.protect_branch(3, 'api')
38
+ # Brat.repo_protect_branch(5, 'master')
39
+ #
40
+ # @param [Integer] project The ID of a project.
41
+ # @param [String] branch The name of the branch.
42
+ # @return [Brat::ObjectifiedHash]
43
+ def protect_branch(project, branch)
44
+ put("/projects/#{project}/repository/branches/#{branch}/protect")
45
+ end
46
+ alias_method :repo_protect_branch, :protect_branch
47
+
48
+ # Unprotects a repository branch.
49
+ #
50
+ # @example
51
+ # Brat.unprotect_branch(3, 'api')
52
+ # Brat.repo_unprotect_branch(5, 'master')
53
+ #
54
+ # @param [Integer] project The ID of a project.
55
+ # @param [String] branch The name of the branch.
56
+ # @return [Brat::ObjectifiedHash]
57
+ def unprotect_branch(project, branch)
58
+ put("/projects/#{project}/repository/branches/#{branch}/unprotect")
59
+ end
60
+ alias_method :repo_unprotect_branch, :unprotect_branch
61
+
62
+ # Creates a repository branch. Requires Brat >= 6.8.x
63
+ #
64
+ # @example
65
+ # Brat.create_branch(3, 'api')
66
+ # Brat.repo_create_branch(5, 'master')
67
+ #
68
+ # @param [Integer] project The ID of a project.
69
+ # @param [String] branch The name of the new branch.
70
+ # @param [String] ref Create branch from commit sha or existing branch
71
+ # @return [Brat::ObjectifiedHash]
72
+ def create_branch(project, branch, ref)
73
+ post("/projects/#{project}/repository/branches",:body => {:branch_name => branch, :ref => ref})
74
+ end
75
+ alias_method :repo_create_branch, :create_branch
76
+
77
+ end
78
+ end
79
+
@@ -0,0 +1,88 @@
1
+ class Brat::Client
2
+ # Defines methods related to groups.
3
+ module Groups
4
+ # Gets a list of groups.
5
+ #
6
+ # @example
7
+ # Brat.groups
8
+ # Brat.groups(:per_page => 40)
9
+ #
10
+ # @param [Hash] options A customizable set of options.
11
+ # @option options [Integer] :page The page number.
12
+ # @option options [Integer] :per_page The number of results per page.
13
+ # @return [Array<Brat::ObjectifiedHash>]
14
+ def groups(options={})
15
+ get("/groups", :query => options)
16
+ end
17
+
18
+ # Gets a single group.
19
+ #
20
+ # @example
21
+ # Brat.group(42)
22
+ #
23
+ # @param [Integer] id The ID of a group.
24
+ # @return [Brat::ObjectifiedHash]
25
+ def group(id)
26
+ get("/groups/#{id}")
27
+ end
28
+
29
+ # Creates a new group.
30
+ #
31
+ # @param [String] name The name of a group.
32
+ # @param [String] path The path of a group.
33
+ # @return [Brat::ObjectifiedHash] Information about created group.
34
+ def create_group(name, path)
35
+ body = {:name => name, :path => path}
36
+ post("/groups", :body => body)
37
+ end
38
+
39
+ # Get a list of group members.
40
+ #
41
+ # @example
42
+ # Brat.group_members(1)
43
+ # Brat.group_members(1, :per_page => 40)
44
+ #
45
+ # @param [Integer] id The ID of a group.
46
+ # @param [Hash] options A customizable set of options.
47
+ # @option options [Integer] :page The page number.
48
+ # @option options [Integer] :per_page The number of results per page.
49
+ # @return [Array<Brat::ObjectifiedHash>]
50
+ def group_members(id, options={})
51
+ get("/groups/#{id}/members", :query => options)
52
+ end
53
+
54
+ # Adds a user to group.
55
+ #
56
+ # @example
57
+ # Brat.add_group_member(1, 2, 40)
58
+ #
59
+ # @param [Integer] team_id The group id to add a member to.
60
+ # @param [Integer] user_id The user id of the user to add to the team.
61
+ # @param [Integer] access_level Project access level.
62
+ # @return [Brat::ObjectifiedHash] Information about added team member.
63
+ def add_group_member(team_id, user_id, access_level)
64
+ post("/groups/#{team_id}/members", :body => {:user_id => user_id, :access_level => access_level})
65
+ end
66
+
67
+ # Removes user from user group.
68
+ #
69
+ # @example
70
+ # Brat.remove_group_member(1, 2)
71
+ #
72
+ # @param [Integer] team_id The group ID.
73
+ # @param [Integer] user_id The ID of a user.
74
+ # @return [Brat::ObjectifiedHash] Information about removed team member.
75
+ def remove_group_member(team_id, user_id)
76
+ delete("/groups/#{team_id}/members/#{user_id}")
77
+ end
78
+
79
+ # Transfers a project to a group
80
+ #
81
+ # @param [Integer] id The ID of a group.
82
+ # @param [Integer] project_id The ID of a project.
83
+ def transfer_project_to_group(id, project_id)
84
+ body = {:id => id, :project_id => project_id}
85
+ post("/groups/#{id}/projects/#{project_id}", :body => body)
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,92 @@
1
+ class Brat::Client
2
+ # Defines methods related to issues.
3
+ module Issues
4
+ # Gets a list of user's issues.
5
+ # Will return a list of project's issues if project ID passed.
6
+ #
7
+ # @example
8
+ # Brat.issues
9
+ # Brat.issues(5)
10
+ # Brat.issues(:per_page => 40)
11
+ #
12
+ # @param [Integer] project The ID of a project.
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [Integer] :page The page number.
15
+ # @option options [Integer] :per_page The number of results per page.
16
+ # @return [Array<Brat::ObjectifiedHash>]
17
+ def issues(project=nil, options={})
18
+ if project.to_i.zero?
19
+ get("/issues", :query => options)
20
+ else
21
+ get("/projects/#{project}/issues", :query => options)
22
+ end
23
+ end
24
+
25
+ # Gets a single issue.
26
+ #
27
+ # @example
28
+ # Brat.issue(5, 42)
29
+ #
30
+ # @param [Integer] project The ID of a project.
31
+ # @param [Integer] id The ID of an issue.
32
+ # @return [Brat::ObjectifiedHash]
33
+ def issue(project, id)
34
+ get("/projects/#{project}/issues/#{id}")
35
+ end
36
+
37
+ # Creates a new issue.
38
+ #
39
+ # @param [Integer] project The ID of a project.
40
+ # @param [String] title The title of an issue.
41
+ # @param [Hash] options A customizable set of options.
42
+ # @option options [String] :description The description of an issue.
43
+ # @option options [Integer] :assignee_id The ID of a user to assign issue.
44
+ # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
45
+ # @option options [String] :labels Comma-separated label names for an issue.
46
+ # @return [Brat::ObjectifiedHash] Information about created issue.
47
+ def create_issue(project, title, options={})
48
+ body = {:title => title}.merge(options)
49
+ post("/projects/#{project}/issues", :body => body)
50
+ end
51
+
52
+ # Updates an issue.
53
+ #
54
+ # @param [Integer] project The ID of a project.
55
+ # @param [Integer] id The ID of an issue.
56
+ # @param [Hash] options A customizable set of options.
57
+ # @option options [String] :title The title of an issue.
58
+ # @option options [String] :description The description of an issue.
59
+ # @option options [Integer] :assignee_id The ID of a user to assign issue.
60
+ # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
61
+ # @option options [String] :labels Comma-separated label names for an issue.
62
+ # @option options [String] :state_event The state event of an issue ('close' or 'reopen').
63
+ # @return [Brat::ObjectifiedHash] Information about updated issue.
64
+ def edit_issue(project, id, options={})
65
+ put("/projects/#{project}/issues/#{id}", :body => options)
66
+ end
67
+
68
+ # Closes an issue.
69
+ #
70
+ # @example
71
+ # Brat.close_issue(3, 42)
72
+ #
73
+ # @param [Integer] project The ID of a project.
74
+ # @param [Integer] id The ID of an issue.
75
+ # @return [Brat::ObjectifiedHash] Information about closed issue.
76
+ def close_issue(project, id)
77
+ put("/projects/#{project}/issues/#{id}", :body => {:state_event => 'close'})
78
+ end
79
+
80
+ # Reopens an issue.
81
+ #
82
+ # @example
83
+ # Brat.reopen_issue(3, 42)
84
+ #
85
+ # @param [Integer] project The ID of a project.
86
+ # @param [Integer] id The ID of an issue.
87
+ # @return [Brat::ObjectifiedHash] Information about reopened issue.
88
+ def reopen_issue(project, id)
89
+ put("/projects/#{project}/issues/#{id}", :body => {:state_event => 'reopen'})
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,107 @@
1
+ class Brat::Client
2
+ # Defines methods related to merge requests.
3
+ module MergeRequests
4
+ # Gets a list of project merge requests.
5
+ #
6
+ # @example
7
+ # Brat.merge_requests(5)
8
+ # Brat.merge_requests(:per_page => 40)
9
+ #
10
+ # @param [Integer] project The ID of a project.
11
+ # @param [Hash] options A customizable set of options.
12
+ # @option options [Integer] :page The page number.
13
+ # @option options [Integer] :per_page The number of results per page.
14
+ # @return [Array<Brat::ObjectifiedHash>]
15
+ def merge_requests(project, options={})
16
+ get("/projects/#{project}/merge_requests", :query => options)
17
+ end
18
+
19
+ # Gets a single merge request.
20
+ #
21
+ # @example
22
+ # Brat.merge_request(5, 36)
23
+ #
24
+ # @param [Integer] project The ID of a project.
25
+ # @param [Integer] id The ID of a merge request.
26
+ # @return <Brat::ObjectifiedHash]
27
+ def merge_request(project, id)
28
+ get("/projects/#{project}/merge_request/#{id}")
29
+ end
30
+
31
+ # Creates a merge request.
32
+ #
33
+ # @example
34
+ # Brat.create_merge_request(5, 'New merge request',
35
+ # :source_branch => 'source_branch', :target_branch => 'target_branch')
36
+ # Brat.create_merge_request(5, 'New merge request',
37
+ # :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42)
38
+ #
39
+ # @param [Integer] project The ID of a project.
40
+ # @param [String] title The title of a merge request.
41
+ # @param [Hash] options A customizable set of options.
42
+ # @option options [String] :source_branch (required) The source branch name.
43
+ # @option options [String] :target_branch (required) The target branch name.
44
+ # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
45
+ # @return [Brat::ObjectifiedHash] Information about created merge request.
46
+ def create_merge_request(project, title, options={})
47
+ check_attributes!(options, [:source_branch, :target_branch])
48
+
49
+ body = {:title => title}.merge(options)
50
+ post("/projects/#{project}/merge_requests", :body => body)
51
+ end
52
+
53
+ # Updates a merge request.
54
+ #
55
+ # @example
56
+ # Brat.update_merge_request(5, 42, :title => 'New title')
57
+ #
58
+ # @param [Integer] project The ID of a project.
59
+ # @param [Integer] id The ID of a merge request.
60
+ # @param [Hash] options A customizable set of options.
61
+ # @option options [String] :title The title of a merge request.
62
+ # @option options [String] :source_branch The source branch name.
63
+ # @option options [String] :target_branch The target branch name.
64
+ # @option options [Integer] :assignee_id The ID of a user to assign merge request.
65
+ # @option options [String] :state_event New state (close|reopen|merge).
66
+ # @return [Brat::ObjectifiedHash] Information about updated merge request.
67
+ def update_merge_request(project, id, options={})
68
+ put("/projects/#{project}/merge_request/#{id}", :body => options)
69
+ end
70
+
71
+ # Adds a comment to a merge request.
72
+ #
73
+ # @example
74
+ # Brat.create_merge_request_comment(5, 1, "Awesome merge!")
75
+ # Brat.create_merge_request_comment('brat', 1, "Awesome merge!")
76
+ #
77
+ # @param [Integer] project The ID of a project.
78
+ # @param [Integer] id The ID of a merge request.
79
+ # @param [String] note The content of a comment.
80
+ # @return [Brat::ObjectifiedHash] Information about created merge request comment.
81
+ def create_merge_request_comment(project, id, note)
82
+ post("/projects/#{project}/merge_request/#{id}/comments", :body => {:note => note})
83
+ end
84
+
85
+ # Gets the comments on a merge request.
86
+ #
87
+ # @example
88
+ # Brat.merge_request_comments(5, 1)
89
+ #
90
+ # @param [Integer] project The ID of a project.
91
+ # @param [Integer] id The ID of a merge request.
92
+ # @return [Brat::ObjectifiedHash] The merge request's comments.
93
+ def merge_request_comments(project, id)
94
+ get("/projects/#{project}/merge_request/#{id}/comments")
95
+ end
96
+
97
+ private
98
+
99
+ def check_attributes!(options, attrs)
100
+ attrs.each do |attr|
101
+ unless options.has_key?(attr) || options.has_key?(attr.to_s)
102
+ raise Brat::Error::MissingAttributes.new("Missing '#{attr}' parameter")
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,57 @@
1
+ class Brat::Client
2
+ # Defines methods related to milestones.
3
+ module Milestones
4
+ # Gets a list of project's milestones.
5
+ #
6
+ # @example
7
+ # Brat.milestones(5)
8
+ #
9
+ # @param [Integer] project The ID of a project.
10
+ # @param [Hash] options A customizable set of options.
11
+ # @option options [Integer] :page The page number.
12
+ # @option options [Integer] :per_page The number of results per page.
13
+ # @return [Array<Brat::ObjectifiedHash>]
14
+ def milestones(project, options={})
15
+ get("/projects/#{project}/milestones", :query => options)
16
+ end
17
+
18
+ # Gets a single milestone.
19
+ #
20
+ # @example
21
+ # Brat.milestone(5, 36)
22
+ #
23
+ # @param [Integer, String] project The ID of a project.
24
+ # @param [Integer] id The ID of a milestone.
25
+ # @return [Brat::ObjectifiedHash]
26
+ def milestone(project, id)
27
+ get("/projects/#{project}/milestones/#{id}")
28
+ end
29
+
30
+ # Creates a new milestone.
31
+ #
32
+ # @param [Integer] project The ID of a project.
33
+ # @param [String] title The title of a milestone.
34
+ # @param [Hash] options A customizable set of options.
35
+ # @option options [String] :description The description of a milestone.
36
+ # @option options [String] :due_date The due date of a milestone.
37
+ # @return [Brat::ObjectifiedHash] Information about created milestone.
38
+ def create_milestone(project, title, options={})
39
+ body = {:title => title}.merge(options)
40
+ post("/projects/#{project}/milestones", :body => body)
41
+ end
42
+
43
+ # Updates a milestone.
44
+ #
45
+ # @param [Integer] project The ID of a project.
46
+ # @param [Integer] id The ID of a milestone.
47
+ # @param [Hash] options A customizable set of options.
48
+ # @option options [String] :title The title of a milestone.
49
+ # @option options [String] :description The description of a milestone.
50
+ # @option options [String] :due_date The due date of a milestone.
51
+ # @option options [String] :state_event The state of a milestone ('close' or 'activate').
52
+ # @return [Brat::ObjectifiedHash] Information about updated milestone.
53
+ def edit_milestone(project, id, options={})
54
+ put("/projects/#{project}/milestones/#{id}", :body => options)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,106 @@
1
+ class Brat::Client
2
+ # Defines methods related to notes.
3
+ module Notes
4
+ # Gets a list of projects notes.
5
+ #
6
+ # @example
7
+ # Brat.notes(5)
8
+ #
9
+ # @param [Integer] project The ID of a project.
10
+ # @return [Array<Brat::ObjectifiedHash>]
11
+ def notes(project)
12
+ get("/projects/#{project}/notes")
13
+ end
14
+
15
+ # Gets a list of notes for a issue.
16
+ #
17
+ # @example
18
+ # Brat.issue_notes(5, 10)
19
+ #
20
+ # @param [Integer] project The ID of a project.
21
+ # @param [Integer] issue The ID of an issue.
22
+ # @return [Array<Brat::ObjectifiedHash>]
23
+ def issue_notes(project, issue)
24
+ get("/projects/#{project}/issues/#{issue}/notes")
25
+ end
26
+
27
+ # Gets a list of notes for a snippet.
28
+ #
29
+ # @example
30
+ # Brat.snippet_notes(5, 1)
31
+ #
32
+ # @param [Integer] project The ID of a project.
33
+ # @param [Integer] snippet The ID of a snippet.
34
+ # @return [Array<Brat::ObjectifiedHash>]
35
+ def snippet_notes(project, snippet)
36
+ get("/projects/#{project}/snippets/#{snippet}/notes")
37
+ end
38
+
39
+ # Gets a single wall note.
40
+ #
41
+ # @example
42
+ # Brat.note(5, 15)
43
+ #
44
+ # @param [Integer] project The ID of a project.
45
+ # @param [Integer] id The ID of a note.
46
+ # @return [Brat::ObjectifiedHash]
47
+ def note(project, id)
48
+ get("/projects/#{project}/notes/#{id}")
49
+ end
50
+
51
+ # Gets a single issue note.
52
+ #
53
+ # @example
54
+ # Brat.issue_note(5, 10, 1)
55
+ #
56
+ # @param [Integer] project The ID of a project.
57
+ # @param [Integer] issue The ID of an issue.
58
+ # @param [Integer] id The ID of a note.
59
+ # @return [Brat::ObjectifiedHash]
60
+ def issue_note(project, issue, id)
61
+ get("/projects/#{project}/issues/#{issue}/notes/#{id}")
62
+ end
63
+
64
+ # Gets a single snippet note.
65
+ #
66
+ # @example
67
+ # Brat.snippet_note(5, 11, 3)
68
+ #
69
+ # @param [Integer] project The ID of a project.
70
+ # @param [Integer] snippet The ID of a snippet.
71
+ # @param [Integer] id The ID of an note.
72
+ # @return [Brat::ObjectifiedHash]
73
+ def snippet_note(project, snippet, id)
74
+ get("/projects/#{project}/snippets/#{snippet}/notes/#{id}")
75
+ end
76
+
77
+ # Creates a new wall note.
78
+ #
79
+ # @param [Integer] project The ID of a project.
80
+ # @param [String] body The body of a note.
81
+ # @return [Brat::ObjectifiedHash] Information about created note.
82
+ def create_note(project, body)
83
+ post("/projects/#{project}/notes", :body => {:body => body})
84
+ end
85
+
86
+ # Creates a new issue note.
87
+ #
88
+ # @param [Integer] project The ID of a project.
89
+ # @param [Integer] issue The ID of an issue.
90
+ # @param [String] body The body of a note.
91
+ # @return [Brat::ObjectifiedHash] Information about created note.
92
+ def create_issue_note(project, issue, body)
93
+ post("/projects/#{project}/issues/#{issue}/notes", :body => {:body => body})
94
+ end
95
+
96
+ # Creates a new snippet note.
97
+ #
98
+ # @param [Integer] project The ID of a project.
99
+ # @param [Integer] snippet The ID of a snippet.
100
+ # @param [String] body The body of a note.
101
+ # @return [Brat::ObjectifiedHash] Information about created note.
102
+ def create_snippet_note(project, snippet, body)
103
+ post("/projects/#{project}/snippets/#{snippet}/notes", :body => {:body => body})
104
+ end
105
+ end
106
+ end