Sha256: 552af3c7a2d865eee1cfc93356d757fa52ad7670105782884c02ae5801f0c640

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Geet
  module Github
    # See AbstractIssue for the circular dependency issue notes.
    autoload :AbstractIssue, File.expand_path('abstract_issue', __dir__)

    class Issue < Geet::Github::AbstractIssue
      def self.create(title, description, api_interface)
        api_path = 'issues'
        request_data = { title: title, body: description, base: 'master' }

        response = api_interface.send_request(api_path, data: request_data)

        issue_number, title, link = response.fetch_values('number', 'title', 'html_url')

        new(issue_number, api_interface, title, link)
      end

      # See https://developer.github.com/v3/issues/#list-issues-for-a-repository
      #
      def self.list(api_interface)
        api_path = 'issues'

        response = api_interface.send_request(api_path, multipage: true)

        response.each_with_object([]) do |issue_data, result|
          if !issue_data.key?('pull_request')
            number = issue_data.fetch('number')
            title = issue_data.fetch('title')
            link = issue_data.fetch('html_url')

            result << new(number, api_interface, title, link)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
geet-0.1.12 lib/geet/github/issue.rb
geet-0.1.11 lib/geet/github/issue.rb
geet-0.1.10 lib/geet/github/issue.rb
geet-0.1.9 lib/geet/github/issue.rb