minmb-teambox-client 0.4.0
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.
- data/Gemfile +11 -0
- data/Gemfile.lock +54 -0
- data/History +6 -0
- data/License +20 -0
- data/README.rdoc +30 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/examples/conversation.rb +12 -0
- data/examples/task.rb +17 -0
- data/examples/users.rb +19 -0
- data/lib/teambox-client/models/activity.rb +27 -0
- data/lib/teambox-client/models/comment.rb +55 -0
- data/lib/teambox-client/models/conversation.rb +26 -0
- data/lib/teambox-client/models/divider.rb +15 -0
- data/lib/teambox-client/models/invitation.rb +21 -0
- data/lib/teambox-client/models/membership.rb +15 -0
- data/lib/teambox-client/models/note.rb +15 -0
- data/lib/teambox-client/models/organization.rb +18 -0
- data/lib/teambox-client/models/page.rb +20 -0
- data/lib/teambox-client/models/page_slot.rb +16 -0
- data/lib/teambox-client/models/person.rb +19 -0
- data/lib/teambox-client/models/project.rb +52 -0
- data/lib/teambox-client/models/task.rb +66 -0
- data/lib/teambox-client/models/task_list.rb +26 -0
- data/lib/teambox-client/models/teambox_data.rb +16 -0
- data/lib/teambox-client/models/upload.rb +27 -0
- data/lib/teambox-client/models/user.rb +11 -0
- data/lib/teambox-client/reference_list.rb +49 -0
- data/lib/teambox-client/result_set.rb +72 -0
- data/lib/teambox-client/teambox.rb +288 -0
- data/lib/teambox-client/teambox_oauth.rb +37 -0
- data/lib/teambox-client.rb +8 -0
- data/minmb-teambox-client.gemspec +96 -0
- data/spec/client_spec.rb +17 -0
- data/spec/conversation_spec.rb +29 -0
- data/spec/project_spec.rb +11 -0
- data/spec/resource_spec.rb +77 -0
- data/spec/result_set_spec.rb +55 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/task_lists_spec.rb +17 -0
- data/spec/tasks_spec.rb +18 -0
- metadata +251 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
minmb-teambox-client (0.4.0)
|
5
|
+
httparty (~> 0.7.4)
|
6
|
+
json (~> 1.5.1)
|
7
|
+
minmb-teambox-client
|
8
|
+
oauth2 (~> 0.1.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.2.8)
|
14
|
+
crack (0.1.8)
|
15
|
+
diff-lcs (1.1.3)
|
16
|
+
faraday (0.5.7)
|
17
|
+
addressable (~> 2.2.4)
|
18
|
+
multipart-post (~> 1.1.0)
|
19
|
+
rack (>= 1.1.0, < 2)
|
20
|
+
git (1.2.5)
|
21
|
+
httparty (0.7.8)
|
22
|
+
crack (= 0.1.8)
|
23
|
+
jeweler (1.8.4)
|
24
|
+
bundler (~> 1.0)
|
25
|
+
git (>= 1.2.5)
|
26
|
+
rake
|
27
|
+
rdoc
|
28
|
+
json (1.5.4)
|
29
|
+
multi_json (0.0.5)
|
30
|
+
multipart-post (1.1.5)
|
31
|
+
oauth2 (0.1.1)
|
32
|
+
faraday (~> 0.5.0)
|
33
|
+
multi_json (~> 0.0.4)
|
34
|
+
rack (1.4.1)
|
35
|
+
rake (0.9.2.2)
|
36
|
+
rdoc (3.12)
|
37
|
+
json (~> 1.4)
|
38
|
+
rspec (2.11.0)
|
39
|
+
rspec-core (~> 2.11.0)
|
40
|
+
rspec-expectations (~> 2.11.0)
|
41
|
+
rspec-mocks (~> 2.11.0)
|
42
|
+
rspec-core (2.11.1)
|
43
|
+
rspec-expectations (2.11.2)
|
44
|
+
diff-lcs (~> 1.1.3)
|
45
|
+
rspec-mocks (2.11.2)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
jeweler
|
52
|
+
minmb-teambox-client!
|
53
|
+
rake
|
54
|
+
rspec
|
data/History
ADDED
data/License
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009-2011 James Urquhart, Pablo Villalba
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
minmb-teambox-client is a Ruby wrapper for Teambox ( http://www.teambox.com ) API.
|
3
|
+
|
4
|
+
* Wraps the API in a client object with resources
|
5
|
+
* Inspired by the philosophy of KISS, minimal spaghetti
|
6
|
+
|
7
|
+
Check out the API docs at http://www.teambox.com/api for more details on the Teambox API.
|
8
|
+
|
9
|
+
*Note:* this is a forked version pushed to RubyGems.org to fill in for the outdated version
|
10
|
+
of the upstream gem.
|
11
|
+
|
12
|
+
== Getting Started
|
13
|
+
|
14
|
+
First, install the minmb-teambox-client gem:
|
15
|
+
|
16
|
+
gem install minmb-teambox-client
|
17
|
+
|
18
|
+
Now, run "irb -rubygems" and this snippet to get the list of activities:
|
19
|
+
|
20
|
+
require 'teambox-client'
|
21
|
+
client = Teambox::Client.new(:auth => {:username => 'frank', :password => 'papapa'})
|
22
|
+
puts client.activities
|
23
|
+
|
24
|
+
By default, teambox-client will connect to the hosted service at https://teambox.com/api/1; optionally you can:
|
25
|
+
|
26
|
+
client = Teambox::Client.new(:base_uri => 'http://teambox.mysite.com/api/1', :auth => {:username => 'frank', :password => 'papapa'})
|
27
|
+
|
28
|
+
== Examples
|
29
|
+
|
30
|
+
See the examples directory.
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- mode: ruby; tab-width: nil; indent-tabs-mode: 2; encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'jeweler'
|
9
|
+
Jeweler::Tasks.new do |gem|
|
10
|
+
gem.name = "minmb-teambox-client"
|
11
|
+
gem.summary = "A ruby gem wrapper for Teambox API"
|
12
|
+
gem.description = "Provides methods to read and write to Teambox for ruby apps"
|
13
|
+
gem.email = "martin.hager@minmb.se"
|
14
|
+
gem.homepage = "http://github.com/minmb/teambox-ruby-client"
|
15
|
+
gem.authors = ["Pablo Villalba", "James Urquhart", "Martin Häger"]
|
16
|
+
|
17
|
+
gem.add_dependency("httparty", "~> 0.7.4")
|
18
|
+
gem.add_dependency("oauth2", "~> 0.1.1")
|
19
|
+
gem.add_dependency("json", "~> 1.5.1")
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'rspec/core/rake_task'
|
26
|
+
RSpec::Core::RakeTask.new do |t|
|
27
|
+
t.pattern = "spec/*spec.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
task :default => :spec
|
31
|
+
|
32
|
+
require 'rake/rdoctask'
|
33
|
+
Rake::RDocTask.new do |rdoc|
|
34
|
+
if File.exist?('VERSION')
|
35
|
+
version = File.read('VERSION')
|
36
|
+
else
|
37
|
+
version = ""
|
38
|
+
end
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "minmb-teambox-client #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/**/*.rb')
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'teambox-client')
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
TEAMBOX_SERVER = ENV["TEAMBOX_SERVER"] || "http://localhost:3000"
|
6
|
+
|
7
|
+
client = Teambox::Client.new({:base_uri => "#{TEAMBOX_SERVER}/api/1", :auth => {:user => 'frank', :password => 'papapa'}})
|
8
|
+
project = client.project('earthworks')
|
9
|
+
|
10
|
+
# Make a conversation
|
11
|
+
project.create_conversation({:body => 'Test conversation', :simple => true}) # return conversation resource
|
12
|
+
pp project.conversations[0].data
|
data/examples/task.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'teambox-client')
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
TEAMBOX_SERVER = ENV["TEAMBOX_SERVER"] || "http://localhost:3000"
|
6
|
+
|
7
|
+
client = Teambox::Client.new({:base_uri => "#{TEAMBOX_SERVER}/api/1", :auth => {:user => 'frank', :password => 'papapa'}})
|
8
|
+
project = client.project('earthworks')
|
9
|
+
|
10
|
+
# Make a task list with a task, update task to hold
|
11
|
+
task_list = project.create_task_list(:name => 'Teambox App')
|
12
|
+
task = project.create_task(task_list, {:name => 'Decide what we are going to make'})
|
13
|
+
task.status_name = :hold
|
14
|
+
task.comment = "We have no idea what we are making!"
|
15
|
+
task.save
|
16
|
+
pp task.data
|
17
|
+
pp task.comments[0].data
|
data/examples/users.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'teambox-client')
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
TEAMBOX_SERVER = ENV["TEAMBOX_SERVER"] || "http://localhost:3000"
|
6
|
+
|
7
|
+
client = Teambox::Client.new({:base_uri => "#{TEAMBOX_SERVER}/api/1", :auth => {:user => 'frank', :password => 'papapa'}})
|
8
|
+
puts "Logged in as #{client.current_user.name} (#{client.current_user.username})"
|
9
|
+
|
10
|
+
# Get info on single project
|
11
|
+
project = client.project('earthworks')
|
12
|
+
puts "Earthworks owner: #{client.project('earthworks').owner_user.reload.name}"
|
13
|
+
|
14
|
+
# Get info on all projects (subject to limits)
|
15
|
+
client.projects.each do |project|
|
16
|
+
puts "Project: #{project.name} (#{project.permalink})"
|
17
|
+
puts " Owned by: #{project.owner_user.name}"
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Activity < Teambox::Resource
|
3
|
+
# Teambox::User who generated this activity
|
4
|
+
def user
|
5
|
+
get_or_make_reference('User', @data, 'user_id')
|
6
|
+
end
|
7
|
+
|
8
|
+
# The Teambox::Resource which generated this activity
|
9
|
+
def target
|
10
|
+
get_or_make_reference(@data['target_type'], @data, 'target_id')
|
11
|
+
end
|
12
|
+
|
13
|
+
# The Teambox::Project this activity belongs to
|
14
|
+
def project
|
15
|
+
get_or_make_reference('Project', @data, 'project_id')
|
16
|
+
end
|
17
|
+
|
18
|
+
# The target of the comment if this is a Teambox::Comment
|
19
|
+
def comment_target
|
20
|
+
get_or_make_reference(@data['comment_target_type'], @data, 'comment_target_id')
|
21
|
+
end
|
22
|
+
|
23
|
+
def url #:nodoc:
|
24
|
+
"/activities/#{@data['id']}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Comment < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
def project
|
8
|
+
get_or_make_reference('Project', @data, 'project_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
# The Teambox::Resource which this comment belongs to
|
12
|
+
def target
|
13
|
+
get_or_make_reference(@data['target_type'], @data, 'target_id')
|
14
|
+
end
|
15
|
+
|
16
|
+
# The Teambox::Person assigned to the task at time of posting, if the comment belongs to a Teambox::Task
|
17
|
+
def assigned
|
18
|
+
get_or_make_reference('Person', @data, 'assigned_id')
|
19
|
+
end
|
20
|
+
|
21
|
+
# The Teambox::Person previously assigned to the task at time of posting, if the comment belongs to a Teambox::Task
|
22
|
+
def previous_assigned
|
23
|
+
get_or_make_reference('Person', @data, 'previous_assigned_id')
|
24
|
+
end
|
25
|
+
|
26
|
+
# The name of the status assigned to the Teambox::Task at time of posting
|
27
|
+
def status_name
|
28
|
+
@data['status'].nil? ? nil : Teambox::Task::STATUS_NAMES[@data['status']]
|
29
|
+
end
|
30
|
+
|
31
|
+
# The name of the previous status assigned to the Teambox::Task at time of posting
|
32
|
+
def previous_status_name
|
33
|
+
@data['previous_status'].nil? ? nil : Teambox::Task::STATUS_NAMES[@data['previous_status']]
|
34
|
+
end
|
35
|
+
|
36
|
+
# The due date of the Teambox::Task at time of posting
|
37
|
+
def due_on
|
38
|
+
@data['due_on'] ? Time.parse(data['due_on']) : nil
|
39
|
+
end
|
40
|
+
|
41
|
+
# The previous due date of the Teambox::Task at time of posting
|
42
|
+
def previous_due_on
|
43
|
+
@data['previous_due_on'] ? Time.parse(data['previous_due_on']) : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
# A list of Teambox::Upload attached to this comment
|
47
|
+
def uploads
|
48
|
+
get_or_make_references('Upload', @data, 'upload_ids', 'uploads')
|
49
|
+
end
|
50
|
+
|
51
|
+
def url #:nodoc:
|
52
|
+
"/comments/#{@data['id']}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Conversation < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
# Last two Teambox::Comment of the conversation (may include first_comment)
|
8
|
+
def recent_comments
|
9
|
+
get_or_make_references('Comment', @data, 'recent_comment_ids')
|
10
|
+
end
|
11
|
+
|
12
|
+
# First Teambox::Comment of the conversation
|
13
|
+
def first_comment
|
14
|
+
get_or_make_reference('Comment', @data, 'first_comment_id')
|
15
|
+
end
|
16
|
+
|
17
|
+
# Gets a Teambox::ResultSet of all Teambox::Comment objects belonging to the conversation
|
18
|
+
def comments
|
19
|
+
@list.client.get("#{url}/comments")
|
20
|
+
end
|
21
|
+
|
22
|
+
def url #:nodoc:
|
23
|
+
"/conversations/#{@data['id']}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Divider < Teambox::Resource
|
3
|
+
def page
|
4
|
+
get_or_make_reference('Page', @data, 'page_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
def project
|
8
|
+
get_or_make_reference('Project', @data, 'project_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
def url #:nodoc:
|
12
|
+
"/pages/#{@data['page_id']}/dividers/#{@data['id']}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Invitation < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
# Teambox::User who is the subject of this invite
|
8
|
+
def invited_user
|
9
|
+
get_or_make_reference('User', @data, 'invited_user_id')
|
10
|
+
end
|
11
|
+
|
12
|
+
# Teambox::Project the subject is being invited to
|
13
|
+
def project
|
14
|
+
get_or_make_reference('Project', @data, 'project_id')
|
15
|
+
end
|
16
|
+
|
17
|
+
def url #:nodoc:
|
18
|
+
"/invitations/#{@data['id']}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Membership < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
def organization
|
8
|
+
get_or_make_reference('Organization', @data, 'organization_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
def url #:nodoc:
|
12
|
+
"/organizations/#{@data['organization_id']}/memberships/#{@data['id']}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Note < Teambox::Resource
|
3
|
+
def page
|
4
|
+
get_or_make_reference('Page', @data, 'page_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
def project
|
8
|
+
get_or_make_reference('Project', @data, 'project_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
def url #:nodoc:
|
12
|
+
"/pages/#{@data['page_id']}/notes/#{@data['id']}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Organization < Teambox::Resource
|
3
|
+
|
4
|
+
# Gets a Teambox::ResultSet of all Teambox::Project objects belonging to the organization
|
5
|
+
def projects
|
6
|
+
@list.client.get("#{url}/projects")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Gets a Teambox::ResultSet of all Teambox::Membership objects belonging to the organization
|
10
|
+
def memberships
|
11
|
+
@list.client.get("#{url}/memberships")
|
12
|
+
end
|
13
|
+
|
14
|
+
def url #:nodoc:
|
15
|
+
"/organizations/#{@data['permalink']||@data['id']}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Page < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
def project
|
8
|
+
get_or_make_reference('Project', @data, 'project_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns an Array of Teambox::PageSlot
|
12
|
+
def slots
|
13
|
+
get_or_make_references('PageSlot', @data, 'slot_ids', 'slots')
|
14
|
+
end
|
15
|
+
|
16
|
+
def url #:nodoc:
|
17
|
+
"/projects/#{@data['project_id']}/pages/#{@data['id']}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Teambox
|
2
|
+
class PageSlot < Teambox::Resource
|
3
|
+
def page
|
4
|
+
get_or_make_reference('Page', @data, 'page_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
# The Teambox::Note, Teambox::Divider, or Teambox::Upload attached to this slot
|
8
|
+
def rel_object
|
9
|
+
get_or_make_reference(@data['rel_object_type'], @data, 'rel_object_id')
|
10
|
+
end
|
11
|
+
|
12
|
+
def url #:nodoc:
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Person < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
def source_user
|
8
|
+
get_or_make_reference('User', @data, 'source_user_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
def project
|
12
|
+
get_or_make_reference('Project', @data, 'project_id')
|
13
|
+
end
|
14
|
+
|
15
|
+
def url #:nodoc:
|
16
|
+
"/projects/#{@data['project_id']}/people/#{@data['id']}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Project < Teambox::Resource
|
3
|
+
# Teambox::User who created this project
|
4
|
+
def owner_user
|
5
|
+
get_or_make_reference('User', @data, 'owner_user_id')
|
6
|
+
end
|
7
|
+
|
8
|
+
def url #:nodoc:
|
9
|
+
"/projects/#{@data['permalink']||@data['id']}"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns a Teambox::ResultSet of conversations in this project
|
13
|
+
def conversations(query=nil)
|
14
|
+
@list.client.get("#{url}/conversations", query)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns a Teambox::ResultSet of task lists in this project
|
18
|
+
def task_lists(query=nil)
|
19
|
+
@list.client.get("#{url}/task_lists", query)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns a Teambox::ResultSet of tasks in this project
|
23
|
+
def tasks(query=nil)
|
24
|
+
@list.client.get("#{url}/tasks", query)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns a Teambox::ResultSet of comments in this project
|
28
|
+
def comments(query=nil)
|
29
|
+
@list.client.get("#{url}/comments", query)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a new Teambox::Conversation in this project
|
33
|
+
def create_conversation(opts={})
|
34
|
+
@list.client.post("#{url}/conversations", opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Creates a new Teambox::TaskList in this project
|
38
|
+
def create_task_list(opts={})
|
39
|
+
@list.client.post("#{url}/task_lists", opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Creates a new Teambox::Task in this project
|
43
|
+
def create_task(task_list, opts={})
|
44
|
+
@list.client.post("#{url}/task_lists/#{task_list.id}/tasks", opts)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Creates a new Teambox::Comment in target belonging to this project
|
48
|
+
def create_comment(target, opts={})
|
49
|
+
@list.client.post("#{url}/comments", opts.merge({'target_type' => target.class.to_s, 'target_id' => target.id}))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Teambox
|
2
|
+
class Task < Teambox::Resource
|
3
|
+
STATUS_NAMES = [:new, :open, :hold, :resolved, :rejected]
|
4
|
+
STATUSES = [0,1,2,3,4]
|
5
|
+
|
6
|
+
def user
|
7
|
+
get_or_make_reference('User', @data, 'user_id')
|
8
|
+
end
|
9
|
+
|
10
|
+
# Teambox::TaskList this task belongs to
|
11
|
+
def task_list
|
12
|
+
get_or_make_reference('TaskList', @data, 'task_list_id')
|
13
|
+
end
|
14
|
+
|
15
|
+
# First Teambox::Comment of the task
|
16
|
+
def first_comment
|
17
|
+
get_or_make_reference('Comment', @data, 'first_comment_id')
|
18
|
+
end
|
19
|
+
|
20
|
+
# Last two Teambox::Comment of the task (may include first_comment)
|
21
|
+
def recent_comments
|
22
|
+
get_or_make_references('Comment', @data, 'recent_comment_ids')
|
23
|
+
end
|
24
|
+
|
25
|
+
# Gets a Teambox::ResultSet of all Teambox::Comment objects belonging to the conversation
|
26
|
+
def comments
|
27
|
+
@list.client.get("#{url}/comments")
|
28
|
+
end
|
29
|
+
|
30
|
+
# The Teambox::Person assigned this task
|
31
|
+
def assigned
|
32
|
+
get_or_make_reference('Person', @data, 'assigned_id')
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sets the Teambox::Person assigned this task
|
36
|
+
def assigned=(value)
|
37
|
+
@data['assigned_id'] = set_reference('Person', value).id
|
38
|
+
end
|
39
|
+
|
40
|
+
# Current due date
|
41
|
+
def due_on
|
42
|
+
@data['due_on'] ? Date.parse(@data['due_on']) : nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def due_on=(value)
|
46
|
+
@data['due_on'] = value.strftime('%Y-%m-%d %H:%M:%S %z')
|
47
|
+
end
|
48
|
+
|
49
|
+
def comment=(value)
|
50
|
+
@data['comments_attributes'] = {'0' => {'body' => value}}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Current status
|
54
|
+
def status_name
|
55
|
+
STATUS_NAMES[@data['status']]
|
56
|
+
end
|
57
|
+
|
58
|
+
def status_name=(value)
|
59
|
+
@data['status'] = STATUS_NAMES.index(value.to_sym)
|
60
|
+
end
|
61
|
+
|
62
|
+
def url #:nodoc:
|
63
|
+
"/tasks/#{@data['id']}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Teambox
|
2
|
+
class TaskList < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
# Time this task list commences
|
8
|
+
def start_on
|
9
|
+
@data.has_key?('start_on') ? Time.parse(data['start_on']) : nil
|
10
|
+
end
|
11
|
+
|
12
|
+
# Time this task list finished
|
13
|
+
def finish_on
|
14
|
+
@data.has_key?('finish_on') ? Time.parse(data['finish_on']) : nil
|
15
|
+
end
|
16
|
+
|
17
|
+
# Time this task list was completed
|
18
|
+
def completed_at
|
19
|
+
@data.has_key?('completed_at') ? Time.parse(data['completed_at']) : nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def url #:nodoc:
|
23
|
+
"/task_lists/#{@data['id']}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Teambox
|
2
|
+
class TeamboxData < Teambox::Resource
|
3
|
+
def user
|
4
|
+
get_or_make_reference('User', @data, 'user_id')
|
5
|
+
end
|
6
|
+
|
7
|
+
# Time this data was processed
|
8
|
+
def processed_at
|
9
|
+
@data.has_key?('processed_at') ? Time.parse(data['processed_at']) : nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def url #:nodoc:
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|