Class: Calagator::Source::Parser::Facebook
- Inherits:
-
Calagator::Source::Parser
- Object
- Struct
- Calagator::Source::Parser
- Calagator::Source::Parser::Facebook
- Defined in:
- app/models/calagator/source/parser/facebook.rb
Instance Attribute Summary
Attributes inherited from Calagator::Source::Parser
Instance Method Summary collapse
Methods inherited from Calagator::Source::Parser
<=>, inherited, labels, read_url, to_events
Instance Method Details
#to_events ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/calagator/source/parser/facebook.rb', line 26 def to_events return unless data = to_events_api_helper(url) do |event_id| raise Calagator::Source::Parser::HttpAuthenticationRequiredError unless Calagator.facebook_access_token.present? [ "https://graph.facebook.com/#{event_id}", { access_token: Calagator.facebook_access_token } ] end raise Calagator::Source::Parser::HttpAuthenticationRequiredError if data['parsed_response'] === false event = Event.new({ source: source, title: data['name'], description: data['description'], url: url, tag_list: "facebook:event=#{data['id']}", venue: to_venue(data), # Facebook is sending floating times, treat them as local start_time: Time.zone.parse(data['start_time']), end_time: Time.zone.parse(data['end_time']), }) [event_or_duplicate(event)] end |