Class: EcalClient::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/ecal_client/api.rb

Defined Under Namespace

Classes: Base, Rest

Constant Summary collapse

API_VERSION =
"/apiv2".freeze
ORGANISATION =
"/organisation/".freeze
PUBLISHER =
"/publisher/".freeze
CALENDAR =
"/calendar/".freeze
EVENT =
"/event/".freeze
SUBSCRIPTION_WIDGET =
"/subscription-widget/".freeze
SUBSCRIBER =
"/subscriber/".freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Api

Returns a new instance of Api.



12
13
14
15
16
# File 'lib/ecal_client/api.rb', line 12

def initialize(options = {})
  @key = options.delete(:key) || EcalClient.configuration.key
  @secret = options.delete(:secret) || EcalClient.configuration.secret
  EcalClient.configuration.options.merge!(options)
end

Instance Method Details

#calendarObject



30
31
32
# File 'lib/ecal_client/api.rb', line 30

def calendar
  @calendar ||= Rest.new(endpoint_for(CALENDAR), [:get, :post, :put], credentials)
end

#credentialsObject



18
19
20
# File 'lib/ecal_client/api.rb', line 18

def credentials
  { key: @key, secret: @secret }
end

#eventObject



34
35
36
# File 'lib/ecal_client/api.rb', line 34

def event
  @event ||= Rest.new(endpoint_for(EVENT), [:get, :post, :put], credentials)
end

#organisationObject



22
23
24
# File 'lib/ecal_client/api.rb', line 22

def organisation
  @organisation ||= Rest.new(endpoint_for(ORGANISATION), [:get, :post, :put], credentials)
end

#publisherObject



26
27
28
# File 'lib/ecal_client/api.rb', line 26

def publisher
  @publisher ||= Rest.new(endpoint_for(PUBLISHER), [:get, :put], credentials)
end

#subscriberObject



42
43
44
# File 'lib/ecal_client/api.rb', line 42

def subscriber
  @subscriber ||= Rest.new(endpoint_for(SUBSCRIBER), [:get, :post, :put], credentials)
end

#subscription_widgetObject



38
39
40
# File 'lib/ecal_client/api.rb', line 38

def subscription_widget
  @subscription_widget ||= Rest.new(endpoint_for(SUBSCRIPTION_WIDGET), [:get], credentials)
end