Class: GithubGraphApi
- Inherits:
-
Object
- Object
- GithubGraphApi
- Defined in:
- lib/github_graph_api.rb
Overview
Understands github graph api
Constant Summary collapse
- ENDPOINT =
"https://api.github.com/graphql"
Instance Method Summary collapse
- #fetch_vulnerabilities(project:, owner:) ⇒ Object
-
#initialize(oauth_token) ⇒ GithubGraphApi
constructor
A new instance of GithubGraphApi.
Constructor Details
#initialize(oauth_token) ⇒ GithubGraphApi
Returns a new instance of GithubGraphApi.
8 9 10 11 12 |
# File 'lib/github_graph_api.rb', line 8 def initialize(oauth_token) raise "You must provide an oauth token" unless oauth_token @oauth_token = oauth_token end |
Instance Method Details
#fetch_vulnerabilities(project:, owner:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/github_graph_api.rb', line 14 def fetch_vulnerabilities(project:, owner:) uri = URI(ENDPOINT) https = Net::HTTP.new(uri.host, uri.port) # https.set_debug_output($stdout) https.use_ssl = true req = Net::HTTP::Post.new(uri.path, { "Authorization" => "bearer #{@oauth_token}" }) req.body = JSON[{ "query" => request_json(project: project, owner: owner) }] res = https.request(req) res.body end |