1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00
fab-manager/app/services/cart/create_service.rb
2022-08-19 20:03:09 +02:00

20 lines
450 B
Ruby

# frozen_string_literal: true
# Provides methods for create cart
class Cart::CreateService
def call(user)
token = GenerateTokenService.new.call(Order)
order_param = {
token: token,
state: 'cart',
amount: 0
}
if user
order_param[:statistic_profile_id] = user.statistic_profile.id if user.member?
order_param[:operator_id] = user.id if user.privileged?
end
Order.create!(order_param)
end
end