FerrisBueller
FerrisBueller is a gem for creating events.
Installation
Add this line to your application's Gemfile:
gem 'ferris_bueller'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ferris_bueller
Usage
Creating an event:
client = FerrisBueller::Client.new(url: 'your-event-service.com', token: '1337807')
client.create_event(
title: 'Jonan on Ice',
venue: {
name: 'Rose Garden',
locality: 'Portland',
region: 'Oregon'
},
shows: [
{ date: '2015-03-01 19:00:00 -0700',
date_description: 'First Sunday of March',
time_description: "Seven o'clock at night" },
{ date: '2015-03-08 19:00:00 -0700',
date_description: 'Second Sunday of March',
time_description: "Seven o'clock at night" },
{ date: '2015-03-15 19:00:00 -0700',
date_description: 'Third Sunday of March',
time_description: "Seven o'clock at night" },
{ date: '2015-03-22 19:00:00 -0700',
date_description: 'Third Sunday of March',
time_description: "Seven o'clock at night" },
{ date: '2015-03-29 19:00:00 -0700',
date_description: 'Third Sunday of March',
time_description: "Seven o'clock at night" },
],
source: "unique_name_for_your_event_source",
source_listing: {
title: 'Jonan on Ice',
where: 'The Rose Garden in Portland Oregon',
when: 'Every Sunday night in March at 7'
}
)
The source_listing attribute is used to prevent insertion of duplicates and to maintain a canonical record of imported events. It should include all of the data you extracted from your source that consistently identifies this event.
Do not include timestamps or other data from your source that is likely to change for the same event.
If two events have identical source listings only the first one will be inserted.
Response
FerrisBueller::Event.create will return a hash with the id of the event whether or not it was created by your call. It will also return a boolean value to indicate whether or not the data you submitted created that event.
FerrisBueller::Event.create(...)
#=> { id: 7, created: false }