teamwork 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +25 -0
- data/.gemtest +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +8 -0
- data/README.txt +52 -0
- data/Rakefile +23 -0
- data/bin/teamwork +3 -0
- data/lib/teamwork.rb +95 -0
- data/test/test_teamwork.rb +8 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8023bcbcda04872c9d3d734239a09450b9005306
|
4
|
+
data.tar.gz: a6beee542c5b77588df7cf446c6acd5474c25b66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f95023765c2f26563811e86ab2a17d25fdb30ac4c244b27344955603b5a4f5ae6ede5b429c5852b2ee7434190d1d310af4a2d88c5c41750f42e08d0bfba474cb
|
7
|
+
data.tar.gz: da008bd9867f58bcad6d9a5a70d0e7c2aee8eb20e58365e99e1b6f5c59eabd65065f4cd271dec232adbd3d72c1f3ed51c1c41915d4ed50388559edbf9e5101bc
|
data/.autotest
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "autotest/restart"
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.testlib = "minitest/unit"
|
7
|
+
#
|
8
|
+
# at.extra_files << "../some/external/dependency.rb"
|
9
|
+
#
|
10
|
+
# at.libs << ":../some/external"
|
11
|
+
#
|
12
|
+
# at.add_exception "vendor"
|
13
|
+
#
|
14
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
15
|
+
# at.files_matching(/test_.*rb$/)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# %w(TestA TestB).each do |klass|
|
19
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
# Autotest.add_hook :run_command do |at|
|
24
|
+
# system "rake build"
|
25
|
+
# end
|
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
= teamwork
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
A gem wrapper for the {TeamworkPM}[http://www.teamworkpm.net/] {API}[http://developer.teamworkpm.net/api]
|
6
|
+
|
7
|
+
== INSTALL:
|
8
|
+
|
9
|
+
gem install teamwork
|
10
|
+
|
11
|
+
== API EXAMPLES:
|
12
|
+
|
13
|
+
require 'teamwork'
|
14
|
+
|
15
|
+
api = Teamwork::API.new project_name: 'your-site-name', api_key: 'your-api-key'
|
16
|
+
|
17
|
+
api.people pageSize: 100
|
18
|
+
api.people pageSize: 100, page: 2
|
19
|
+
|
20
|
+
== DEVELOPERS:
|
21
|
+
|
22
|
+
After checking out the source, run:
|
23
|
+
|
24
|
+
$ rake newb
|
25
|
+
|
26
|
+
This task will install any missing dependencies, run the tests/specs,
|
27
|
+
and generate the RDoc.
|
28
|
+
|
29
|
+
== LICENSE:
|
30
|
+
|
31
|
+
(The MIT License)
|
32
|
+
|
33
|
+
Copyright (c) 2013 Ed Halferty
|
34
|
+
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
36
|
+
a copy of this software and associated documentation files (the
|
37
|
+
'Software'), to deal in the Software without restriction, including
|
38
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
39
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
40
|
+
permit persons to whom the Software is furnished to do so, subject to
|
41
|
+
the following conditions:
|
42
|
+
|
43
|
+
The above copyright notice and this permission notice shall be
|
44
|
+
included in all copies or substantial portions of the Software.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
47
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
48
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
49
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
50
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
51
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
52
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
|
6
|
+
# Hoe.plugin :compiler
|
7
|
+
# Hoe.plugin :gem_prelude_sucks
|
8
|
+
# Hoe.plugin :inline
|
9
|
+
# Hoe.plugin :racc
|
10
|
+
# Hoe.plugin :rcov
|
11
|
+
# Hoe.plugin :rubyforge
|
12
|
+
Hoe.plugin :bundler
|
13
|
+
|
14
|
+
Hoe.spec "teamwork" do
|
15
|
+
developer("Ed Halferty", "edhalferty@gmail.com")
|
16
|
+
extra_deps << ['faraday']
|
17
|
+
extra_deps << ['faraday_middleware']
|
18
|
+
extra_deps << ['multi_json']
|
19
|
+
extra_deps << ['multipart-post']
|
20
|
+
|
21
|
+
license "MIT" # this should match the license in the README
|
22
|
+
end
|
23
|
+
|
data/bin/teamwork
ADDED
data/lib/teamwork.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'pry'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Teamwork
|
7
|
+
|
8
|
+
VERSION = "1.0.1"
|
9
|
+
|
10
|
+
class API
|
11
|
+
|
12
|
+
def initialize(project_name: nil, api_key: nil)
|
13
|
+
@project_name = project_name
|
14
|
+
@api_key = api_key
|
15
|
+
@api_conn = Faraday.new(url: "http://#{project_name}.teamworkpm.net/") do |c|
|
16
|
+
c.request :multipart
|
17
|
+
c.request :json
|
18
|
+
c.request :url_encoded
|
19
|
+
c.response :json, content_type: /\bjson$/
|
20
|
+
c.adapter :net_http
|
21
|
+
end
|
22
|
+
|
23
|
+
@api_conn.headers[:cache_control] = 'no-cache'
|
24
|
+
@api_conn.basic_auth(api_key, '')
|
25
|
+
end
|
26
|
+
|
27
|
+
def account(request_params)
|
28
|
+
response = @api_conn.get "account.json", request_params
|
29
|
+
response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
def people(request_params)
|
33
|
+
response = @api_conn.get "people.json", request_params
|
34
|
+
response.body
|
35
|
+
end
|
36
|
+
|
37
|
+
def latestActivity(maxItems: 60, onlyStarred: false)
|
38
|
+
request_params = {
|
39
|
+
maxItems: maxItems,
|
40
|
+
onlyStarred: onlyStarred
|
41
|
+
}
|
42
|
+
response = @api_conn.get "latestActivity.json", request_params
|
43
|
+
response.body
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_comment(id)
|
47
|
+
response = @api_conn.get "comments/#{id}.json"
|
48
|
+
response.body["comment"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_company_id(name)
|
52
|
+
Hash[@api_conn.get('companies.json').body["companies"].map { |c| [c['name'], c['id']] }][name]
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_company(name)
|
56
|
+
@api_conn.post 'companies.json', { company: { name: name } }
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_or_create_company(name)
|
60
|
+
create_company(name) if !get_company_id(name)
|
61
|
+
get_company_id(name)
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_project(name, client_name)
|
65
|
+
company_id = get_or_create_company(name)
|
66
|
+
@api_conn.post('projects.json', {
|
67
|
+
project: {
|
68
|
+
name: name,
|
69
|
+
companyId: company_id,
|
70
|
+
"category-id" => '0'
|
71
|
+
}
|
72
|
+
}).headers['id']
|
73
|
+
end
|
74
|
+
|
75
|
+
def update_project(id, name, client_name)
|
76
|
+
company_id = get_or_create_company(name)
|
77
|
+
@api_conn.put "projects/#{id}.json", {
|
78
|
+
project: {
|
79
|
+
name: name,
|
80
|
+
companyId: company_id
|
81
|
+
}
|
82
|
+
}.status
|
83
|
+
end
|
84
|
+
|
85
|
+
def delete_project(id)
|
86
|
+
@api_conn.delete "projects/#{id}.json"
|
87
|
+
end
|
88
|
+
|
89
|
+
def attach_post_to_project(title, body, project_id)
|
90
|
+
@api_conn.post "projects/#{project_id}/messsages.json", { post: { title: title, body: body } }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamwork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ed Halferty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-13 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: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: multipart-post
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
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: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hoe
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
description: A gem wrapper for the {TeamworkPM}[http://www.teamworkpm.net/] {API}[http://developer.teamworkpm.net/api]
|
98
|
+
email:
|
99
|
+
- edhalferty@gmail.com
|
100
|
+
executables:
|
101
|
+
- teamwork
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files:
|
104
|
+
- History.txt
|
105
|
+
- Manifest.txt
|
106
|
+
- README.txt
|
107
|
+
files:
|
108
|
+
- .autotest
|
109
|
+
- History.txt
|
110
|
+
- Manifest.txt
|
111
|
+
- README.txt
|
112
|
+
- Rakefile
|
113
|
+
- bin/teamwork
|
114
|
+
- lib/teamwork.rb
|
115
|
+
- test/test_teamwork.rb
|
116
|
+
- .gemtest
|
117
|
+
homepage:
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options:
|
123
|
+
- --main
|
124
|
+
- README.txt
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project: teamwork
|
139
|
+
rubygems_version: 2.1.11
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: A gem wrapper for the {TeamworkPM}[http://www.teamworkpm.net/] {API}[http://developer.teamworkpm.net/api]
|
143
|
+
test_files:
|
144
|
+
- test/test_teamwork.rb
|