class EcalClient::Api::Rest

Public Class Methods

new(endpoint, actions, options = {}) click to toggle source
# File lib/ecal_client/api/rest.rb, line 6
def initialize(endpoint, actions, options = {})
  @endpoint = endpoint
  @actions = actions
  @key = options[:key]
  @secret = options[:secret]
end

Public Instance Methods

get(options = {}) click to toggle source
# File lib/ecal_client/api/rest.rb, line 13
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) click to toggle source
# File lib/ecal_client/api/rest.rb, line 22
def post(options)
  raise Unsupported unless supported?(:post)
  response = post_call(@endpoint, {}, options, headers)
  Response.new(response)
end
put(options) click to toggle source
# File lib/ecal_client/api/rest.rb, line 28
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

Private Instance Methods

supported?(action) click to toggle source
# File lib/ecal_client/api/rest.rb, line 39
def supported?(action)
  @actions.include? action.to_sym
end