Sha256: c76452ab249ef4c406c296c07b42bb3e98082ddafa5721d03b8d4807fd92a2cd

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require_relative 'api_helper'
require_relative 'gist'
require_relative 'issue'
require_relative 'pr'

module Geet
  module GitHub
    class RemoteRepository
      def initialize(local_repository, api_helper)
        @local_repository = local_repository
        @api_helper = api_helper
      end

      def collaborators
        url = "https://api.github.com/repos/#{@local_repository.owner}/#{@local_repository.repo}/collaborators"
        response = @api_helper.send_request(url, multipage: true)

        response.map { |user_entry| user_entry.fetch('login') }
      end

      def labels
        url = "https://api.github.com/repos/#{@local_repository.owner}/#{@local_repository.repo}/labels"
        response = @api_helper.send_request(url, multipage: true)

        response.map { |label_entry| label_entry['name'] }
      end

      def create_gist(filename, content, description: nil, publik: false)
        Geet::GitHub::Gist.create(@local_repository, filename, content, @api_helper, description: description, publik: publik)
      end

      def create_issue(title, description)
        Geet::GitHub::Issue.create(@local_repository, title, description, @api_helper)
      end

      def list_issues
        Geet::GitHub::Issue.list(@local_repository, @api_helper)
      end

      def create_pr(title, description, head: @local_repository.current_head)
        Geet::GitHub::PR.create(@local_repository, title, description, head, @api_helper)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geet-0.1.2 lib/geet/git_hub/remote_repository.rb