class TrackerApi::Endpoints::Story

Attributes

client[RW]

Public Class Methods

new(client) click to toggle source
# File lib/tracker_api/endpoints/story.rb, line 6
def initialize(client)
  @client = client
end

Public Instance Methods

create(project_id, params={}) click to toggle source
# File lib/tracker_api/endpoints/story.rb, line 22
def create(project_id, params={})
  data = client.post("/projects/#{project_id}/stories", params: params).body

  Resources::Story.new({ client: client }.merge(data))
end
get(project_id, id, params={}) click to toggle source
# File lib/tracker_api/endpoints/story.rb, line 10
def get(project_id, id, params={})
  data = client.get("/projects/#{project_id}/stories/#{id}", params: params).body

  Resources::Story.new({ client: client, project_id: project_id }.merge(data))
end
get_story(story_id, params={}) click to toggle source
# File lib/tracker_api/endpoints/story.rb, line 16
def get_story(story_id, params={})
  data = client.get("/stories/#{story_id}", params: params).body

  Resources::Story.new({ client: client }.merge(data))
end
update(story, params={}) click to toggle source
# File lib/tracker_api/endpoints/story.rb, line 28
def update(story, params={})
  raise ArgumentError, 'Valid story required to update.' unless story.instance_of?(Resources::Story)

  data = client.put("/projects/#{story.project_id}/stories/#{story.id}", params: params).body

  story.attributes = data
  story.clean!
  story
end