DVPayoutSplit constructor

DVPayoutSplit({
  1. required Map<String, int> recipients,
  2. int platformFeeBasisPoints = 0,
  3. DVMoney? platformFixedFee,
})

Implementation

DVPayoutSplit({
  required Map<String, int> recipients,
  this.platformFeeBasisPoints = 0,
  this.platformFixedFee,
}) : recipients = Map<String, int>.unmodifiable(recipients) {
  if (recipients.isEmpty) {
    throw ArgumentError.value(recipients, 'recipients', 'names nobody');
  }
  for (final MapEntry<String, int> r in recipients.entries) {
    if (r.key == DVPayouts.platform || r.key.isEmpty) {
      throw ArgumentError.value(r.key, 'recipients',
          'is not a connected account id; the platform takes its fee');
    }
    if (r.value < 1) {
      throw ArgumentError.value(r.value, 'recipients',
          'weight of ${r.key} is not positive; leave the recipient out');
    }
  }
  if (platformFeeBasisPoints < 0 || platformFeeBasisPoints > 10000) {
    throw ArgumentError.value(platformFeeBasisPoints,
        'platformFeeBasisPoints', 'is between 0 and 10000');
  }
}