class TrackerDeliveries::PivotalTracker

Constants

API_URL
STORY_URL

Attributes

api[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/tracker_deliveries/pivotal_tracker.rb, line 10
def initialize options = {}
  @api_token = options[:api_token]
  @project_id = options[:project_id]
  @api_url = options[:api] || API_URL

  @formatter = StoryFormatter.new(
    options[:format] || :plaintext,
    STORY_URL
  )

  @api = Blanket.wrap(
    @api_url,
    headers: {
      'X-TrackerToken' => @api_token
    }
  )
end

Public Instance Methods

delivered_stories() click to toggle source
# File lib/tracker_deliveries/pivotal_tracker.rb, line 28
def delivered_stories
  params = {
    params:
      {
        with_state: "delivered"
      }
  }

  begin
    @formatter.format(
      api
        .projects(@project_id)
        .stories.get(params).payload
    )
  rescue Blanket::Forbidden
    STDERR.puts "PivotalTracker responded with: 403 (Forbidden) project: #{@project_id}, api_token: #{@api_token}"
  rescue Blanket::ResourceNotFound
    STDERR.puts "PivotalTracker responded with: 404 (Not Found) project: #{@project_id}, api_token: #{@api_token}"
  end
end