-
-
Save jkatz/486935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'json' | |
class GithubAPI | |
HOST = "github.com" | |
API = "/api/v2" | |
attr_accessor :format | |
attr_reader :response, :user | |
def initialize(username, token, params={}) | |
@username, @token = username, token | |
@format = params[:format] || "json" | |
end | |
def api | |
API | |
end | |
def get_user_info(username, token) | |
path = [api,format,'user','show'].join('/') | |
connect(path, username, token) | |
end | |
def get_all_commit_history(value) | |
end | |
def host | |
HOST | |
end | |
private | |
def connect(path, username, token) | |
params = { :token => token, :login => username } | |
query = params.map { |k,v| "k=v" }.join('&') | |
Net::HTTP.start(host) do |http| | |
req = Net::HTTP::Get.new("#{path}?#{query}") | |
@response = http.request(req) | |
@user = JSON.parse(@response.body) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick passthrough with my thoughts...nothing earth-shattering on my end