teamwork-pm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/teamwork.rb +42 -2
- data/test/test_teamwork.rb +18 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59a61ea724f6cf704b6c51361060f313c8ba79a7
|
4
|
+
data.tar.gz: 80bdee67088bb1a75d20f8f5410adccff25f675d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78842132a79dcfed91f5feeecf933fd3d295aff46d8b98b75556a32faafc98b2f6b7403be8c8fc8863a6ee55be4aad5c7958cd73f76ef21f91384806215d9d14
|
7
|
+
data.tar.gz: e2a808e1ad76694a561050a2c6a4354af926dcf3180e5520c58fa850a970f004a37abd5f31481be969fa5440b078a4dbee909e04103e4efac6464bb5bb533bd8
|
data/lib/teamwork.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
require "rubygems"
|
1
2
|
require 'faraday'
|
2
3
|
require 'faraday_middleware'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
module Teamwork
|
6
7
|
|
7
|
-
VERSION = "0.0.
|
8
|
+
VERSION = "0.0.2"
|
8
9
|
|
9
10
|
class API
|
10
11
|
|
@@ -85,8 +86,47 @@ module Teamwork
|
|
85
86
|
@api_conn.delete "projects/#{id}.json"
|
86
87
|
end
|
87
88
|
|
89
|
+
def get_tasks(id)
|
90
|
+
response = @api_conn.get "projects/#{id}/todo_lists.json"
|
91
|
+
response.body["todo-lists"]
|
92
|
+
end
|
93
|
+
|
94
|
+
def create_task(task,project_id)
|
95
|
+
@api_conn.post "/tasklists/#{project_id}/tasks.json",
|
96
|
+
{
|
97
|
+
"todo-item"=>{
|
98
|
+
"content"=>task["content"],
|
99
|
+
"notify"=>false,
|
100
|
+
"description"=>task["description"],
|
101
|
+
|
102
|
+
"private"=>0
|
103
|
+
}
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_task_list(task_list,project_id)
|
108
|
+
{
|
109
|
+
"todo-list" => task_list.to_json
|
110
|
+
}.to_json
|
111
|
+
|
112
|
+
|
113
|
+
@api_conn.post "projects/#{project_id}/todo_lists.json",
|
114
|
+
{
|
115
|
+
"todo-list"=> {
|
116
|
+
"name"=> task_list['name'],
|
117
|
+
"private"=> false,
|
118
|
+
"pinned"=> true,
|
119
|
+
"tracked"=> true,
|
120
|
+
"milestone-id"=> "",
|
121
|
+
|
122
|
+
}
|
123
|
+
}.to_json
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
|
88
128
|
def attach_post_to_project(title, body, project_id)
|
89
|
-
@api_conn.post "projects/#{project_id}/messsages.json", { post: { title: title, body: body } }
|
129
|
+
@api_conn.post "projects/#{project_id}/messsages.json", { post: { title: title, body: body }.to_json }
|
90
130
|
end
|
91
131
|
end
|
92
132
|
end
|
data/test/test_teamwork.rb
CHANGED
@@ -1,8 +1,24 @@
|
|
1
1
|
require "minitest/autorun"
|
2
|
-
require "teamwork"
|
2
|
+
require "../lib/teamwork"
|
3
3
|
|
4
4
|
class TestTeamwork < MiniTest::Unit::TestCase
|
5
5
|
def test_sanity
|
6
|
-
|
6
|
+
api = Teamwork::API.new(project_name: 'digital', api_key:'1doom333toe!')
|
7
|
+
project_id = api.create_project('test 6','Test Client')
|
8
|
+
task_lists = api.get_tasks('87494')
|
9
|
+
task_lists.each do |task_list|
|
10
|
+
|
11
|
+
puts task_list
|
12
|
+
keys = %w[name private pinned tracked todo-list-template-id]
|
13
|
+
new_tasklist = task_list.select { |key,_| keys.include? key }
|
14
|
+
new_tasklist_id = api.create_task_list(new_tasklist, project_id).body['TASKLISTID']
|
15
|
+
task_list['todo-items'].each do |todo_item|
|
16
|
+
keys = %w[content description]
|
17
|
+
new_task = todo_item.select { |key,_| keys.include? key }
|
18
|
+
api.create_task(new_task, new_tasklist_id)
|
19
|
+
puts new_task
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# api.delete_project project_id
|
7
23
|
end
|
8
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamwork-pm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|