encode<V> static method

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

Implementation

static V encode<V>(
  TerminalReaderAction instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.failureCode != null) {
    container.encodeString(
      'failure_code',
      instance.failureCode!,
    );
  }
  if (instance.failureMessage != null) {
    container.encodeString(
      'failure_message',
      instance.failureMessage!,
    );
  }
  if (instance.processPaymentIntent != null) {
    TerminalReaderReaderResourceProcessPaymentIntentAction.encode(
      instance.processPaymentIntent!,
      container.nestedSingleValueContainer('process_payment_intent').encoder,
    );
  }
  if (instance.processSetupIntent != null) {
    TerminalReaderReaderResourceProcessSetupIntentAction.encode(
      instance.processSetupIntent!,
      container.nestedSingleValueContainer('process_setup_intent').encoder,
    );
  }
  if (instance.refundPayment != null) {
    TerminalReaderReaderResourceRefundPaymentAction.encode(
      instance.refundPayment!,
      container.nestedSingleValueContainer('refund_payment').encoder,
    );
  }
  if (instance.setReaderDisplay != null) {
    TerminalReaderReaderResourceSetReaderDisplayAction.encode(
      instance.setReaderDisplay!,
      container.nestedSingleValueContainer('set_reader_display').encoder,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  container.encodeString(
    'type',
    instance.type,
  );
  return container.value;
}