Sha256: d3b0dee3f04e06598464f49c3457ee95bab2556b0c3d9bf15d85b47e01e7b624

Contents?: true

Size: 904 Bytes

Versions: 5

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

require 'date'

module Geet
  module Github
    class Label
      attr_reader :name, :color

      def initialize(name, color)
        @name = name
        @color = color
      end

      # Returns a flat list of names in string form.
      def self.list(api_interface)
        api_path = 'labels'
        response = api_interface.send_request(api_path, multipage: true)

        response.map do |label_entry|
          name = label_entry.fetch('name')
          color = label_entry.fetch('color')

          new(name, color)
        end
      end

      # See https://developer.github.com/v3/issues/labels/#create-a-label
      def self.create(name, color, api_interface)
        api_path = 'labels'
        request_data = { name: name, color: color }

        api_interface.send_request(api_path, data: request_data)

        new(name, color)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
geet-0.3.2 lib/geet/github/label.rb
geet-0.3.1 lib/geet/github/label.rb
geet-0.3.0 lib/geet/github/label.rb
geet-0.2.1 lib/geet/github/label.rb
geet-0.2.0 lib/geet/github/label.rb