Sha256: 55d72ef24712ca7dbe015ed340ca9e05ffe0c95ed006170815a9099e2b29e2cf

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

module Geet
  module Github
    class User
      attr_reader :username

      def initialize(username)
        @username = username
      end

      # See https://developer.github.com/v3/users/#get-the-authenticated-user
      #
      def self.authenticated(api_interface)
        api_path = '/user'

        response = api_interface.send_request(api_path)

        new(response.fetch('login'))
      end

      # Returns an array of User instances
      #
      def self.list_collaborators(api_interface)
        api_path = 'collaborators'
        response = api_interface.send_request(api_path, multipage: true)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geet-0.3.3 lib/geet/github/user.rb