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) ⇒ Rest



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

def initialize(endpoint, actions)
  @endpoint = endpoint
  @actions = actions
end

Instance Method Details

#get(options = {}) ⇒ Object

Raises:



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

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:



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

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

#put(options) ⇒ Object

Raises:



26
27
28
29
30
31
32
33
# File 'lib/ecal_client/api/rest.rb', line 26

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