Sha256: 2cfca0ea9e024aea20c6bd46e8c58876ee94b2a186953508ec510ff096cd1ba5

Contents?: true

Size: 1.24 KB

Versions: 12

Compression:

Stored size: 1.24 KB

Contents

module TrackerApi
  module Endpoints
    class Story
      attr_accessor :client

      def initialize(client)
        @client = client
      end

      def get(project_id, id)
        data = client.get("/projects/#{project_id}/stories/#{id}").body

        Resources::Story.new({ client: client, project_id: project_id }.merge(data))
      end

      def get_story(story_id)
        data = client.get("/stories/#{story_id}").body

        Resources::Story.new({ client: client }.merge(data))
      end

      def create(project_id, params={})
        data = client.post("/projects/#{project_id}/stories", params: params).body

        Resources::Story.new({ client: client }.merge(data))
      end

      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
      end

      def add_label(story, params = {})
        raise ArgumentError, 'Valid story required to update.' unless story.instance_of?(Resources::Story)
        data = client.post("/projects/#{story.project_id}/stories/#{story.id}/labels", params: params).body
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
v2gpti-1.3.5 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.3.4 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.3.3 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.3.2 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.3.1 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.3.0 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.2.9 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.2.8 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.2.7 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.2.6 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.2.5 tracker_api/lib/tracker_api/endpoints/story.rb
v2gpti-1.2.4 tracker_api/lib/tracker_api/endpoints/story.rb