Class: DPay::PayoutInstruction

Inherits:
Object
  • Object
show all
Defined in:
lib/dpay/payment/payout_instruction.rb,
sig/dpay/payment/payout_instruction.rbs

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(positions, fee_mode = PayoutFeeMode::NET) ⇒ PayoutInstruction

Returns a new instance of PayoutInstruction.

Parameters:

  • positions (Array[PayoutPosition])
  • fee_mode (String) (defaults to: PayoutFeeMode::NET)

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dpay/payment/payout_instruction.rb', line 9

def initialize(positions, fee_mode = PayoutFeeMode::NET)
  raise InvalidArgumentError, "Payout instruction requires at least one position" if positions.empty?
  unless positions.all?(PayoutPosition)
    raise InvalidArgumentError, "Positions must be DPay::PayoutPosition instances"
  end

  PayoutFeeMode.assert_valid(fee_mode)

  @positions = positions.dup.freeze
  @fee_mode = fee_mode
  freeze
end

Class Method Details

.create(positions, fee_mode = PayoutFeeMode::NET) ⇒ PayoutInstruction

Parameters:

  • positions (Array[PayoutPosition])
  • fee_mode (String) (defaults to: PayoutFeeMode::NET)

Returns:



5
6
7
# File 'lib/dpay/payment/payout_instruction.rb', line 5

def self.create(positions, fee_mode = PayoutFeeMode::NET)
  new(positions, fee_mode)
end

Instance Method Details

#to_hHash[String, untyped]

Returns:

  • (Hash[String, untyped])


22
23
24
# File 'lib/dpay/payment/payout_instruction.rb', line 22

def to_h
  { "fee_mode" => @fee_mode, "positions" => @positions.map(&:to_h) }
end