encode<V> static method

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

Implementation

static V encode<V>(
  BankConnectionsResourceBalance instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeDateTime(
    'as_of',
    instance.asOf,
  );
  if (instance.cash != null) {
    BankConnectionsResourceBalanceApiResourceCashBalance.encode(
      instance.cash!,
      container.nestedSingleValueContainer('cash').encoder,
    );
  }
  if (instance.credit != null) {
    BankConnectionsResourceBalanceApiResourceCreditBalance.encode(
      instance.credit!,
      container.nestedSingleValueContainer('credit').encoder,
    );
  }
  container.encodeMap(
    'current',
    (container) => instance.current.forEach((
      key,
      value,
    ) =>
        container.encodeInt(
          key,
          value,
        )),
  );
  container.encodeString(
    'type',
    instance.type,
  );
  return container.value;
}