encode<V> static method

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

Implementation

static V encode<V>(
  IssuingTransaction 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,
    );
  }
  if (instance.authorization != null) {
    IssuingAuthorizationOrId.encode(
      instance.authorization!,
      container.nestedSingleValueContainer('authorization').encoder,
    );
  }
  if (instance.balanceTransaction != null) {
    BalanceTransactionOrId.encode(
      instance.balanceTransaction!,
      container.nestedSingleValueContainer('balance_transaction').encoder,
    );
  }
  IssuingCardOrId.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,
  );
  if (instance.dispute != null) {
    IssuingDisputeOrId.encode(
      instance.dispute!,
      container.nestedSingleValueContainer('dispute').encoder,
    );
  }
  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) {
    IssuingTransactionNetworkData.encode(
      instance.networkData!,
      container.nestedSingleValueContainer('network_data').encoder,
    );
  }
  container.encodeString(
    'object',
    'issuing.transaction',
  );
  if (instance.purchaseDetails != null) {
    IssuingTransactionPurchaseDetails.encode(
      instance.purchaseDetails!,
      container.nestedSingleValueContainer('purchase_details').encoder,
    );
  }
  if (instance.token != null) {
    IssuingTokenOrId.encode(
      instance.token!,
      container.nestedSingleValueContainer('token').encoder,
    );
  }
  if (instance.treasury != null) {
    IssuingTransactionTreasury.encode(
      instance.treasury!,
      container.nestedSingleValueContainer('treasury').encoder,
    );
  }
  container.encodeString(
    'type',
    instance.type,
  );
  if (instance.wallet != null) {
    container.encodeString(
      'wallet',
      instance.wallet!,
    );
  }
  return container.value;
}