Class: SpreeCmCommissioner::TicketTransfers::Initiate
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::TicketTransfers::Initiate
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/ticket_transfers/initiate.rb
Instance Method Summary collapse
-
#call(from_user_id:, to_user_id:, from_guest_id:, currency:, transfer_type:, price: 0, expires_at: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Instance Method Details
#call(from_user_id:, to_user_id:, from_guest_id:, currency:, transfer_type:, price: 0, expires_at: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/spree_cm_commissioner/ticket_transfers/initiate.rb', line 6 def call(from_user_id:, to_user_id:, from_guest_id:, currency:, transfer_type:, price: 0, expires_at: nil) # rubocop:disable Metrics/ParameterLists validate_transfer_params!(from_user_id, to_user_id, from_guest_id, currency, price.to_d, transfer_type) from_guest = SpreeCmCommissioner::Guest.find(from_guest_id) fee = compute_fee(from_guest, price, currency, transfer_type) return failure(nil, fee[:error]) if fee[:error] ticket_transfer = create_transfer!( from_user_id: from_user_id, to_user_id: to_user_id, from_guest: from_guest, fee: fee, currency: currency, expires_at: expires_at, transfer_type: transfer_type ) success(ticket_transfer: ticket_transfer) rescue StandardError => e handle_failure(e) end |