Module: NetworkProfile::GithubGraphql
- Included in:
- GithubProfile, GithubProject
- Defined in:
- lib/network_profile/extractors/github_graphql.rb
Instance Method Summary collapse
Instance Method Details
#doc ⇒ Object
21 22 23 |
# File 'lib/network_profile/extractors/github_graphql.rb', line 21 def doc raise NotImplementedError end |
#json ⇒ Object
17 18 19 |
# File 'lib/network_profile/extractors/github_graphql.rb', line 17 def json @json ||= query!(query) end |
#query!(query) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/network_profile/extractors/github_graphql.rb', line 4 def query!(query) r = Typhoeus.post("https://api.github.com/graphql", body: { query: query }.to_json, headers: { "Authorization": "bearer #{NetworkProfile.github_api_key}" }) if r.success? JSON.parse(r.body).with_indifferent_access else raise ArgumentError, "Fetching query failed: #{r.code}" end end |