Class: DPay::PayoutInstruction
- Inherits:
-
Object
- Object
- DPay::PayoutInstruction
- Defined in:
- lib/dpay/payment/payout_instruction.rb,
sig/dpay/payment/payout_instruction.rbs
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(positions, fee_mode = PayoutFeeMode::NET) ⇒ PayoutInstruction
constructor
A new instance of PayoutInstruction.
- #to_h ⇒ Hash[String, untyped]
Constructor Details
#initialize(positions, fee_mode = PayoutFeeMode::NET) ⇒ PayoutInstruction
Returns a new instance of PayoutInstruction.
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
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_h ⇒ 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 |