module LightspeedRestaurantClient::Operations::List

Public Instance Methods

all(params = {}, configuration = nil)
Alias for: list
list(params = {}, configuration = nil) click to toggle source
# File lib/lightspeed_restaurant/operations/list.rb, line 6
def list(params = {}, configuration = nil)
  response = JSON.parse(LightspeedRestaurantClient.get(resource_path, params, configuration))
  response = handle_list_response(response)
  instantiate(response)
end
Also aliased as: all

Private Instance Methods

handle_list_response(response) click to toggle source
# File lib/lightspeed_restaurant/operations/list.rb, line 19
def handle_list_response(response)
  case response
  when Hash
    response['results']
  else
    response
  end
end
instantiate(records) click to toggle source
# File lib/lightspeed_restaurant/operations/list.rb, line 28
def instantiate(records)
  records.map do |record|
    is_a?(Class) ? new(record) : self.class.new(record)
  end
end
resource_path() click to toggle source
# File lib/lightspeed_restaurant/operations/list.rb, line 15
def resource_path
  respond_to?(:list_resource_path) ? list_resource_path : default_resource_path
end