encode<V> static method

V encode<V>(
  1. IssuingAuthorization instance,
  2. Encoder<V> encoder
)
override

Implementation

static V encode<V>(
  IssuingAuthorization instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  if (instance.amountDetails != null) {
    IssuingAuthorizationAmountDetails.encode(
      instance.amountDetails!,
      container.nestedSingleValueContainer('amount_details').encoder,
    );
  }
  container.encodeBool(
    'approved',
    instance.approved,
  );
  container.encodeString(
    'authorization_method',
    instance.authorizationMethod,
  );
  container.encodeList(
    'balance_transactions',
    (container) => instance.balanceTransactions
        .forEach((el) => BalanceTransaction.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  IssuingCard.encode(
    instance.card,
    container.nestedSingleValueContainer('card').encoder,
  );
  if (instance.cardholder != null) {
    IssuingCardholderOrId.encode(
      instance.cardholder!,
      container.nestedSingleValueContainer('cardholder').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeInt(
    'merchant_amount',
    instance.merchantAmount,
  );
  container.encodeString(
    'merchant_currency',
    instance.merchantCurrency,
  );
  IssuingAuthorizationMerchantData.encode(
    instance.merchantData,
    container.nestedSingleValueContainer('merchant_data').encoder,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  if (instance.networkData != null) {
    IssuingAuthorizationNetworkData.encode(
      instance.networkData!,
      container.nestedSingleValueContainer('network_data').encoder,
    );
  }
  container.encodeString(
    'object',
    'issuing.authorization',
  );
  if (instance.pendingRequest != null) {
    IssuingAuthorizationPendingRequest.encode(
      instance.pendingRequest!,
      container.nestedSingleValueContainer('pending_request').encoder,
    );
  }
  container.encodeList(
    'request_history',
    (container) => instance.requestHistory
        .forEach((el) => IssuingAuthorizationRequest.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  container.encodeString(
    'status',
    instance.status,
  );
  if (instance.token != null) {
    IssuingTokenOrId.encode(
      instance.token!,
      container.nestedSingleValueContainer('token').encoder,
    );
  }
  container.encodeList(
    'transactions',
    (container) =>
        instance.transactions.forEach((el) => IssuingTransaction.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  if (instance.treasury != null) {
    IssuingAuthorizationTreasury.encode(
      instance.treasury!,
      container.nestedSingleValueContainer('treasury').encoder,
    );
  }
  IssuingAuthorizationVerificationData.encode(
    instance.verificationData,
    container.nestedSingleValueContainer('verification_data').encoder,
  );
  if (instance.wallet != null) {
    container.encodeString(
      'wallet',
      instance.wallet!,
    );
  }
  return container.value;
}