Class: PivotalApi

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal.rb

Instance Method Summary collapse

Instance Method Details

#configure!(project, token) ⇒ Object



57
58
59
60
# File 'lib/pivotal.rb', line 57

def configure!(project, token)
  @token = token
  @project = project
end

#create_story(yaml_story) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/pivotal.rb', line 62

def create_story(yaml_story)
  story = {
      story_type: yaml_story.story_type,
      name: yaml_story.name,
      description: yaml_story.description,
      labels: yaml_story.labels.map { |label| {:name => label} },
      #requested_by_id: yaml_story.requested_by
  }

  response = post(url('stories'), story.to_json, headers)
  return response.success?, response.body
end

#stories(filter) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/pivotal.rb', line 75

def stories(filter)
  response = get(url('stories'), filter, headers)
  unless response.success?
    raise Exception.new "#{response.status} #{response.body}"
  end

  JSON.parse(response.body.encode('ASCII', :invalid => :replace, :undef => :replace, :replace => '?'))
end