Sha256: 507bfb8ba77b8cbe155e10500618f228fa7cb333a30c21feed8825691d6cd551

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module LightspeedRestaurantClient
  module Operations
    module Create
      def create(attributes, configuration = nil)
        response = JSON.parse(LightspeedRestaurantClient.post(default_resource_path, attributes, {}, configuration))
        response = handle_create_response(response, attributes)
        return new(response) if is_a?(Class)

        self.class.new(response)
      end

      private

      def handle_create_response(response, attributes)
        case response
        when Numeric
          attributes.merge(id: response)
        else
          response
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lightspeed_restaurant-3.3.3 lib/lightspeed_restaurant/operations/create.rb
lightspeed_restaurant-3.3.2 lib/lightspeed_restaurant/operations/create.rb