encode<V> static method

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

Implementation

static V encode<V>(
  PaymentLinksResourcePaymentIntentData instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.captureMethod != null) {
    PaymentLinkPaymentIntentDataCaptureMethod.encode(
      instance.captureMethod!,
      container.nestedSingleValueContainer('capture_method').encoder,
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  if (instance.setupFutureUsage != null) {
    ConfirmationTokenSetupFutureUsage.encode(
      instance.setupFutureUsage!,
      container.nestedSingleValueContainer('setup_future_usage').encoder,
    );
  }
  if (instance.statementDescriptor != null) {
    container.encodeString(
      'statement_descriptor',
      instance.statementDescriptor!,
    );
  }
  if (instance.statementDescriptorSuffix != null) {
    container.encodeString(
      'statement_descriptor_suffix',
      instance.statementDescriptorSuffix!,
    );
  }
  if (instance.transferGroup != null) {
    container.encodeString(
      'transfer_group',
      instance.transferGroup!,
    );
  }
  return container.value;
}