Class: PivotalTracker
- Inherits:
-
Object
show all
- Includes:
- HTTParty
- Defined in:
- lib/pivotal_tracker.rb
Defined Under Namespace
Classes: BadRequest, Error, General, InformPivotal, ResourceInvalid, ResourceNotFound, Unauthorized, Unavailable
Instance Method Summary
collapse
-
#add_project_membership(project_id, role, email, options = {}) ⇒ Object
-
#add_project_story(project_id, story) ⇒ Object
-
#add_project_story_note(project_id, story_id, text) ⇒ Object
-
#create_project(name, options = {}) ⇒ Object
-
#delete_project_story(project_id, story_id) ⇒ Object
-
#get_all_activities(options = {}) ⇒ Object
-
#get_all_project_activities(project_id, options = {}) ⇒ Object
-
#get_all_project_iterations(project_id, options = {}) ⇒ Object
-
#get_all_project_memberships(project_id) ⇒ Object
-
#get_all_project_stories(project_id, options = {}) ⇒ Object
-
#get_all_projects ⇒ Object
-
#get_project(project_id) ⇒ Object
-
#get_project_membership(project_id, membership_id) ⇒ Object
-
#initialize(api_token, options = {}) ⇒ PivotalTracker
constructor
A new instance of PivotalTracker.
-
#move_project_story(project_id, story_id, direction, target_story_id) ⇒ Object
-
#remove_project_membership(project_id, membership_id) ⇒ Object
-
#update_project_story(project_id, story_id, story) ⇒ Object
Constructor Details
#initialize(api_token, options = {}) ⇒ PivotalTracker
Returns a new instance of PivotalTracker.
10
11
12
13
14
|
# File 'lib/pivotal_tracker.rb', line 10
def initialize(api_token, options = {})
self.class. 'X-TrackerToken' => api_token
use_ssl = options.delete(:ssl)
self.class.base_uri "http#{'s' if use_ssl}://www.pivotaltracker.com/services/v3"
end
|
Instance Method Details
#add_project_membership(project_id, role, email, options = {}) ⇒ Object
58
59
60
61
62
|
# File 'lib/pivotal_tracker.rb', line 58
def add_project_membership(project_id, role, email, options = {})
response = self.class.post("/projects/#{project_id}/memberships", :body => {:membership => {:role => role, :person => options.merge(:email => email)}})
raise_errors(response)
parse_response(response, 'membership')
end
|
#add_project_story(project_id, story) ⇒ Object
86
87
88
89
90
|
# File 'lib/pivotal_tracker.rb', line 86
def add_project_story(project_id, story)
response = self.class.post("/projects/#{project_id}/stories", :body => {:story => story})
raise_errors(response)
parse_response(response, 'story')
end
|
#add_project_story_note(project_id, story_id, text) ⇒ Object
104
105
106
107
108
|
# File 'lib/pivotal_tracker.rb', line 104
def add_project_story_note(project_id, story_id, text)
response = self.class.post("/projects/#{project_id}/stories/#{story_id}/notes", :body => {:note => {:text => text}})
raise_errors(response)
parse_response(response, 'note')
end
|
#create_project(name, options = {}) ⇒ Object
40
41
42
43
44
|
# File 'lib/pivotal_tracker.rb', line 40
def create_project(name, options = {})
response = self.class.post('/projects', :body => {:project => options.merge(:name => name)})
raise_errors(response)
parse_response(response, 'project')
end
|
#delete_project_story(project_id, story_id) ⇒ Object
98
99
100
101
102
|
# File 'lib/pivotal_tracker.rb', line 98
def delete_project_story(project_id, story_id)
response = self.class.delete("/projects/#{project_id}/stories/#{story_id}")
raise_errors(response)
parse_response(response, 'story')
end
|
#get_all_activities(options = {}) ⇒ Object
16
17
18
19
20
|
# File 'lib/pivotal_tracker.rb', line 16
def get_all_activities(options = {})
response = self.class.get("/activities", :query => options)
raise_errors(response)
parse_response(response, 'activities')
end
|
#get_all_project_activities(project_id, options = {}) ⇒ Object
22
23
24
25
26
|
# File 'lib/pivotal_tracker.rb', line 22
def get_all_project_activities(project_id, options = {})
response = self.class.get("/projects/#{project_id}/activities", :query => options)
raise_errors(response)
parse_response(response, 'activities')
end
|
#get_all_project_iterations(project_id, options = {}) ⇒ Object
70
71
72
73
74
|
# File 'lib/pivotal_tracker.rb', line 70
def get_all_project_iterations(project_id, options = {})
response = self.class.get("/projects/#{project_id}/iterations", :query => options)
raise_errors(response)
parse_response(response, 'iterations')
end
|
#get_all_project_memberships(project_id) ⇒ Object
46
47
48
49
50
|
# File 'lib/pivotal_tracker.rb', line 46
def get_all_project_memberships(project_id)
response = self.class.get("/projects/#{project_id}/memberships")
raise_errors(response)
parse_response(response, 'memberships')
end
|
#get_all_project_stories(project_id, options = {}) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/pivotal_tracker.rb', line 76
def get_all_project_stories(project_id, options = {})
if options[:filter]
options[:filter] = options[:filter].inject([]) {|f,(key,value)| f << "#{key}:#{value}"}.join(' ')
end
response = self.class.get("/projects/#{project_id}/stories", :query => options)
raise_errors(response)
parse_response(response, 'stories')
end
|
#get_all_projects ⇒ Object
28
29
30
31
32
|
# File 'lib/pivotal_tracker.rb', line 28
def get_all_projects
response = self.class.get("/projects")
raise_errors(response)
parse_response(response, 'projects')
end
|
#get_project(project_id) ⇒ Object
34
35
36
37
38
|
# File 'lib/pivotal_tracker.rb', line 34
def get_project(project_id)
response = self.class.get("/projects/#{project_id}")
raise_errors(response)
parse_response(response, 'project')
end
|
#get_project_membership(project_id, membership_id) ⇒ Object
52
53
54
55
56
|
# File 'lib/pivotal_tracker.rb', line 52
def get_project_membership(project_id, membership_id)
response = self.class.get("/projects/#{project_id}/memberships/#{membership_id}")
raise_errors(response)
parse_response(response, 'membership')
end
|
#move_project_story(project_id, story_id, direction, target_story_id) ⇒ Object
110
111
112
113
114
|
# File 'lib/pivotal_tracker.rb', line 110
def move_project_story(project_id, story_id, direction, target_story_id)
response = self.class.post("/projects/#{project_id}/stories/#{story_id}/moves", :body => {:move => {:move => direction, :target => target_story_id}})
raise_errors(response)
parse_response(response, 'story')
end
|
#remove_project_membership(project_id, membership_id) ⇒ Object
64
65
66
67
68
|
# File 'lib/pivotal_tracker.rb', line 64
def remove_project_membership(project_id, membership_id)
response = self.class.delete("/projects/#{project_id}/memberships/#{membership_id}")
raise_errors(response)
parse_response(response, 'membership')
end
|
#update_project_story(project_id, story_id, story) ⇒ Object
92
93
94
95
96
|
# File 'lib/pivotal_tracker.rb', line 92
def update_project_story(project_id, story_id, story)
response = self.class.put("/projects/#{project_id}/stories/#{story_id}", :body => {:story => story})
raise_errors(response)
parse_response(response, 'story')
end
|