encode<V> static method

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

Implementation

static V encode<V>(
  TerminalReader instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.action != null) {
    TerminalReaderAction.encode(
      instance.action!,
      container.nestedSingleValueContainer('action').encoder,
    );
  }
  if (instance.deviceSwVersion != null) {
    container.encodeString(
      'device_sw_version',
      instance.deviceSwVersion!,
    );
  }
  container.encodeString(
    'device_type',
    instance.deviceType,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.ipAddress != null) {
    container.encodeString(
      'ip_address',
      instance.ipAddress!,
    );
  }
  container.encodeString(
    'label',
    instance.label,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  if (instance.location != null) {
    TerminalLocationOrId.encode(
      instance.location!,
      container.nestedSingleValueContainer('location').encoder,
    );
  }
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  container.encodeString(
    'object',
    'terminal.reader',
  );
  container.encodeString(
    'serial_number',
    instance.serialNumber,
  );
  if (instance.status != null) {
    container.encodeString(
      'status',
      instance.status!,
    );
  }
  return container.value;
}