Module: Pivit::Client::Story

Included in:
Pivit::Client
Defined in:
lib/pivit/client/story.rb

Overview

Story management

Instance Method Summary collapse

Instance Method Details

#add_attachment(project_id, story_id, file, options = {}) ⇒ Hashie::Mash

Add an attachement to a story

Examples:

Pivit::Client.add_attachment(12345, 111111, "test.txt")

Parameters:

  • project_id (Integer)

    the id of the project that contains the story

  • story_id (Integer)

    the id of the story that is getting moved

  • file (String)

    the location of the file to be attached

Returns:

  • (Hashie::Mash)

    story attachement response

See Also:

Author:

  • Jason Truluck



157
158
159
160
# File 'lib/pivit/client/story.rb', line 157

def add_attachment(project_id, story_id, file, options = {})
  options.merge!(:payload => file)
  post("projects/#{project_id}/stories/#{story_id}/attachments", options).attachment
end

#create_story(project_id, options = {}) ⇒ Hashie::Mash

Create a story

Provide the parameters you want to use for the story via the options hash

Examples:

Pivit::Client.create_story({:type => "feature", :name => "Story"})

Parameters:

  • project_id (Integer)

    the id of the project that contains the story

Returns:

  • (Hashie::Mash)

    story created response

See Also:

Author:

  • Jason Truluck



64
65
66
67
# File 'lib/pivit/client/story.rb', line 64

def create_story(project_id, options = {})
  options = { :story => options }
  post("projects/#{project_id}/stories", options).story
end

#delete_story(project_id, story_id, options = {}) ⇒ Hashie::Mash

Delete a story

Examples:

Pivit::Client.delete_story(12345, 11111)

Parameters:

  • project_id (Integer)

    the id of the project that contains the story

  • story_id (Integer)

    the id of the story that is getting deleted

Returns:

  • (Hashie::Mash)

    story deleted response

See Also:

Author:

  • Jason Truluck



103
104
105
# File 'lib/pivit/client/story.rb', line 103

def delete_story(project_id, story_id, options = {})
  delete("projects/#{project_id}/stories/#{story_id}", options).story
end

#move_story_after(project_id, story_id, story_target_id, options = {}) ⇒ Hashie::Mash

Move a story after another story

Examples:

Pivit::Client.move_story_after(12345, 11111, 22222)

Parameters:

  • project_id (Integer)

    the id of the project that contains the story

  • story_id (Integer)

    the id of the story that is getting moved

  • story_target_id (Integer)

    the id of the story that the other story is moving after

Returns:

  • (Hashie::Mash)

    story move response

See Also:

Author:

  • Jason Truluck



139
140
141
# File 'lib/pivit/client/story.rb', line 139

def move_story_after(project_id, story_id, story_target_id, options = {})
  move_story(project_id, story_id, story_target_id, :after, options)
end

#move_story_before(project_id, story_id, story_target_id, options = {}) ⇒ Hashie::Mash

Move a story before another story

Examples:

Pivit::Client.move_story_before(12345, 11111, 22222)

Parameters:

  • project_id (Integer)

    the id of the project that contains the story

  • story_id (Integer)

    the id of the story that is getting moved

  • story_target_id (Integer)

    the id of the story that the other story is moving before

Returns:

  • (Hashie::Mash)

    story move response

See Also:

Author:

  • Jason Truluck



121
122
123
# File 'lib/pivit/client/story.rb', line 121

def move_story_before(project_id, story_id, story_target_id, options = {})
  move_story(project_id, story_id, story_target_id, :before, options)
end

#stories(project_id, options = {}) ⇒ Hashie::Mash

Retrieve all stories from your account

You can also use any filter option provided by pivotal tracker by prefacing with the option :filter

Examples:

Pivit::Client.stories(1111111)

Pivit::Client.stories(1111111, {:filter => "type:bug,chore"})

Parameters:

  • project_id (Integer)

    the id of the project that contains the stories

Returns:

  • (Hashie::Mash)

    stories response

See Also:

Author:

  • Jason Truluck



46
47
48
# File 'lib/pivit/client/story.rb', line 46

def stories(project_id, options = {})
  get("projects/#{project_id}/stories/", options).stories
end

#story(project_id, story_id, options = {}) ⇒ Hashie::Mash

Retrieve a single story from your account

Examples:

Pivit::Client.story(1111111, 123456)

Parameters:

  • project_id (Integer)

    the id of the project that you want to retrieve stories from

  • story_id (Integer)

    the id of the story that you want to retrieve

Returns:

  • (Hashie::Mash)

    story response

See Also:

Author:

  • Jason Truluck



22
23
24
# File 'lib/pivit/client/story.rb', line 22

def story(project_id, story_id, options = {})
  get("projects/#{project_id}/stories/#{story_id}", options).story
end

#update_story(project_id, story_id, options = {}) ⇒ Hashie::Mash

Update a story

Provide the parameters you want to use for the story via the options hash

Examples:

Pivit::Client.update_story(12345, 11111, {:name => "awesome new story name"})

Parameters:

  • project_id (Integer)

    the id of the project that contains the story

  • story_id (Integer)

    the id of the story that is getting updated

Returns:

  • (Hashie::Mash)

    story updated response

See Also:

Author:

  • Jason Truluck



85
86
87
88
# File 'lib/pivit/client/story.rb', line 85

def update_story(project_id, story_id, options = {})
  options = { :story => options }
  put("projects/#{project_id}/stories/#{story_id}",  options).story
end