teamwork_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +11 -1
- data/.travis.yml +14 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +65 -10
- data/Guardfile +12 -0
- data/README.md +5 -5
- data/Rakefile +2 -0
- data/lib/teamwork_api.rb +3 -0
- data/lib/teamwork_api/api/companies.rb +4 -0
- data/lib/teamwork_api/api/params.rb +18 -11
- data/lib/teamwork_api/api/people.rb +52 -29
- data/lib/teamwork_api/api/project_owner.rb +6 -1
- data/lib/teamwork_api/api/projects.rb +70 -47
- data/lib/teamwork_api/api/task_lists.rb +8 -4
- data/lib/teamwork_api/client.rb +24 -20
- data/lib/teamwork_api/error.rb +7 -1
- data/lib/teamwork_api/version.rb +3 -1
- data/spec/fixtures/companies.json +64 -0
- data/spec/fixtures/company.json +32 -0
- data/spec/fixtures/create_project.json +4 -0
- data/spec/fixtures/create_task_list.json +4 -0
- data/spec/fixtures/delete.json +3 -0
- data/spec/fixtures/people.json +80 -0
- data/spec/fixtures/person.json +77 -0
- data/spec/fixtures/project.json +68 -0
- data/spec/fixtures/project_owner.json +91 -0
- data/spec/fixtures/projects.json +135 -0
- data/spec/fixtures/task_list.json +18 -0
- data/spec/fixtures/task_lists.json +22 -0
- data/spec/fixtures/update.json +3 -0
- data/spec/spec_helper.rb +60 -7
- data/spec/teamwork_api/api/companies_spec.rb +69 -0
- data/spec/teamwork_api/api/people_spec.rb +78 -0
- data/spec/teamwork_api/api/project_owner_spec.rb +35 -0
- data/spec/teamwork_api/api/projects_spec.rb +117 -0
- data/spec/teamwork_api/api/task_lists_spec.rb +98 -0
- data/spec/teamwork_api/client_spec.rb +202 -0
- data/teamwork_api.gemspec +10 -2
- metadata +116 -8
- data/spec/teamwork_api_spec.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 352f6e7275ab0a7dabe81bd20c89f39522ac44633aba09c3baa44d343eff2288
|
4
|
+
data.tar.gz: 3866dfeb95209f58dd00a14fa91d68d6ef743ef682a23c1a80330685d8b918f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd71511ed7847858390dfa9402d896ef9fe91f70f46c300b51fe01927c05bca3a103f07637c797b4de9314d1ddf8552c63dc6fa13399f9c232f3869385166d1
|
7
|
+
data.tar.gz: 94ec7a0c037ac613ee8461ab2cd21003bd24821bb1402f20466381063e782a47daca582ce125bd60129a0c4514da1727376c1978f45171f757c50fd638c8be0e
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
+
require: rubocop-performance
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
TargetRubyVersion: 2.5
|
5
|
+
Metrics/BlockLength:
|
3
6
|
Exclude:
|
4
|
-
|
7
|
+
- 'Rakefile'
|
8
|
+
- 'spec/**/*.rb'
|
9
|
+
Metrics/MethodLength:
|
10
|
+
Max: 15
|
11
|
+
Style/BlockDelimiters:
|
12
|
+
EnforcedStyle: braces_for_chaining
|
13
|
+
Style/SymbolArray:
|
14
|
+
EnforcedStyle: brackets
|
data/.travis.yml
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
language: 'ruby'
|
2
2
|
|
3
|
+
env:
|
4
|
+
global:
|
5
|
+
- CC_TEST_REPORTER_ID=a2684f17bc26e1344f48ee22a407e27b3eb229050e949b56010388bc8a5e0866
|
6
|
+
|
3
7
|
before_install:
|
4
8
|
- 'gem update --system'
|
5
9
|
- 'gem install bundler'
|
@@ -8,4 +12,13 @@ rvm:
|
|
8
12
|
- '2.5.5'
|
9
13
|
- '2.6.2'
|
10
14
|
|
11
|
-
|
15
|
+
before_script:
|
16
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
17
|
+
- chmod +x ./cc-test-reporter
|
18
|
+
- ./cc-test-reporter before-build
|
19
|
+
|
20
|
+
script:
|
21
|
+
- bundle exec rake
|
22
|
+
|
23
|
+
after_script:
|
24
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
## [0.1.1]
|
6
|
+
|
7
|
+
- Added Guard for development
|
8
|
+
- Setup Travis CI and Codeclimate
|
9
|
+
- Allow optional params for project request
|
10
|
+
- Added specs
|
11
|
+
|
12
|
+
## [0.1.0] - 2019-05-13
|
13
|
+
|
14
|
+
- Release
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in teamwork_api.gemspec
|
6
8
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
teamwork_api (0.1.
|
4
|
+
teamwork_api (0.1.1)
|
5
5
|
faraday (~> 0.9)
|
6
6
|
faraday_middleware (~> 0.10)
|
7
7
|
rack (>= 1.6)
|
@@ -9,23 +9,64 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
+
addressable (2.6.0)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
14
|
ast (2.4.0)
|
15
|
+
coderay (1.1.2)
|
16
|
+
crack (0.4.3)
|
17
|
+
safe_yaml (~> 1.0.0)
|
13
18
|
diff-lcs (1.3)
|
14
19
|
docile (1.3.1)
|
15
20
|
faraday (0.15.4)
|
16
21
|
multipart-post (>= 1.2, < 3)
|
17
22
|
faraday_middleware (0.13.1)
|
18
23
|
faraday (>= 0.7.4, < 1.0)
|
24
|
+
ffi (1.10.0)
|
25
|
+
formatador (0.2.5)
|
26
|
+
guard (2.15.0)
|
27
|
+
formatador (>= 0.2.4)
|
28
|
+
listen (>= 2.7, < 4.0)
|
29
|
+
lumberjack (>= 1.0.12, < 2.0)
|
30
|
+
nenv (~> 0.1)
|
31
|
+
notiffany (~> 0.0)
|
32
|
+
pry (>= 0.9.12)
|
33
|
+
shellany (~> 0.0)
|
34
|
+
thor (>= 0.18.1)
|
35
|
+
guard-compat (1.2.1)
|
36
|
+
guard-rspec (4.7.3)
|
37
|
+
guard (~> 2.1)
|
38
|
+
guard-compat (~> 1.1)
|
39
|
+
rspec (>= 2.99.0, < 4.0)
|
40
|
+
guard-rubocop (1.3.0)
|
41
|
+
guard (~> 2.0)
|
42
|
+
rubocop (~> 0.20)
|
43
|
+
hashdiff (0.3.9)
|
19
44
|
jaro_winkler (1.5.2)
|
20
45
|
json (2.2.0)
|
46
|
+
listen (3.1.5)
|
47
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
48
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
49
|
+
ruby_dep (~> 1.2)
|
50
|
+
lumberjack (1.0.13)
|
51
|
+
method_source (0.9.2)
|
21
52
|
multipart-post (2.1.0)
|
53
|
+
nenv (0.3.0)
|
54
|
+
notiffany (0.1.1)
|
55
|
+
nenv (~> 0.1)
|
56
|
+
shellany (~> 0.0)
|
22
57
|
parallel (1.17.0)
|
23
58
|
parser (2.6.3.0)
|
24
59
|
ast (~> 2.4.0)
|
25
|
-
|
60
|
+
pry (0.12.2)
|
61
|
+
coderay (~> 1.1.0)
|
62
|
+
method_source (~> 0.9.0)
|
63
|
+
public_suffix (3.0.3)
|
26
64
|
rack (2.0.7)
|
27
65
|
rainbow (3.0.0)
|
28
|
-
rake (
|
66
|
+
rake (11.3.0)
|
67
|
+
rb-fsevent (0.10.3)
|
68
|
+
rb-inotify (0.10.0)
|
69
|
+
ffi (~> 1.0)
|
29
70
|
rspec (3.8.0)
|
30
71
|
rspec-core (~> 3.8.0)
|
31
72
|
rspec-expectations (~> 3.8.0)
|
@@ -39,32 +80,46 @@ GEM
|
|
39
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
81
|
rspec-support (~> 3.8.0)
|
41
82
|
rspec-support (3.8.0)
|
42
|
-
rubocop (0.
|
83
|
+
rubocop (0.69.0)
|
43
84
|
jaro_winkler (~> 1.5.1)
|
44
85
|
parallel (~> 1.10)
|
45
|
-
parser (>= 2.
|
46
|
-
psych (>= 3.1.0)
|
86
|
+
parser (>= 2.6)
|
47
87
|
rainbow (>= 2.2.2, < 4.0)
|
48
88
|
ruby-progressbar (~> 1.7)
|
49
|
-
unicode-display_width (>= 1.4.0, < 1.
|
89
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
90
|
+
rubocop-performance (1.3.0)
|
91
|
+
rubocop (>= 0.68.0)
|
50
92
|
ruby-progressbar (1.10.0)
|
93
|
+
ruby_dep (1.5.0)
|
94
|
+
safe_yaml (1.0.5)
|
95
|
+
shellany (0.0.1)
|
51
96
|
simplecov (0.16.1)
|
52
97
|
docile (~> 1.1)
|
53
98
|
json (>= 1.8, < 3)
|
54
99
|
simplecov-html (~> 0.10.0)
|
55
100
|
simplecov-html (0.10.2)
|
56
|
-
|
101
|
+
thor (0.20.3)
|
102
|
+
unicode-display_width (1.6.0)
|
103
|
+
webmock (2.3.2)
|
104
|
+
addressable (>= 2.3.6)
|
105
|
+
crack (>= 0.3.2)
|
106
|
+
hashdiff
|
57
107
|
|
58
108
|
PLATFORMS
|
59
109
|
ruby
|
60
110
|
|
61
111
|
DEPENDENCIES
|
62
112
|
bundler (~> 1.16)
|
63
|
-
|
113
|
+
guard (~> 2.14)
|
114
|
+
guard-rspec (~> 4.7)
|
115
|
+
guard-rubocop (~> 1.3.0)
|
116
|
+
rake (~> 11.1)
|
64
117
|
rspec (~> 3.4)
|
65
|
-
rubocop (~> 0.
|
118
|
+
rubocop (~> 0.69.0)
|
119
|
+
rubocop-performance (~> 1.3.0)
|
66
120
|
simplecov (~> 0.11)
|
67
121
|
teamwork_api!
|
122
|
+
webmock (~> 2.0)
|
68
123
|
|
69
124
|
BUNDLED WITH
|
70
125
|
1.17.2
|
data/Guardfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
4
|
+
watch(%r{^spec/.+_spec\.rb$})
|
5
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
6
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
7
|
+
end
|
8
|
+
|
9
|
+
guard :rubocop, all_on_start: false, cli: ['--display-cop-names'] do
|
10
|
+
watch(/.+\.(rb|rake)$/)
|
11
|
+
watch(%r{(?:.+/)?\.rubocop(_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
12
|
+
end
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# TeamworkApi
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Build](https://travis-ci.org/100yrs/teamwork_api.svg?branch=master)](https://travis-ci.org/100yrs/teamwork_api)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/ad05d9af4c9a0d2cc4dd/maintainability)](https://codeclimate.com/github/100yrs/teamwork_api/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/ad05d9af4c9a0d2cc4dd/test_coverage)](https://codeclimate.com/github/100yrs/teamwork_api/test_coverage)
|
4
6
|
|
5
|
-
[
|
6
|
-
|
7
|
-
The Teamwork API gem allows you to consume the Teamwork API
|
7
|
+
The Teamwork API gem allows you to consume the [Teamwork API](https://developer.teamwork.com/)
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -44,7 +44,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/100yrs/teamwork_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
48
48
|
|
49
49
|
1. Fork it
|
50
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/Rakefile
CHANGED
data/lib/teamwork_api.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TeamworkApi
|
4
|
+
# Make it easier to deal with params
|
2
5
|
module API
|
3
6
|
def self.params(args)
|
4
7
|
Params.new(args)
|
5
8
|
end
|
6
9
|
|
10
|
+
# The useful stuff is here
|
7
11
|
class Params
|
8
12
|
def initialize(args)
|
9
|
-
raise
|
13
|
+
raise(ArgumentError, 'Required to be initialized with a Hash') unless
|
10
14
|
args.is_a? Hash
|
15
|
+
|
11
16
|
@args = args
|
12
17
|
@required = []
|
13
18
|
@optional = []
|
@@ -36,8 +41,7 @@ module TeamworkApi
|
|
36
41
|
|
37
42
|
@required.each do |k|
|
38
43
|
h[k] = @args[k]
|
39
|
-
raise
|
40
|
-
h[k]
|
44
|
+
raise(ArgumentError, "#{k} is required but not specified") unless h[k]
|
41
45
|
end
|
42
46
|
|
43
47
|
@optional.each do |k|
|
@@ -45,25 +49,28 @@ module TeamworkApi
|
|
45
49
|
end
|
46
50
|
|
47
51
|
@defaults.each do |k, v|
|
48
|
-
@args.key?(k) ?
|
52
|
+
h[k] = (@args.key?(k) ? @args[k] : v)
|
49
53
|
end
|
50
54
|
|
51
55
|
caseify_keys(h)
|
52
56
|
end
|
53
57
|
|
54
|
-
def caseify_keys(
|
58
|
+
def caseify_keys(hash)
|
55
59
|
caseified_hash = {}
|
56
|
-
|
57
|
-
|
58
|
-
key = k.to_s
|
59
|
-
else
|
60
|
-
key = k.to_s.camelize(:lower)
|
61
|
-
end
|
60
|
+
hash.each do |k, v|
|
61
|
+
key = (k.match?(/-/) ? k.to_s : camelize(k.to_s))
|
62
62
|
caseified_hash[key] = v
|
63
63
|
end
|
64
64
|
|
65
65
|
caseified_hash
|
66
66
|
end
|
67
|
+
|
68
|
+
def camelize(string)
|
69
|
+
string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
|
70
|
+
string.gsub(%r{(?:_|(\/))([a-z\d]*)}) {
|
71
|
+
"#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}"
|
72
|
+
}.gsub('/', '::')
|
73
|
+
end
|
67
74
|
end
|
68
75
|
end
|
69
76
|
end
|
@@ -1,42 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TeamworkApi
|
2
4
|
module API
|
5
|
+
# client methods for People
|
6
|
+
# https://developer.teamwork.com/projects/people
|
3
7
|
module People
|
8
|
+
OPTIONAL_GET_ATTRIBUTES = [
|
9
|
+
:project_id,
|
10
|
+
:page,
|
11
|
+
:page_size,
|
12
|
+
:group_by_company,
|
13
|
+
:sort,
|
14
|
+
:sort_order,
|
15
|
+
:full_profile
|
16
|
+
].freeze
|
17
|
+
OPTIONAL_UPDATE_ATTRIBUTES = [
|
18
|
+
:'edit-all-tasks',
|
19
|
+
:'view-messages-and-files',
|
20
|
+
:'view-tasks-and-milestones',
|
21
|
+
:'view-time',
|
22
|
+
:'view-notebooks',
|
23
|
+
:'view-risk-register',
|
24
|
+
:'view-invoices',
|
25
|
+
:'view-links',
|
26
|
+
:'view-links',
|
27
|
+
:'add-tasks',
|
28
|
+
:'add-milestones',
|
29
|
+
:'add-taskLists',
|
30
|
+
:'add-messages',
|
31
|
+
:'add-files',
|
32
|
+
:'add-time',
|
33
|
+
:'add-notebooks',
|
34
|
+
:'add-links',
|
35
|
+
:'set-privacy',
|
36
|
+
:'set-privacy',
|
37
|
+
:'is-observing',
|
38
|
+
:'can-be-assigned-to-tasks-and-milestones',
|
39
|
+
:'project-administrator',
|
40
|
+
:'add-people-to-project'
|
41
|
+
].freeze
|
42
|
+
|
43
|
+
def person(person_id)
|
44
|
+
response = get "/people/#{person_id}.json"
|
45
|
+
response.body['person']
|
46
|
+
end
|
47
|
+
|
48
|
+
def people(args = {})
|
49
|
+
args = API.params(args).optional(*OPTIONAL_GET_ATTRIBUTES).to_h
|
50
|
+
response = get '/people.json', args
|
51
|
+
response.body['people']
|
52
|
+
end
|
53
|
+
|
4
54
|
def add_person_to_project(project_id, person_id)
|
5
55
|
response =
|
6
56
|
put "projects/#{project_id}/people.json",
|
7
|
-
|
57
|
+
add: { userIdList: person_id }
|
8
58
|
response.body['STATUS']
|
9
59
|
end
|
10
60
|
|
11
61
|
def set_permissions(project_id, person_id, args)
|
12
|
-
args =
|
13
|
-
API.params(args)
|
14
|
-
.optional(
|
15
|
-
:'edit-all-tasks',
|
16
|
-
:'view-messages-and-files',
|
17
|
-
:'view-tasks-and-milestones',
|
18
|
-
:'view-time',
|
19
|
-
:'view-notebooks',
|
20
|
-
:'view-risk-register',
|
21
|
-
:'view-invoices',
|
22
|
-
:'view-links',
|
23
|
-
:'view-links',
|
24
|
-
:'add-tasks',
|
25
|
-
:'add-milestones',
|
26
|
-
:'add-taskLists',
|
27
|
-
:'add-messages',
|
28
|
-
:'add-files',
|
29
|
-
:'add-time',
|
30
|
-
:'add-notebooks',
|
31
|
-
:'add-links',
|
32
|
-
:'set-privacy',
|
33
|
-
:'set-privacy',
|
34
|
-
:'is-observing',
|
35
|
-
:'can-be-assigned-to-tasks-and-milestones',
|
36
|
-
:'project-administrator',
|
37
|
-
:'add-people-to-project'
|
38
|
-
).to_h
|
39
|
-
|
62
|
+
args = API.params(args).optional(*OPTIONAL_UPDATE_ATTRIBUTES).to_h
|
40
63
|
response =
|
41
64
|
put "projects/#{project_id}/people/#{person_id}.json",
|
42
65
|
permissions: args
|
@@ -1,10 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TeamworkApi
|
2
4
|
module API
|
5
|
+
# Client methods for ProjectOwner. Note that there isn't a specific
|
6
|
+
# ProjectOwner endpoint and these happen via the project
|
7
|
+
# https://developer.teamwork.com/projects/project-owner
|
3
8
|
module ProjectOwner
|
4
9
|
def project_owner(project_id)
|
5
10
|
response = get "projects/#{project_id}.json",
|
6
11
|
project: { include_project_owner: true }
|
7
|
-
response[
|
12
|
+
response.body['project']['owner']
|
8
13
|
end
|
9
14
|
|
10
15
|
# This doesn't seem to work. Response is OK, but owner not set
|