Last active
December 12, 2015 03:58
-
-
Save bwiggs/4710598 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Event | |
attr_reader :uid, :event_date, :sports | |
def initialize(args) | |
args.keys.each do |name| | |
instance_variable_set "@" + name.to_s, args[name] | |
end | |
end | |
end |
This file contains hidden or 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 EventClient | |
# ... | |
def self.get_event(event_id) | |
response = Faraday.get("#{@base_url}/sports/v2/events/#{event_id}") | |
return nil unless response.status == 200 | |
json = JSON.parse response.body | |
Event.new({ | |
uid: json["uid"], | |
event_date: DateTime.parse(json["eventDate"]) | |
}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment