encode<V> static method

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

Implementation

static V encode<V>(
  Topup instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  if (instance.balanceTransaction != null) {
    BalanceTransactionOrId.encode(
      instance.balanceTransaction!,
      container.nestedSingleValueContainer('balance_transaction').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.expectedAvailabilityDate != null) {
    container.encodeInt(
      'expected_availability_date',
      instance.expectedAvailabilityDate!,
    );
  }
  if (instance.failureCode != null) {
    container.encodeString(
      'failure_code',
      instance.failureCode!,
    );
  }
  if (instance.failureMessage != null) {
    container.encodeString(
      'failure_message',
      instance.failureMessage!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  container.encodeString(
    'object',
    'topup',
  );
  if (instance.source != null) {
    Source.encode(
      instance.source!,
      container.nestedSingleValueContainer('source').encoder,
    );
  }
  if (instance.statementDescriptor != null) {
    container.encodeString(
      'statement_descriptor',
      instance.statementDescriptor!,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  if (instance.transferGroup != null) {
    container.encodeString(
      'transfer_group',
      instance.transferGroup!,
    );
  }
  return container.value;
}