Sha256: 4646d6736ec9fb969f1bd02f5329bf002d6e2729bef7173084349653caa658ce

Contents?: true

Size: 1.07 KB

Versions: 21

Compression:

Stored size: 1.07 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
        story.clean!
        story
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
tracker_api-1.16.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.15.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.14.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.13.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.12.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.11.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.10.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.9.1 lib/tracker_api/endpoints/story.rb
tracker_api-1.9.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.8.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.7.1 lib/tracker_api/endpoints/story.rb
tracker_api-1.7.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.6.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.5.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.4.1 lib/tracker_api/endpoints/story.rb
tracker_api-1.4.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.3.0 lib/tracker_api/endpoints/story.rb
tracker_api-1.2.1 lib/tracker_api/endpoints/story.rb
tracker_api-1.1.1 lib/tracker_api/endpoints/story.rb
tracker_api-1.1.0 lib/tracker_api/endpoints/story.rb