Module: AddEvent

Extended by:
Configuration
Defined in:
lib/add_event.rb,
lib/add_event/url.rb,
lib/add_event/params.rb,
lib/add_event/service.rb,
lib/add_event/version.rb

Overview

Validates and provides a Service value for the AddEvent API

Defined Under Namespace

Classes: Params, Service, Url

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.url(title, starts_at, ends_at, options) ⇒ String

Creates an AddEvent URL

Usage

party_starts = DateTime.new(2016, 10, 2, 18, 0, 0, '+7')
party_ends = DateTime.new(2016, 10, 3, 3, 0, 0, '+7')

event_options = {
  service: :google, # or 'google' works too!
  organizer: 'Mike',
  organizer_email: '[email protected]',
  alert: 15, # set alarm for 15 minutes before the party starts
  description: "A little get together to celebrate DHH's birthday. BYORG (Bring your own ruby gems)",
  location: "Ruby Bar, San Francisco CA"
}

url = AddEvent.url(title: "DHH's Birthday Bash", starts_at: party_starts,
                   ends_at: party_ends, options: event_options)

Time Zones

To keep things simple, this gem converts the starts_at and ends_at to UTC and sends all times to AddEvent as UTC. When the end user adds the event to their calendar, it will automatically be converted to their local timezone.

Parameters:

  • title (String)

    The title of the event (this is what users will see on their calendar)

  • starts_at (DateTime)

    The DateTime of when the event begins.

  • ends_at (DateTime)

    The DateTime of when the event ends.

  • options (Hash)

    Optional parameters for creating the event.

Options Hash (options):

  • :client_id (String)

    The API client id (addthisevent.com/account). Only need to include this if you did not set it using config.

  • :service (Symbol, String)

    Type of service you’d like the event generated for. Available services are :outlook, :google, :appleical, :outlookcom or :yahoo. May be passed as a string ('outlook') or a symbol (:outlook)

  • :alarm (Integer)

    Set a reminder alarm before the event. Integer in # of minutes before the event starts.

  • :organizer (String)

    Event organizer’s name

  • :organizer_email (String)

    Event organizers email

  • :description (String)

    Event description (Max 300 chars recommended)

  • :location (String)

    Location of the Event. Ex: ‘San Francisco, CA’

  • :reference (String)

    Tracking parameter for analytics. Ex: "iPhone" or "Newsletter Oct 2016"

  • :template (String)

    ID of a AddEvent template. Uses the default template if not defined. You can get this ID from the AddEvent dashboard after creating a template.

  • :all_day_event (Boolean) — default: false

    Is it an all day event? True or False

Returns:

  • (String)

    AddEvent Direct URL



81
82
83
84
85
86
# File 'lib/add_event.rb', line 81

def self.url(title:, starts_at:, ends_at:, options: {})
  options = { client_id: client_id || ENV['ADD_EVENT_CLIENT_ID'] }.merge(options)

  Url.new(title: title, starts_at: starts_at, ends_at: ends_at,
          options: options).to_s
end

Instance Method Details

#client_idObject

Set the API client ID. (addevent.com/account)

Usage

# config/initializers/add_event.rb
AddEvent.configuration do |config|
  # Your Client ID (License code) is available here: https://addevent.com/account/
  config.client_id = 'your_id_goes_here'
end


20
# File 'lib/add_event.rb', line 20

define_setting :client_id