Class: TrackerApi::Resources::Project

Inherits:
Object
  • Object
show all
Includes:
Shared::Base
Defined in:
lib/tracker_api/resources/project.rb

Instance Method Summary collapse

Methods included from Shared::Base

included

Instance Method Details

#activity(params = {}) ⇒ Array[Activity]

Provides a list of all the activity performed on a project.

Parameters:

  • params (Hash) (defaults to: {})

Returns:



159
160
161
# File 'lib/tracker_api/resources/project.rb', line 159

def activity(params={})
  Endpoints::Activity.new(client).get_project(id, params)
end

#add_membership(params) ⇒ ProjectMembership

Add a new membership for the project.

Parameters:

  • params (Hash)

    attributes to add a member; must have at least email or user_id

Returns:



199
200
201
# File 'lib/tracker_api/resources/project.rb', line 199

def add_membership(params)
  Endpoints::Memberships.new(client).add(id, params)
end

#add_webhook(params) ⇒ Webhook

Create a new webhook for the project.

Parameters:

  • params (Hash)

    attributes to add a webhook; must have webhook_url, webhook_version

Returns:

  • (Webhook)

    webhook that was added to project



215
216
217
# File 'lib/tracker_api/resources/project.rb', line 215

def add_webhook(params)
  Endpoints::Webhook.new(client).create(id, params)
end

#create_epic(params) ⇒ epic

Create a new epic in the project.

Parameters:

  • params (Hash)

    attributes to create the epic with

Returns:

  • (epic)

    newly created Epic



191
192
193
# File 'lib/tracker_api/resources/project.rb', line 191

def create_epic(params)
  Endpoints::Epic.new(client).create(id, params)
end

#create_story(params) ⇒ Story

Create a new story in the project.

Parameters:

  • params (Hash)

    attributes to create the story with

Returns:

  • (Story)

    newly created Story



175
176
177
# File 'lib/tracker_api/resources/project.rb', line 175

def create_story(params)
  Endpoints::Story.new(client).create(id, params)
end

#delete_webhook(webhook_id) ⇒ Object

Delete webhook from the project.

Returns:

  • true of false depends on result of delition



222
223
224
# File 'lib/tracker_api/resources/project.rb', line 222

def delete_webhook(webhook_id)
  Endpoints::Webhook.new(client).delete_from_project(id, webhook_id)
end

#epic(epic_id, params = {}) ⇒ Epic

Find a epic by id for the project.

Parameters:

  • epic_id (Fixnum)

    id of epic to get

Returns:

  • (Epic)

    epic with given id



183
184
185
# File 'lib/tracker_api/resources/project.rb', line 183

def epic(epic_id, params={})
  Endpoints::Epic.new(client).get(id, epic_id, params)
end

#epics(params = {}) ⇒ Array[Epic]

Provides a list of all the epics in the project.

Parameters:

  • params (Hash) (defaults to: {})

Returns:

  • (Array[Epic])

    epics associated with this project



69
70
71
72
73
74
75
# File 'lib/tracker_api/resources/project.rb', line 69

def epics(params={})
  if @epics && @epics.present?
    @epics
  else
    @epics = Endpoints::Epics.new(client).get(id, params)
  end
end

#iterations(params = {}) ⇒ Array[Iteration]

Provides a list of all the iterations in the project.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :scope (String)

    Restricts the state of iterations to return. If not specified, it defaults to all iterations including done. Valid enumeration values: done, current, backlog, current_backlog.

  • :number (Integer)

    The iteration to retrieve, starting at 1

  • :offset (Integer)

    The offset of first iteration to return, relative to the set of iterations specified by ‘scope’, with zero being the first iteration in the scope.

  • :limit (Integer)

    The number of iterations to return relative to the offset.

Returns:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/tracker_api/resources/project.rb', line 100

def iterations(params={})
  if params.include?(:number)
    number = params[:number].to_i
    raise ArgumentError, ':number must be > 0' unless number > 0

    params = params.merge(auto_paginate: false, limit: 1)
    params.delete(:number)

    offset          = number - 1
    params[:offset] = offset if offset > 0
  end

  Endpoints::Iterations.new(client).get(id, params)
end

#label_idsInteger

Returns comma separated list of label_ids.

Returns:

  • (Integer)

    comma separated list of label_ids



49
50
51
# File 'lib/tracker_api/resources/project.rb', line 49

