Sha256: 5b6cd1db0d09af1290dbd82fa59570ec7ad706e6ef5b6a843afb27d52fb6fd23

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module TrackerApi
  module Endpoints
    class Story
      attr_accessor :client

      def initialize(client)
        @client = client
      end

      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

      def get_story(story_id, params={})
        data = client.get("/stories/#{story_id}", params: params).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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tracker_api-0.2.12 lib/tracker_api/endpoints/story.rb
tracker_api-0.2.11 lib/tracker_api/endpoints/story.rb
tracker_api-0.2.10 lib/tracker_api/endpoints/story.rb