encode<V> static method

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

Implementation

static V encode<V>(
  File instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.expiresAt != null) {
    container.encodeDateTime(
      'expires_at',
      instance.expiresAt!,
    );
  }
  if (instance.filename != null) {
    container.encodeString(
      'filename',
      instance.filename!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.links != null) {
    FileLinks.encode(
      instance.links!,
      container.nestedSingleValueContainer('links').encoder,
    );
  }
  container.encodeString(
    'object',
    'file',
  );
  container.encodeString(
    'purpose',
    instance.purpose,
  );
  container.encodeInt(
    'size',
    instance.size,
  );
  if (instance.title != null) {
    container.encodeString(
      'title',
      instance.title!,
    );
  }
  if (instance.type != null) {
    container.encodeString(
      'type',
      instance.type!,
    );
  }
  if (instance.url != null) {
    container.encodeString(
      'url',
      instance.url!,
    );
  }
  return container.value;
}