backlog-api-client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +117 -0
- data/Rakefile +2 -0
- data/backlog-api-client.gemspec +27 -0
- data/lib/backlog-api-client/client.rb +81 -0
- data/lib/backlog-api-client/issues.rb +31 -0
- data/lib/backlog-api-client/project.rb +0 -0
- data/lib/backlog-api-client/space.rb +39 -0
- data/lib/backlog-api-client/users.rb +48 -0
- data/lib/backlog-api-client/version.rb +3 -0
- data/lib/backlog-api-client.rb +5 -0
- data/spec/backlog-api-client/client_spec.rb +35 -0
- data/spec/backlog-api-client/issues_spec.rb +41 -0
- data/spec/backlog-api-client/space_spec.rb +50 -0
- data/spec/backlog-api-client/users_spec.rb +69 -0
- data/spec/spec_helper.rb +7 -0
- data/wercker.yml +31 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb36a99c98687e332dc99c78cf21d35fbb8160d5
|
4
|
+
data.tar.gz: ba889529d74d33d33b362d4056971d60e720ff5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50e0775472d005c3b528b730fd8cf51e03265d904702504988a2dea3eb90f86d76051ef205bf8132ae0a3f9bbb4909f877f091973c6732af730a78cebb692d7c
|
7
|
+
data.tar.gz: 1cb3bb5dc36c464c2d42e2e390840406b82a91c3c9d21ec01889321eb8d6065fa60a9ba22fd0f2ea8d3b8e56898fe3820a52510d315a4041277a67f09fa04542
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 joe-re
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# BacklogApiClient
|
2
|
+
[![wercker status](https://app.wercker.com/status/de4cb885aa9f05ab44c7d5364f6c9281/m "wercker status")](https://app.wercker.com/project/bykey/de4cb885aa9f05ab44c7d5364f6c9281)
|
3
|
+
|
4
|
+
backlog-api-client is a library to make it easy to use Backlog(http://www.backlog.jp/) Restful API(V2) for Ruby.
|
5
|
+
|
6
|
+
- official document
|
7
|
+
- http://developer.nulab-inc.com/docs/backlog/api/2/
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'backlog-api-client'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install backlog-api-client
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### example
|
28
|
+
```ruby
|
29
|
+
cli = BacklogApiClient::Client.new('joe-re.backlog.jp', '8EnEQMOapDlZHHXPTMfNy8ByikEYXLDdbS1A1htuLNTRtpU7Q7hIP4JY7gEhLyqt') # with space_name and api_key
|
30
|
+
|
31
|
+
# get issue list
|
32
|
+
cli.issues.list({ 'projectId[]' => 16931 })
|
33
|
+
|
34
|
+
# create issue
|
35
|
+
cli.issues.create({
|
36
|
+
'projectId' => 16931,
|
37
|
+
'summary' => 'test summary',
|
38
|
+
'description' => 'make for test',
|
39
|
+
'issueTypeId' => 74279,
|
40
|
+
'priorityId' => 3,
|
41
|
+
})
|
42
|
+
|
43
|
+
# update issue
|
44
|
+
cli.issues.update('TST-3', {
|
45
|
+
'summary' => 'test summary update',
|
46
|
+
'description' => 'make for test',
|
47
|
+
'issueTypeId' => 74279,
|
48
|
+
'priorityId' => 3,
|
49
|
+
})
|
50
|
+
```
|
51
|
+
|
52
|
+
### support methods
|
53
|
+
#### Space
|
54
|
+
- Get Space(/api/v2/space)
|
55
|
+
- Get Recent Updates(/api/v2/space/activities)
|
56
|
+
- Get Space Logo(/api/v2/space/image)
|
57
|
+
- Get Space Information(/api/v2/space/notification)
|
58
|
+
- Update Space Information(/api/v2/space/notification
|
59
|
+
- Get Space Disk Usage(/api/v2/space/diskUsage)
|
60
|
+
- Post Attachment File(/api/v2/space/attachment)
|
61
|
+
|
62
|
+
#### Users
|
63
|
+
- Get User List(/api/v2/users)
|
64
|
+
- Get User(/api/v2/users/:userId)
|
65
|
+
- Add User(/api/v2/users)
|
66
|
+
- Delete User(/api/v2/users/:userId)
|
67
|
+
- Get Own Usre(/api/v2/users/myself)
|
68
|
+
- Get User Icon(/api/v2/users/:userId/icon)
|
69
|
+
- Get User Recent Updates(/api/v2/users/:userId/activities)
|
70
|
+
- Get Received Star List(/api/v2/users/:userId/stars)
|
71
|
+
- Count User Received Stars(/api/v2/users/:userId/stars/count)
|
72
|
+
|
73
|
+
#### Issues
|
74
|
+
- Get Issue List(/api/v2/issues)
|
75
|
+
- Add Issue(/api/v2/issues)
|
76
|
+
- Get Issue(/api/v2/issues/:issueIdOrKey)
|
77
|
+
- Update Issue(/api/v2/issues/:issueIdOrKey)
|
78
|
+
- Delete Issue(/api/v2/issues/:issueIdOrKey)
|
79
|
+
|
80
|
+
### How to use not support API
|
81
|
+
You can use not support API by using BacklogApiClient::Client has methods.
|
82
|
+
|
83
|
+
- \#get
|
84
|
+
- \#post
|
85
|
+
- \#patch
|
86
|
+
- \#put
|
87
|
+
- \#file_upload
|
88
|
+
|
89
|
+
But I would be glad if you send Pull Request without to use these methods.
|
90
|
+
|
91
|
+
#### example
|
92
|
+
```ruby
|
93
|
+
cli = BacklogApiClient::Client.new('joe-re.backlog.jp', '8EnEQMOapDlZHHXPTMfNy8ByikEYXLDdbS1A1htuLNTRtpU7Q7hIP4JY7gEhLyqt')
|
94
|
+
|
95
|
+
# get wiki list
|
96
|
+
cli.get('/api/v2/wikis', { 'projectIdOrKey' => 16931})
|
97
|
+
|
98
|
+
# create wiki
|
99
|
+
cli.post('/api/v2/wikis', {
|
100
|
+
'projectId' => 16931,
|
101
|
+
'name' => 'add test wiki',
|
102
|
+
'content' => 'test'
|
103
|
+
})
|
104
|
+
```
|
105
|
+
|
106
|
+
## Contributing
|
107
|
+
|
108
|
+
1. Fork it ( https://github.com/[my-github-username]/backlog-api-client/fork )
|
109
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
110
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
111
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
112
|
+
5. Create a new Pull Request
|
113
|
+
|
114
|
+
|
115
|
+
## Release
|
116
|
+
- 0.0.1
|
117
|
+
- first release
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'backlog-api-client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'backlog-api-client'
|
8
|
+
spec.version = BacklogApiClient::VERSION
|
9
|
+
spec.authors = ['joe-re']
|
10
|
+
spec.email = ['joe.tialtngo@gmail.com']
|
11
|
+
spec.summary = ''
|
12
|
+
spec.description = 'This is a simple and easy-to-use Backlog Restful Api client.'
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'faraday'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'guard-rspec'
|
27
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module BacklogApiClient
|
4
|
+
class Client
|
5
|
+
API_PATH = '/api/v2'
|
6
|
+
|
7
|
+
def initialize(space_name, api_key)
|
8
|
+
@space_name = space_name
|
9
|
+
@api_key = { apiKey: api_key }
|
10
|
+
@http_cli = Faraday.new(url: "https://#{space_name}#{API_PATH}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(resource_path, params = {})
|
14
|
+
params.merge!(@api_key)
|
15
|
+
@http_cli.get "#{resource_path}#{to_request_params(params)}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def post(resource_path, request_body = {})
|
19
|
+
@http_cli.post do |req|
|
20
|
+
req.url "#{resource_path}#{to_request_params(@api_key)}"
|
21
|
+
req.headers['Content-Type'] = 'application/json'
|
22
|
+
req.body = request_body.to_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def patch(resource_path, request_body = {})
|
27
|
+
@http_cli.patch do |req|
|
28
|
+
req.url "#{resource_path}#{to_request_params(@api_key)}"
|
29
|
+
req.headers['Content-Type'] = 'application/json'
|
30
|
+
req.body = request_body.to_json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def put(resource_path, request_body = {})
|
35
|
+
@http_cli.put do |req|
|
36
|
+
req.url "#{resource_path}#{to_request_params(@api_key)}"
|
37
|
+
req.headers['Content-Type'] = 'application/json'
|
38
|
+
req.body = request_body.to_json
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def file_upload(resource_path, file)
|
43
|
+
@file_upload_cli ||= file_upload_cli
|
44
|
+
payload = { file: Faraday::UploadIO.new(file, 'application/octet-stream') }
|
45
|
+
@file_upload_cli.post "#{resource_path}#{to_request_params(@api_key)}", payload
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete(resource_path)
|
49
|
+
@http_cli.delete "#{resource_path}#{to_request_params(@api_key)}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def space
|
53
|
+
BacklogApiClient::Client::Space.new(self)
|
54
|
+
end
|
55
|
+
|
56
|
+
def issues
|
57
|
+
BacklogApiClient::Client::Issues.new(self)
|
58
|
+
end
|
59
|
+
|
60
|
+
def users
|
61
|
+
BacklogApiClient::Client::Users.new(self)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def to_request_params(hash)
|
67
|
+
hash.each_with_object('') do |(k, v), request_params|
|
68
|
+
request_params << (request_params.empty? ? '?' : '&')
|
69
|
+
request_params << "#{k}=#{v}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def file_upload_cli
|
74
|
+
Faraday.new("https://#{@space_name}#{API_PATH}") do |f|
|
75
|
+
f.request :multipart
|
76
|
+
f.request :url_encoded
|
77
|
+
f.adapter :net_http # This is what ended up making it work
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BacklogApiClient
|
2
|
+
class Client
|
3
|
+
class Issues
|
4
|
+
RESOURCE_NAME = 'issues'
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def list(params)
|
11
|
+
@client.get(RESOURCE_NAME, params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def information(isuue_id_or_key)
|
15
|
+
@client.get("#{RESOURCE_NAME}/#{isuue_id_or_key}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(request)
|
19
|
+
@client.post(RESOURCE_NAME, request)
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(issue_id_or_key, request)
|
23
|
+
@client.patch("#{RESOURCE_NAME}/#{issue_id_or_key}", request)
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(isuue_id_or_key)
|
27
|
+
@client.delete("#{RESOURCE_NAME}/#{isuue_id_or_key}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module BacklogApiClient
|
2
|
+
class Client
|
3
|
+
class Space
|
4
|
+
RESOURCE_NAME = 'space'
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def information
|
11
|
+
@client.get(RESOURCE_NAME)
|
12
|
+
end
|
13
|
+
|
14
|
+
def activities(request = {})
|
15
|
+
@client.get("#{RESOURCE_NAME}/activities", request)
|
16
|
+
end
|
17
|
+
|
18
|
+
def image
|
19
|
+
@client.get("#{RESOURCE_NAME}/image")
|
20
|
+
end
|
21
|
+
|
22
|
+
def notification
|
23
|
+
@client.get("#{RESOURCE_NAME}/notification")
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_notification(content)
|
27
|
+
@client.put("#{RESOURCE_NAME}/notification", content)
|
28
|
+
end
|
29
|
+
|
30
|
+
def disk_usage
|
31
|
+
@client.get("#{RESOURCE_NAME}/diskUsage")
|
32
|
+
end
|
33
|
+
|
34
|
+
def attachment(file)
|
35
|
+
@client.file_upload("#{RESOURCE_NAME}/attachment", file)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module BacklogApiClient
|
2
|
+
class Client
|
3
|
+
class Users
|
4
|
+
RESOURCE_NAME = 'users'
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def list
|
11
|
+
@client.get(RESOURCE_NAME)
|
12
|
+
end
|
13
|
+
|
14
|
+
def information(user_id)
|
15
|
+
@client.get("#{RESOURCE_NAME}/#{user_id}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(request)
|
19
|
+
@client.post(RESOURCE_NAME, request)
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete(user_id)
|
23
|
+
@client.delete("#{RESOURCE_NAME}/#{user_id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def myself
|
27
|
+
@client.get("#{RESOURCE_NAME}/myself")
|
28
|
+
end
|
29
|
+
|
30
|
+
def icon(user_id)
|
31
|
+
@client.get("#{RESOURCE_NAME}/#{user_id}/icon")
|
32
|
+
end
|
33
|
+
|
34
|
+
def activities(user_id, request = {})
|
35
|
+
@client.get("#{RESOURCE_NAME}/#{user_id}/activities", request)
|
36
|
+
end
|
37
|
+
|
38
|
+
def stars(user_id, request = {})
|
39
|
+
@client.get("#{RESOURCE_NAME}/#{user_id}/stars", request)
|
40
|
+
end
|
41
|
+
|
42
|
+
def stars_count(user_id, request = {})
|
43
|
+
@client.get("#{RESOURCE_NAME}/#{user_id}/stars/count", request)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BacklogApiClient::Client do
|
4
|
+
let(:http_cli) { double('http_cli') }
|
5
|
+
let(:space_name) { 'test_space_name' }
|
6
|
+
let(:api_key) { 'test_api_key' }
|
7
|
+
before { expect(Faraday).to receive(:new).with(url: "https://#{space_name}/api/v2").and_return(http_cli) }
|
8
|
+
|
9
|
+
describe '#get' do
|
10
|
+
let(:params) { { params: 'test-param' } }
|
11
|
+
let(:resource_path) { 'test/resource' }
|
12
|
+
before { expect(http_cli).to receive(:get).with("#{resource_path}?#{q(params)}&apiKey=#{api_key}").and_return('ok') }
|
13
|
+
subject { described_class.new(space_name, api_key).get(resource_path, params) }
|
14
|
+
it { should eq 'ok' }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#post' do
|
18
|
+
# ToDo: write test
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#patch' do
|
22
|
+
# ToDo: write test
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#delete' do
|
26
|
+
let(:resource_path) { 'test/resource' }
|
27
|
+
before { expect(http_cli).to receive(:delete).with("#{resource_path}?apiKey=#{api_key}").and_return('ok') }
|
28
|
+
subject { described_class.new(space_name, api_key).delete(resource_path) }
|
29
|
+
it { should eq 'ok' }
|
30
|
+
end
|
31
|
+
|
32
|
+
def q(hash)
|
33
|
+
hash.each_with_object([]) { |(k, v), ary| ary << "#{k}=#{v}" }.join('&')
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BacklogApiClient::Client::Issues do
|
4
|
+
let(:client) { double('client') }
|
5
|
+
|
6
|
+
describe '#list' do
|
7
|
+
let(:params) { { projectId: 'test-project' } }
|
8
|
+
before { expect(client).to receive(:get).with('issues', params).and_return('ok') }
|
9
|
+
subject { described_class.new(client).list(params) }
|
10
|
+
it { should eq 'ok' }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#information' do
|
14
|
+
let(:test_issue_id) { 'TEST-ISSUE-ID' }
|
15
|
+
before { expect(client).to receive(:get).with("issues/#{test_issue_id}").and_return('ok') }
|
16
|
+
subject { described_class.new(client).information(test_issue_id) }
|
17
|
+
it { should eq 'ok' }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#create' do
|
21
|
+
let(:request) { 'request' }
|
22
|
+
before { expect(client).to receive(:post).with('issues', request).and_return('ok') }
|
23
|
+
subject { described_class.new(client).create(request) }
|
24
|
+
it { should eq 'ok' }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#update' do
|
28
|
+
let(:test_issue_id) { 'TEST-ISSUE-ID' }
|
29
|
+
let(:request) { 'request' }
|
30
|
+
before { expect(client).to receive(:patch).with("issues/#{test_issue_id}", request).and_return('ok') }
|
31
|
+
subject { described_class.new(client).update(test_issue_id, request) }
|
32
|
+
it { should eq 'ok' }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#delete' do
|
36
|
+
let(:test_issue_id) { 'TEST-ISSUE-ID' }
|
37
|
+
before { expect(client).to receive(:delete).with("issues/#{test_issue_id}").and_return('ok') }
|
38
|
+
subject { described_class.new(client).delete(test_issue_id) }
|
39
|
+
it { should eq 'ok' }
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BacklogApiClient::Client::Space do
|
4
|
+
let(:client) { double('client') }
|
5
|
+
|
6
|
+
describe '#information' do
|
7
|
+
before { expect(client).to receive(:get).with('space').and_return('ok') }
|
8
|
+
subject { described_class.new(client).information }
|
9
|
+
it { should eq 'ok' }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#activities' do
|
13
|
+
let(:params) { { order: 'ace' } }
|
14
|
+
before { expect(client).to receive(:get).with('space/activities', params).and_return('ok') }
|
15
|
+
subject { described_class.new(client).activities(params) }
|
16
|
+
it { should eq 'ok' }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#image' do
|
20
|
+
before { expect(client).to receive(:get).with('space/image').and_return('ok') }
|
21
|
+
subject { described_class.new(client).image }
|
22
|
+
it { should eq 'ok' }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#notification' do
|
26
|
+
before { expect(client).to receive(:get).with('space/notification').and_return('ok') }
|
27
|
+
subject { described_class.new(client).notification }
|
28
|
+
it { should eq 'ok' }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#update_notification' do
|
32
|
+
let(:content) { 'content' }
|
33
|
+
before { expect(client).to receive(:put).with('space/notification', content).and_return('ok') }
|
34
|
+
subject { described_class.new(client).update_notification(content) }
|
35
|
+
it { should eq 'ok' }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#disk_usage' do
|
39
|
+
before { expect(client).to receive(:get).with('space/diskUsage').and_return('ok') }
|
40
|
+
subject { described_class.new(client).disk_usage }
|
41
|
+
it { should eq 'ok' }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#attachment' do
|
45
|
+
let(:file) { 'test_file' }
|
46
|
+
before { expect(client).to receive(:file_upload).with('space/attachment', file).and_return('ok') }
|
47
|
+
subject { described_class.new(client).attachment(file) }
|
48
|
+
it { should eq 'ok' }
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BacklogApiClient::Client::Users do
|
4
|
+
let(:client) { double('client') }
|
5
|
+
|
6
|
+
describe '#list' do
|
7
|
+
before { expect(client).to receive(:get).with('users').and_return('ok') }
|
8
|
+
subject { described_class.new(client).list }
|
9
|
+
it { should eq 'ok' }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#information' do
|
13
|
+
let(:test_user_id) { 'TEST-USER-ID' }
|
14
|
+
before { expect(client).to receive(:get).with("users/#{test_user_id}").and_return('ok') }
|
15
|
+
subject { described_class.new(client).information(test_user_id) }
|
16
|
+
it { should eq 'ok' }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#create' do
|
20
|
+
let(:request) { 'request' }
|
21
|
+
before { expect(client).to receive(:post).with('users', request).and_return('ok') }
|
22
|
+
subject { described_class.new(client).create(request) }
|
23
|
+
it { should eq 'ok' }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#delete' do
|
27
|
+
let(:test_user_id) { 'TEST-USER-ID' }
|
28
|
+
before { expect(client).to receive(:delete).with("users/#{test_user_id}").and_return('ok') }
|
29
|
+
subject { described_class.new(client).delete(test_user_id) }
|
30
|
+
it { should eq 'ok' }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#myself' do
|
34
|
+
before { expect(client).to receive(:get).with('users/myself').and_return('ok') }
|
35
|
+
subject { described_class.new(client).myself }
|
36
|
+
it { should eq 'ok' }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#icon' do
|
40
|
+
let(:test_user_id) { 'TEST-USER-ID' }
|
41
|
+
before { expect(client).to receive(:get).with("users/#{test_user_id}/icon").and_return('ok') }
|
42
|
+
subject { described_class.new(client).icon(test_user_id) }
|
43
|
+
it { should eq 'ok' }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#activities' do
|
47
|
+
let(:test_user_id) { 'TEST-USER-ID' }
|
48
|
+
let(:params) { { order: 'ace' } }
|
49
|
+
before { expect(client).to receive(:get).with("users/#{test_user_id}/activities", params).and_return('ok') }
|
50
|
+
subject { described_class.new(client).activities(test_user_id, params) }
|
51
|
+
it { should eq 'ok' }
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#stars' do
|
55
|
+
let(:test_user_id) { 'TEST-USER-ID' }
|
56
|
+
let(:params) { { order: 'ace' } }
|
57
|
+
before { expect(client).to receive(:get).with("users/#{test_user_id}/stars", params).and_return('ok') }
|
58
|
+
subject { described_class.new(client).stars(test_user_id, params) }
|
59
|
+
it { should eq 'ok' }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#stars_count' do
|
63
|
+
let(:test_user_id) { 'TEST-USER-ID' }
|
64
|
+
let(:params) { { order: 'ace' } }
|
65
|
+
before { expect(client).to receive(:get).with("users/#{test_user_id}/stars/count", params).and_return('ok') }
|
66
|
+
subject { described_class.new(client).stars_count(test_user_id, params) }
|
67
|
+
it { should eq 'ok' }
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/wercker.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
box: wercker/rvm
|
2
|
+
# Build definition
|
3
|
+
build:
|
4
|
+
# The steps that will be executed on build
|
5
|
+
# See the Ruby section on the wercker devcenter:
|
6
|
+
# http://devcenter.wercker.com/articles/languages/ruby.html
|
7
|
+
steps:
|
8
|
+
# Uncomment this to force RVM to use a specific Ruby version
|
9
|
+
- rvm-use:
|
10
|
+
version: 2.1.2
|
11
|
+
|
12
|
+
- script:
|
13
|
+
name: bundle
|
14
|
+
code: gem install bundler
|
15
|
+
|
16
|
+
# A step that executes `bundle install` command
|
17
|
+
- bundle-install
|
18
|
+
|
19
|
+
# A custom script step, name value is used in the UI
|
20
|
+
# and the code value contains the command that get executed
|
21
|
+
- script:
|
22
|
+
name: echo ruby information
|
23
|
+
code: |
|
24
|
+
echo "ruby version $(ruby --version) running"
|
25
|
+
echo "from location $(which ruby)"
|
26
|
+
echo -p "gem list: $(gem list)"
|
27
|
+
|
28
|
+
# Add more steps here:
|
29
|
+
- script:
|
30
|
+
name: rspec
|
31
|
+
code: bundle exec rspec
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backlog-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- joe-re
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: This is a simple and easy-to-use Backlog Restful Api client.
|
84
|
+
email:
|
85
|
+
- joe.tialtngo@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Guardfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- backlog-api-client.gemspec
|
97
|
+
- lib/backlog-api-client.rb
|
98
|
+
- lib/backlog-api-client/client.rb
|
99
|
+
- lib/backlog-api-client/issues.rb
|
100
|
+
- lib/backlog-api-client/project.rb
|
101
|
+
- lib/backlog-api-client/space.rb
|
102
|
+
- lib/backlog-api-client/users.rb
|
103
|
+
- lib/backlog-api-client/version.rb
|
104
|
+
- spec/backlog-api-client/client_spec.rb
|
105
|
+
- spec/backlog-api-client/issues_spec.rb
|
106
|
+
- spec/backlog-api-client/space_spec.rb
|
107
|
+
- spec/backlog-api-client/users_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
- wercker.yml
|
110
|
+
homepage: ''
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.2.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: ''
|
134
|
+
test_files:
|
135
|
+
- spec/backlog-api-client/client_spec.rb
|
136
|
+
- spec/backlog-api-client/issues_spec.rb
|
137
|
+
- spec/backlog-api-client/space_spec.rb
|
138
|
+
- spec/backlog-api-client/users_spec.rb
|
139
|
+
- spec/spec_helper.rb
|