Skip to content

Instantly share code, notes, and snippets.

@kinsomicrote
Created February 21, 2017 11:39
Show Gist options
  • Save kinsomicrote/932beb03fcbd221189e1130dd8c9a5b5 to your computer and use it in GitHub Desktop.
Save kinsomicrote/932beb03fcbd221189e1130dd8c9a5b5 to your computer and use it in GitHub Desktop.
require 'faraday'
require 'json'
require 'pry'
class ReceivedEvent
def initialize(username)
@username = username
end
def github_url
"https://api.github.com/users/#{@username}/received_events"
end
def fetch_messages
data = get_api_data
issue_event_data = grab_issue_event(data)
payload_data = collect_payloads(issue_event_data)
issue_history = collect_issue_history(payload_data)
#grab_issue_history(issue_history)
binding.pry
end
private
def grab_issue_history(data)
end
def collect_issue_history(data)
data.collect do |payload|
payload['issue']
end
end
def collect_payloads(data)
data.collect do |issue_comment_event|
issue_comment_event['payload']
end
end
def grab_issue_event(data)
data.select do |event|
event['type'] == "IssueCommentEvent"
end
end
def get_api_data
response = Faraday.get(github_url)
JSON.parse(response.body)
end
end
u = ReceivedEvent.new("iMacTia")
puts u.fetch_messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment