encode<V> static method

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

Implementation

static V encode<V>(
  Balance instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeList(
    'available',
    (container) => instance.available.forEach((el) => BalanceAmount.encode(
          el,
          container.nestedSingleValueContainer().encoder,
        )),
  );
  if (instance.connectReserved != null) {
    container.encodeList(
      'connect_reserved',
      (container) =>
          instance.connectReserved!.forEach((el) => BalanceAmount.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.instantAvailable != null) {
    container.encodeList(
      'instant_available',
      (container) =>
          instance.instantAvailable!.forEach((el) => BalanceAmountNet.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.issuing != null) {
    BalanceDetail.encode(
      instance.issuing!,
      container.nestedSingleValueContainer('issuing').encoder,
    );
  }
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'object',
    'balance',
  );
  container.encodeList(
    'pending',
    (container) => instance.pending.forEach((el) => BalanceAmount.encode(
          el,
          container.nestedSingleValueContainer().encoder,
        )),
  );
  return container.value;
}