Class: TrackerApi::Endpoints::Story
- Defined in:
- lib/tracker_api/endpoints/story.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create(project_id, params = {}) ⇒ Object
- #get(project_id, id, params = {}) ⇒ Object
- #get_story(story_id, params = {}) ⇒ Object
-
#initialize(client) ⇒ Story
constructor
A new instance of Story.
- #update(story, params = {}) ⇒ Object
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
#client ⇒ Object
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
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 |