Class: AddEvent::Params

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/add_event/params.rb

Overview

Takes in a hash of parameters and formats them for use with the AddEvent API

Constant Summary collapse

KEYS =

Available parameters. Full docs: addthisevent.com/api/

%i(alarm all_day_event client date_format description end endext endtime location
organizer organizer_email reference service start startext starttime template timezone title).freeze
VALID_SERVICES =
%w(outlook google appleical outlookcom yahoo).freeze
DATE_FORMAT =
'MM/DD/YYYY'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ AddEvent::Params

Parameters:

  • params (Hash)


27
28
29
# File 'lib/add_event/params.rb', line 27

def initialize(params)
  @params = OpenStruct.new(params)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



17
18
19
# File 'lib/add_event/params.rb', line 17

def params
  @params
end

Instance Method Details

#to_hHash

Returns a hash with only valid params for the AddEvent API

Returns:

  • (Hash)


37
38
39
# File 'lib/add_event/params.rb', line 37

def to_h
  KEYS.each_with_object({}) { |key, output| output[key] = send(key) }
end