Class: TrackerApi::Endpoints::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/tracker_api/endpoints/story.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Story

Returns a new instance of Story.



6
7
8
# File 'lib/tracker_api/endpoints/story.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/tracker_api/endpoints/story.rb', line 4

def client
  @client
end

Instance Method Details

#create(project_id, params = {}) ⇒ Object



22
23
24
25
26
# 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 = {}) ⇒ Object



10
11
12
13
14
# 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 = {}) ⇒ Object



16
17
18
19
20
# 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 = {}) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
# 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