def label_ids
  @label_ids ||= labels.collect(&:id).join(',')
end

#label_listString

Returns comma separated list of labels.

Returns:

  • (String)

    comma separated list of labels



44
45
46
# File 'lib/tracker_api/resources/project.rb', line 44

def label_list
  @label_list ||= labels.collect(&:name).join(',')
end

#labels(params = {}) ⇒ Array[Label]

Provides a list of all the labels on the project.

Parameters:

  • params (Hash) (defaults to: {})

Returns:



57
58
59
60
61
62
63
# File 'lib/tracker_api/resources/project.rb', line 57

def labels(params = {})
  if @labels && @labels.present?
    @labels
  else
    @labels = Endpoints::Labels.new(client).get(id, params)
  end
end

#memberships(params = {}) ⇒ Array[ProjectMembership]

Provides a list of all the memberships in the project.

Parameters:

  • params (Hash) (defaults to: {})

Returns:



151
152
153
# File 'lib/tracker_api/resources/project.rb', line 151

def memberships(params={})
  Endpoints::Memberships.new(client).get(id, params)
end

#releases(params = {}) ⇒ Array[Release]

Provides a list of all the releases in the project.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :with_state (String)

    A release’s current_state which all returned releases must match. Valid enumeration values: accepted, delivered, finished, started, rejected, unstarted, unscheduled

  • :offset (Integer)

    With the first release in your priority list as 0, the index of the first release you want returned.

  • :limit (Integer)

    The number of releases you want returned.

Returns:

  • (Array[Release])

    releases associated with this project



143
144
145
# File 'lib/tracker_api/resources/project.rb', line 143

def releases(params={})
  Endpoints::Releases.new(client).get(id, params)
end

#search(query, params = {}) ⇒ SearchResultsContainer

Search for a term in the given project. This can be an arbitrary term or a specific search query. See www.pivotaltracker.com/help/articles/advanced_search/

Parameters:

  • query (String)

    A versatile search query

  • params (Hash) (defaults to: {})

Returns:

  • (SearchResultsContainer)

    An object composed of Epic(s) [EpicsSearchResult] and Story(s) [StoriesSearchResults]



232
233
234
# File 'lib/tracker_api/resources/project.rb', line 232

def search(query, params={})
  Endpoints::Search.new(client).get(id, query, params)
end

#stories(params = {}) ⇒ Array[Story]

Provides a list of all the stories in the project.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :with_label (String)

    A label name which all returned stories must match.

  • :with_state (String)

    A story’s current_state which all returned stories must match. Valid enumeration values: accepted, delivered, finished, started, rejected, unstarted, unscheduled

  • :filter (String)

    This parameter supplies a search string; only stories that match the search criteria are returned. Cannot be used together with any other parameters except limit and offset. ex) state:started requester:OWK label:“jedi stuff” keyword

  • :offset (Integer)

    With the first story in your priority list as 0, the index of the first story you want returned.

  • :limit (Integer)

    The number of stories you want returned.

Returns:

  • (Array[Story])

    stories associated with this project



130
131
132
# File 'lib/tracker_api/resources/project.rb', line 130

def stories(params={})
  Endpoints::Stories.new(client).get(id, params)
end

#story(story_id, params = {}) ⇒ Story

Find a story by id for the project.

Parameters:

  • story_id (Fixnum)

    id of story to get

Returns:

  • (Story)

    story with given id



167
168
169
# File 'lib/tracker_api/resources/project.rb', line 167

def story(story_id, params={})
  Endpoints::Story.new(client).get(id, story_id, params)
end

#webhook(webhook_id, params = {}) ⇒ Webhook

Find a webhook for the project.

Parameters:

  • webhook_id (Fixnum)

    id of webhook to get

Returns:

  • (Webhook)

    webhook with given id



207
208
209
# File 'lib/tracker_api/resources/project.rb', line 207

def webhook(webhook_id, params={})
  Endpoints::Webhook.new(client).get(id, webhook_id, params)
end

#webhooks(params = {}) ⇒ Array[Webhook]

Provides a list of all the webhooks in the project.

Parameters:

  • params (Hash) (defaults to: {})

Returns:



81
82
83
84
85
86
87
# File 'lib/tracker_api/resources/project.rb', line 81

def webhooks(params={})
  if @webhooks && @webhooks.present?
    @webhooks
  else
    @webhooks = Endpoints::Webhooks.new(client).get(id, params)
  end
end