Created
March 1, 2010 20:49
-
-
Save sipple/318791 to your computer and use it in GitHub Desktop.
Beginnings of a Github API class.
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
class GithubAPI | |
require 'net/http' | |
require 'net/https' | |
require 'uri' | |
require 'open-uri' | |
# Get the configuration values from APP_CONFIG | |
Token = APP_CONFIG['github_api_token'] | |
Base_Url = APP_CONFIG['github_api_url'] | |
User = APP_CONFIG['github_api_user'] | |
Repo = APP_CONFIG['github_api_repo'] | |
Open_Issue_Action = 'issues/open' | |
Url_Format = '%s/%s/%s/%s' #Base URL + Action + User + Repo | |
# Create an issue in Github for the Support Center | |
def create_issue(submitter, title, body) | |
# Build the Open Issue URL | |
open_issue_url = URI.parse(sprintf(Url_Format, Base_Url, Open_Issue_Action, User, Repo)) | |
# Private github repos must be interacted with via https/ssl | |
http = Net::HTTP.new(open_issue_url.host, open_issue_url.port) | |
http.use_ssl = true | |
# Create the ticket and return the response | |
request = Net::HTTP::Post.new(open_issue_url.request_uri) | |
request.set_form_data({'title' => title, | |
'body' => submitter + ': ' + body, | |
'login' => User, | |
'token' => Token}) | |
response = http.request(request) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment