teamwork-pm 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/teamwork.rb +42 -2
  3. data/test/test_teamwork.rb +18 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba5d5523cd0d13641b62034827d12b729a410b86
4
- data.tar.gz: 99b523dde4bc3b9907ba4254cc5d3f16e646114a
3
+ metadata.gz: 59a61ea724f6cf704b6c51361060f313c8ba79a7
4
+ data.tar.gz: 80bdee67088bb1a75d20f8f5410adccff25f675d
5
5
  SHA512:
6
- metadata.gz: daa7d5ac14780270c956dedf1c8a7d3daa6117bf25eaa5cfcde926c1cf358ea7a1fb60d67091fd5fadc51dddc723ce97be16e142b07096d2b5ef09d4459cffa7
7
- data.tar.gz: c194cf4e4609a0103bc049b07188ad72a16626027b2e53cb66ebee3785a86786aa956604a5c2d1122a3f7dbd722a38626a469e3b3ce5c616a25d18e2d7a2e05e
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.1"
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
@@ -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
- flunk "write tests or I will kneecap you"
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.1
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-24 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday