backlog_kit 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2787c685de929aa848a973cf52dd1cf91c82a134
4
- data.tar.gz: 103f2397a530e80be64a94f838c5b99927ab4795
3
+ metadata.gz: e6dd58ad4aa5bd208229d43b68272d72bcd70a01
4
+ data.tar.gz: 8e3e1333972337069b86a18eaaac86d8e79963b0
5
5
  SHA512:
6
- metadata.gz: e2ee7f9f210266165163d6b0fdf91f1518d7914e6dc360c86e23c6ce1262c941dbc67e7d4d92b66c452cf49cce7ddb44f310ee52239f510b1f7a8cd5002dac3e
7
- data.tar.gz: 377c5b5e6df02bae194d9cb6e86509627e0961d6604106e36e3e1e8164b4ca51e63577e02f95e53fd8183a257cc3d69670996e88ba9c30f56bd0ce17e367219d
6
+ metadata.gz: 0723e40b9b7fdb68bc6c810381cb67b386b32dda0d058c8caaa826a2cf06a8304890108a9aed36a353828ac1de90f30fa7fc1cc41874eccf5aa5ab4498ac5f31
7
+ data.tar.gz: 0a58144b1b20c2c5e7975e02f9fbd2910cf1a2d6ca096337074d277c2333b3a84c55027cdc3fa15b5a87a4fddb847b6863094decac816336d27aa5f07af17a23
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --no-private
2
+ --markup markdown
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Coverage Status](https://coveralls.io/repos/emsk/backlog_kit/badge.svg?branch=master)](https://coveralls.io/r/emsk/backlog_kit)
6
6
  [![Code Climate](https://codeclimate.com/github/emsk/backlog_kit/badges/gpa.svg)](https://codeclimate.com/github/emsk/backlog_kit)
7
7
  [![Dependency Status](https://gemnasium.com/emsk/backlog_kit.svg)](https://gemnasium.com/emsk/backlog_kit)
8
+ [![Inline docs](http://inch-ci.org/github/emsk/backlog_kit.svg?branch=master)](http://inch-ci.org/github/emsk/backlog_kit)
8
9
 
9
10
  Ruby wrapper for the Nulab's Backlog API.
10
11
 
@@ -59,7 +60,7 @@ client.delete('groups/3712') # DELETE
59
60
 
60
61
  ## Authentication
61
62
 
62
- ### API Key
63
+ ### API key
63
64
 
64
65
  ```ruby
65
66
  client = BacklogKit::Client.new(
@@ -94,7 +95,7 @@ You can create instance more easily.
94
95
  client = BacklogKit::Client.new
95
96
  ```
96
97
 
97
- ## Supported API
98
+ ## Supported APIs
98
99
 
99
100
  * Git
100
101
  * Group
@@ -109,7 +110,7 @@ client = BacklogKit::Client.new
109
110
  * User
110
111
  * Wiki
111
112
 
112
- See [RDoc](http://www.rubydoc.info/gems/backlog_kit) for more details.
113
+ See [documentation](http://www.rubydoc.info/gems/backlog_kit) for more details.
113
114
 
114
115
  ## Supported Ruby Versions
115
116
 
data/Rakefile CHANGED
@@ -4,4 +4,8 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task test: :spec
7
+
8
+ require 'yard'
9
+ YARD::Rake::YardocTask.new
10
+
7
11
  task default: :spec
data/backlog_kit.gemspec CHANGED
@@ -17,10 +17,11 @@ Gem::Specification.new do |spec|
17
17
  spec.bindir = 'exe'
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
+ spec.required_ruby_version = '>= 2.0.0'
20
21
 
21
22
  spec.add_runtime_dependency 'activesupport', '~> 4.2.1'
22
23
  spec.add_runtime_dependency 'faraday', '~> 0.9.1'
23
- spec.add_runtime_dependency 'faraday_middleware', '~> 0.9.1'
24
+ spec.add_runtime_dependency 'faraday_middleware', '~> 0.10.0'
24
25
  spec.add_development_dependency 'bundler', '~> 1.6'
25
26
  spec.add_development_dependency 'rake', '~> 10.0'
26
27
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -29,4 +30,6 @@ Gem::Specification.new do |spec|
29
30
  spec.add_development_dependency 'multi_json', '~> 1.11.0'
30
31
  spec.add_development_dependency 'vcr', '~> 2.9.3'
31
32
  spec.add_development_dependency 'coveralls', '~> 0.8.1'
33
+ spec.add_development_dependency 'yard', '~> 0.8.7'
34
+ spec.add_development_dependency 'redcarpet', '~> 3.3'
32
35
  end
@@ -19,6 +19,10 @@ require 'backlog_kit/response/raise_error'
19
19
  require 'backlog_kit/hash_extensions'
20
20
 
21
21
  module BacklogKit
22
+
23
+ # Client for the Backlog API
24
+ #
25
+ # @see http://developer.nulab-inc.com/docs/backlog
22
26
  class Client
23
27
  include BacklogKit::Client::Authorization
24
28
  include BacklogKit::Client::Git
@@ -47,6 +51,14 @@ module BacklogKit
47
51
  :access_token
48
52
  )
49
53
 
54
+ # Initialize a new Client object with given options
55
+ #
56
+ # @param options [Hash] Initialize options
57
+ # @option options [String] :space_id Backlog space id
58
+ # @option options [String] :api_key Backlog api key
59
+ # @option options [String] :client_id Backlog OAuth client id
60
+ # @option options [String] :client_secret Backlog OAuth client secret
61
+ # @option options [String] :refresh_token Backlog OAuth refresh token
50
62
  def initialize(options = {})
51
63
  @space_id = ENV['BACKLOG_SPACE_ID']
52
64
  @api_key = ENV['BACKLOG_API_KEY']
@@ -59,6 +71,9 @@ module BacklogKit
59
71
  end
60
72
  end
61
73
 
74
+ # Generate an OAuth authorization URL
75
+ #
76
+ # @return [String] OAuth authorization URL
62
77
  def authorization_url
63
78
  url = "#{host}/OAuth2AccessRequest.action?response_type=code&client_id=#{@client_id}"
64
79
  url += "&redirect_uri=#{URI.escape(@redirect_uri)}" if @redirect_uri
@@ -66,22 +81,47 @@ module BacklogKit
66
81
  url
67
82
  end
68
83
 
84
+ # Make a HTTP GET request
85
+ #
86
+ # @param path [String] Path for request
87
+ # @param params [Hash] Request parameters
88
+ # @return [BacklogKit::Response] Response from API server
69
89
  def get(path, params = {})
70
90
  request(:get, path, params)
71
91
  end
72
92
 
93
+ # Make a HTTP POST request
94
+ #
95
+ # @param path [String] Path for request
96
+ # @param params [Hash] Request parameters
97
+ # @return [BacklogKit::Response] Response from API server
73
98
  def post(path, params = {})
74
99
  request(:post, path, params)
75
100
  end
76
101
 
102
+ # Make a HTTP PUT request
103
+ #
104
+ # @param path [String] Path for request
105
+ # @param params [Hash] Request parameters
106
+ # @return [BacklogKit::Response] Response from API server
77
107
  def put(path, params = {})
78
108
  request(:put, path, params)
79
109
  end
80
110
 
111
+ # Make a HTTP PATCH request
112
+ #
113
+ # @param path [String] Path for request
114
+ # @param params [Hash] Request parameters
115
+ # @return [BacklogKit::Response] Response from API server
81
116
  def patch(path, params = {})
82
117
  request(:patch, path, params)
83
118
  end
84
119
 
120
+ # Make a HTTP DELETE request
121
+ #
122
+ # @param path [String] Path for request
123
+ # @param params [Hash] Request parameters
124
+ # @return [BacklogKit::Response] Response from API server
85
125
  def delete(path, params = {})
86
126
  request(:delete, path, params)
87
127
  end
@@ -1,6 +1,15 @@
1
1
  module BacklogKit
2
2
  class Client
3
+
4
+ # Methods for OAuth 2.0 authorization
5
+ #
6
+ # @see http://developer.nulab-inc.com/docs/backlog/auth
3
7
  module Authorization
8
+
9
+ # Create a new access token
10
+ #
11
+ # @param oauth_code [String] Authorization code that you get from the authorization endpoint
12
+ # @return [BacklogKit::Response] The token information
4
13
  def create_token(oauth_code)
5
14
  params = {
6
15
  client_id: client_id,
@@ -12,6 +21,9 @@ module BacklogKit
12
21
  request(:post, 'oauth2/token', params, true)
13
22
  end
14
23
 
24
+ # Refresh an access token
25
+ #
26
+ # @return [BacklogKit::Response] The token information
15
27
  def update_token
16
28
  params = {
17
29
  client_id: client_id,
@@ -1,6 +1,13 @@
1
1
  module BacklogKit
2
2
  class Client
3
+
4
+ # Methods for the Git API
3
5
  module Git
6
+
7
+ # Get list of git repositories
8
+ #
9
+ # @param project_id_or_key [Integer, String] Project id or project key
10
+ # @return [BacklogKit::Response] List of git repositories
4
11
  def get_git_repositories(project_id_or_key)
5
12
  get('git/repositories', project_id_or_key: project_id_or_key)
6
13
  end
@@ -1,23 +1,48 @@
1
1
  module BacklogKit
2
2
  class Client
3
+
4
+ # Methods for the Group API
3
5
  module Group
6
+
7
+ # Get list of groups
8
+ #
9
+ # @param params [Hash] Request parameters
10
+ # @return [BacklogKit::Response] List of groups
4
11
  def get_groups(params = {})
5
12
  get('groups', params)
6
13
  end
7
14
 
15
+ # Get a group
16
+ #
17
+ # @param group_id [Integer, String] Group id
18
+ # @return [BacklogKit::Response] The group information
8
19
  def get_group(group_id)
9
20
  get("groups/#{group_id}")
10
21
  end
11
22
 
23
+ # Create a new group
24
+ #
25
+ # @param name [String] Group name
26
+ # @param params [Hash] Request parameters
27
+ # @return [BacklogKit::Response] The group information
12
28
  def create_group(name, params = {})
13
29
  params.merge!(name: name)
14
30
  post('groups', params)
15
31
  end
16
32
 
33
+ # Update a group
34
+ #
35
+ # @param group_id [Integer, String] Group id
36
+ # @param params [Hash] Request parameters
37
+ # @return [BacklogKit::Response] The group information
17
38
  def update_group(group_id, params = {})
18
39
  patch("groups/#{group_id}", params)
19
40
  end
20
41
 
42
+ # Delete a group
43
+ #
44
+ # @param group_id [Integer, String] Group id
45
+ # @return [BacklogKit::Response] The group information
21
46
  def delete_group(group_id)
22
47
  delete("groups/#{group_id}")
23
48
  end
@@ -1,80 +1,174 @@
1
1
  module BacklogKit
2
2
  class Client
3
+
4
+ # Methods for the Issue API
3
5
  module Issue
6
+
7
+ # Get list of issues
8
+ #
9
+ # @param params [Hash] Request parameters
10
+ # @return [BacklogKit::Response] List of issues
4
11
  def get_issues(params = {})
5
12
  get('issues', params)
6
13
  end
7
14
 
15
+ # Get number of issues
16
+ #
17
+ # @param params [Hash] Request parameters
18
+ # @return [BacklogKit::Response] Number of issues
8
19
  def get_issue_count(params = {})
9
20
  get('issues/count', params)
10
21
  end
11
22
 
23
+ # Get an issue
24
+ #
25
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
26
+ # @return [BacklogKit::Response] The issue information
12
27
  def get_issue(issue_id_or_key)
13
28
  get("issues/#{issue_id_or_key}")
14
29
  end
15
30
 
31
+ # Create a new issue
32
+ #
33
+ # @param summary [String] Summary of the issue
34
+ # @param params [Hash] Request parameters
35
+ # @return [BacklogKit::Response] The issue information
16
36
  def create_issue(summary, params = {})
17
37
  params.merge!(summary: summary)
18
38
  post('issues', params)
19
39
  end
20
40
 
41
+ # Update an issue
42
+ #
43
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
44
+ # @param params [Hash] Request parameters
45
+ # @return [BacklogKit::Response] The issue information
21
46
  def update_issue(issue_id_or_key, params = {})
22
47
  patch("issues/#{issue_id_or_key}", params)
23
48
  end
24
49
 
50
+ # Delete an issue
51
+ #
52
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
53
+ # @return [BacklogKit::Response] The issue information
25
54
  def delete_issue(issue_id_or_key)
26
55
  delete("issues/#{issue_id_or_key}")
27
56
  end
28
57
 
58
+ # Get list of comments in issue
59
+ #
60
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
61
+ # @param params [Hash] Request parameters
62
+ # @return [BacklogKit::Response] List of comments
29
63
  def get_comments(issue_id_or_key, params = {})
30
64
  get("issues/#{issue_id_or_key}/comments", params)
31
65
  end
32
66
 
67
+ # Get number of comments in issue
68
+ #
69
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
70
+ # @return [BacklogKit::Response] Number of comments
33
71
  def get_comment_count(issue_id_or_key)
34
72
  get("issues/#{issue_id_or_key}/comments/count")
35
73
  end
36
74
 
75
+ # Get a comment in issue
76
+ #
77
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
78
+ # @param comment_id [Integer, String] Comment id
79
+ # @return [BacklogKit::Response] The comment information
37
80
  def get_comment(issue_id_or_key, comment_id)
38
81
  get("issues/#{issue_id_or_key}/comments/#{comment_id}")
39
82
  end
40
83
 
84
+ # Add a comment to an issue
85
+ #
86
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
87
+ # @param content [String] Content of the comment
88
+ # @param params [Hash] Request parameters
89
+ # @return [BacklogKit::Response] The comment information
41
90
  def add_comment(issue_id_or_key, content, params = {})
42
91
  params.merge!(content: content)
43
92
  post("issues/#{issue_id_or_key}/comments", params)
44
93
  end
45
94
 
95
+ # Update a comment in issue
96
+ #
97
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
98
+ # @param comment_id [Integer, String] Comment id
99
+ # @param content [String] Content of the comment
100
+ # @return [BacklogKit::Response] The comment information
46
101
  def update_comment(issue_id_or_key, comment_id, content)
47
102
  patch("issues/#{issue_id_or_key}/comments/#{comment_id}", content: content)
48
103
  end
49
104
 
105
+ # Get list of comment notifications
106
+ #
107
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
108
+ # @param comment_id [Integer, String] Comment id
109
+ # @return [BacklogKit::Response] List of notifications
50
110
  def get_comment_notifications(issue_id_or_key, comment_id)
51
111
  get("issues/#{issue_id_or_key}/comments/#{comment_id}/notifications")
52
112
  end
53
113
 
114
+ # Add notifications to an comment
115
+ #
116
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
117
+ # @param comment_id [Integer, String] Comment id
118
+ # @param notified_user_ids [Array] List of notified user ids
119
+ # @return [BacklogKit::Response] The notification information
54
120
  def add_comment_notification(issue_id_or_key, comment_id, notified_user_ids = [])
55
121
  post("issues/#{issue_id_or_key}/comments/#{comment_id}/notifications", notified_user_id: notified_user_ids)
56
122
  end
57
123
 
124
+ # Get list of attachment files on issue
125
+ #
126
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
127
+ # @return [BacklogKit::Response] List of files
58
128
  def get_issue_attachments(issue_id_or_key)
59
129
  get("issues/#{issue_id_or_key}/attachments")
60
130
  end
61
131
 
132
+ # Download an attachment file on issue
133
+ #
134
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
135
+ # @param attachment_id [Integer, String] Attachment file id
136
+ # @return [BacklogKit::Response] Binary data
62
137
  def download_issue_attachment(issue_id_or_key, attachment_id)
63
138
  get("issues/#{issue_id_or_key}/attachments/#{attachment_id}")
64
139
  end
65
140
 
141
+ # Remove an attachment file from issue
142
+ #
143
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
144
+ # @param attachment_id [Integer, String] Attachment file id
145
+ # @return [BacklogKit::Response] The issue information
66
146
  def remove_issue_attachment(issue_id_or_key, attachment_id)
67
147
  delete("issues/#{issue_id_or_key}/attachments/#{attachment_id}")
68
148
  end
69
149
 
150
+ # Get list of shared files on issue
151
+ #
152
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
153
+ # @return [BacklogKit::Response] List of files
70
154
  def get_issue_shared_files(issue_id_or_key)
71
155
  get("issues/#{issue_id_or_key}/sharedFiles")
72
156
  end
73
157
 
158
+ # Link shared files to an issue
159
+ #
160
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
161
+ # @param file_ids [Array] List of file ids
162
+ # @return [BacklogKit::Response] List of files
74
163
  def link_issue_shared_files(issue_id_or_key, file_ids = [])
75
164
  post("issues/#{issue_id_or_key}/sharedFiles", file_id: file_ids)
76
165
  end
77
166
 
167
+ # Unlink a shared file on issue
168
+ #
169
+ # @param issue_id_or_key [Integer, String] Issue id or Issue key
170
+ # @param file_id [Integer, String] Shared file id
171
+ # @return [BacklogKit::Response] The file information
78
172
  def unlink_issue_shared_file(issue_id_or_key, file_id)
79
173
  delete("issues/#{issue_id_or_key}/sharedFiles/#{file_id}")
80
174
  end
@@ -1,18 +1,36 @@
1
1
  module BacklogKit
2
2
  class Client
3
+
4
+ # Methods for the Notification API
3
5
  module Notification
6
+
7
+ # Get list of own notifications
8
+ #
9
+ # @param params [Hash] Request parameters
10
+ # @return [BacklogKit::Response] List of notifications
4
11
  def get_notifications(params = {})
5
12
  get('notifications', params)
6
13
  end
7
14
 
15
+ # Get number of own notifications
16
+ #
17
+ # @param params [Hash] Request parameters
18
+ # @return [BacklogKit::Response] Number of notifications
8
19
  def get_notification_count(params = {})
9
20
  get('notifications/count', params)
10
21
  end
11
22
 
12
- def reset_already_read_notification_count
23
+ # Reset unread notification count
24
+ #
25
+ # @return [BacklogKit::Response] Number of notifications
26
+ def reset_unread_notification_count
13
27
  post('notifications/markAsRead')
14
28
  end
15
29
 
30
+ # Mark a notification as read
31
+ #
32
+ # @param notification_id [Integer, String] Notification id
33
+ # @return [BacklogKit::Response] No content response
16
34
  def mark_as_read_notification(notification_id)
17
35
  post("notifications/#{notification_id}/markAsRead")
18
36
  end