-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from geeksforsocialchange/master
Merge Eventbrite support
- Loading branch information
Showing
10 changed files
with
2,079 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
# frozen_string_literal: true | |||
|
|||
module Events | |||
class EventbriteEvent < Base | |||
def initialize(event) | |||
@event = event | |||
end | |||
|
|||
def uid | |||
@event['id'] | |||
end | |||
|
|||
def summary | |||
@event['name']['text'] | |||
end | |||
|
|||
def description | |||
@event['description']['text'] | |||
end | |||
|
|||
def place | |||
@place ||= @event['venue'] | |||
end | |||
|
|||
def location | |||
return if place.blank? | |||
address = place['address'] | |||
|
|||
if address.present? | |||
[ place['name'], | |||
address['address_1'], | |||
address['address_2'], | |||
address['city'], | |||
address['region'], | |||
address['postal_code'] | |||
].reject(&:blank?).join(', ') | |||
else | |||
place['name'] | |||
end | |||
end | |||
|
|||
def dtstart | |||
DateTime.parse(@event['start']['local']) | |||
rescue StandardError | |||
nil | |||
end | |||
|
|||
def dtend | |||
DateTime.parse(@event['end']['local']) | |||
rescue StandardError | |||
nil | |||
end | |||
|
|||
def occurrences_between(*) | |||
#TODO: Expand when multi-day events supported | |||
@occurrences = [] | |||
@occurrences << Dates.new(dtstart, dtend) | |||
@occurrences | |||
end | |||
|
|||
end | |||
end |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
# frozen_string_literal: true | |||
|
|||
# In order for a parser to be recognized, it must be added | |||
# to the PARSERS constant list in app/models/calendar_parser.rb. | |||
# Parent parser classes should not be added. | |||
|
|||
module Parsers | |||
class Eventbrite < Base | |||
def self.whitelist_pattern | |||
/https:\/\/www.eventbrite\.(com|co.uk)\/o\/[A-Za-z0-9-]+/ | |||
end | |||
|
|||
def organizer_id | |||
path = URI.parse(@url).path | |||
path.split('/').last.split('-').last | |||
end | |||
|
|||
def download_calendar | |||
EventbriteSDK.token = ENV['EVENTBRITE_TOKEN'] | |||
|
|||
@events = [] | |||
results = EventbriteSDK::Organizer.retrieve(id: organizer_id).events.with_expansion(:venue).page(1) | |||
|
|||
loop do | |||
@events += results | |||
results = results.next_page | |||
break if results.blank? | |||
end | |||
|
|||
@events | |||
end | |||
|
|||
def import_events_from(data) | |||
data.map { |d| Events::EventbriteEvent.new(d) } | |||
end | |||
end | |||
end |
This file contains 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
This file contains 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
1,938 changes: 1,938 additions & 0 deletions
1,938
test/fixtures/vcr_cassettes/Eventbrite_calendar.yml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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