Class: EcalClient::Api::Rest

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

Defined Under Namespace

Classes: Unsupported

Constant Summary

Constants inherited from Base

Base::API_ENDPOINT

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, actions, options = {}) ⇒ Rest

Returns a new instance of Rest.



6
7
8
9
10
11
12
# File 'lib/ecal_client/api/rest.rb', line 6

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

Instance Method Details

#get(options = {}) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
# File 'lib/ecal_client/api/rest.rb', line 14

def get(options = {})
  raise Unsupported unless supported?(:get)
  id = options.delete(:id)
  endpoint = @endpoint
  endpoint += id.to_s if id
  response = get_call(endpoint, options, nil, headers)
  Response.new(response)
end

#post(options) ⇒ Object

Raises:



23
24
25
26
27
# File 'lib/ecal_client/api/rest.rb', line 23

def post(options)
  raise Unsupported unless supported?(:post)
  response = post_call(@endpoint, {}, options, headers)
  Response.new(response)
end

#put(options) ⇒ Object

Raises:



29
30
31
32
33
34
35
36
# File 'lib/ecal_client/api/rest.rb', line 29

def put(options)
  raise Unsupported unless supported?(:put)
  id = options.delete(:id)
  endpoint = @endpoint
  endpoint += id.to_s if id
  response = put_call(endpoint, {}, options, headers)
  Response.new(response)
end