encode<V> static method

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

Implementation

static V encode<V>(
  BalanceTransaction instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  container.encodeDateTime(
    'available_on',
    instance.availableOn,
  );
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.exchangeRate != null) {
    container.encodeDouble(
      'exchange_rate',
      instance.exchangeRate!,
    );
  }
  container.encodeInt(
    'fee',
    instance.fee,
  );
  container.encodeList(
    'fee_details',
    (container) => instance.feeDetails.forEach((el) => Fee.encode(
          el,
          container.nestedSingleValueContainer().encoder,
        )),
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeInt(
    'net',
    instance.net,
  );
  container.encodeString(
    'object',
    'balance_transaction',
  );
  container.encodeString(
    'reporting_category',
    instance.reportingCategory,
  );
  if (instance.source != null) {
    BalanceTransactionSourceOrId.encode(
      instance.source!,
      container.nestedSingleValueContainer('source').encoder,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  container.encodeString(
    'type',
    instance.type,
  );
  return container.value;
}