Sha256: 33558d9503e728447f2314bbb123501c5fba6932f993a375e4c73243a0936582

Contents?: true

Size: 564 Bytes

Versions: 1

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

module LightspeedRestaurantClient
  module Operations
    module List
      def list(params = {}, configuration = nil)
        response = JSON.parse(LightspeedRestaurantClient.get(resource_path, params, configuration))
        results = response.is_a?(Array) ? response : response['results']
        instantiate(results)
      end
      alias all list

      private

      def instantiate(records)
        records.map do |record|
          is_a?(Class) ? new(record) : self.class.new(record)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lightspeed_restaurant-3.0.0 lib/lightspeed_restaurant/operations/list.rb