Sha256: 6c11c9c2c597c9eba7011ceeb8dfd82cac9773715e4c140b3e68931fe5913706

Contents?: true

Size: 695 Bytes

Versions: 23

Compression:

Stored size: 695 Bytes

Contents

module TrackerApi
  module Endpoints
    class Labels
      attr_accessor :client

      def initialize(client)
        @client = client
      end

      def get(project_id, params={})
        data = client.paginate("/projects/#{project_id}/labels", params: params)
        raise Errors::UnexpectedData, 'Array of labels expected' unless data.is_a? Array

        data.map do |label|
          Resources::Label.new({ project_id: project_id }.merge(label))
        end
      end

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

        Resources::Label.new({ project_id: project_id }.merge(data))
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
tracker_api-1.0.0 lib/tracker_api/endpoints/labels.rb
tracker_api-0.2.12 lib/tracker_api/endpoints/labels.rb
tracker_api-0.2.11 lib/tracker_api/endpoints/labels.rb