Module: PivotalTrackerApi::Story

Included in:
API
Defined in:
lib/pivotal_tracker_api/story.rb

Instance Method Summary collapse

Instance Method Details

#create_attachment(project_id, filename) ⇒ Object



30
31
32
# File 'lib/pivotal_tracker_api/story.rb', line 30

def create_attachment(project_id, filename)
  upload "/projects/#{project_id}/uploads", File.new(filename)
end

#create_comment(project_id, story_id, params = {}) ⇒ Object



23
24
25
# File 'lib/pivotal_tracker_api/story.rb', line 23

def create_comment(project_id, story_id, params={})
  post "/projects/#{project_id}/stories/#{story_id}/comments", params
end

#create_story(project_id, params = {}) ⇒ Object

Raises:



26
27
28
29
# File 'lib/pivotal_tracker_api/story.rb', line 26

def create_story(project_id, params={})
  raise ArgumentError.new(":name is required") if params[:name].nil?
  post "/projects/#{project_id}/stories", params
end

#find_stories_by_project_id(project_id, params = {}) ⇒ Object



4
5
6
# File 'lib/pivotal_tracker_api/story.rb', line 4

def find_stories_by_project_id(project_id, params={})
  get "/projects/#{project_id}/stories"
end

#find_story_by_project_id_and_id(project_id, id, params = {}) ⇒ Object



8
9
10
# File 'lib/pivotal_tracker_api/story.rb', line 8

def find_story_by_project_id_and_id(project_id, id, params={})
  get "/projects/#{project_id}/stories/#{id}" 
end

#update_story(project_id, id, params) ⇒ Object



20
21
22
# File 'lib/pivotal_tracker_api/story.rb', line 20

def update_story(project_id, id, params)
  put "/projects/#{project_id}/stories/#{id}", params
end

#upload_attachment(project_id, id, filename, params = {}) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
# File 'lib/pivotal_tracker_api/story.rb', line 12

def upload_attachment(project_id, id, filename, params={})
  raise ArgumentError.new(":project_id is required") unless project_id
  raise ArgumentError.new(":id is required") unless id
  raise ArgumentError.new(":filename is required") unless filename
  attachment = create_attachment project_id, filename
  upload_url = "https://www.pivotaltracker.com#{attachment['download_url']}"
  create_comment project_id, id, "text" => upload_url
end