toForm method

List<MBMultipartForm>? toForm()

Converts this object to a list of multipart forms

Implementation

List<MBMultipartForm>? toForm() {
  List<MBMultipartForm> forms = [];
  switch (visibility) {
    case MBAdminVisibility.visible:
      forms.add(MBMultipartForm.name('visibility', 'visible'));
      break;
    case MBAdminVisibility.draft:
      forms.add(MBMultipartForm.name('visibility', 'draft'));
      break;
    case MBAdminVisibility.scheduled:
      forms.add(MBMultipartForm.name('visibility', 'scheduled'));
      if (availableAt != null) {
        forms.add(
          MBMultipartForm.name(
            'available_at',
            (availableAt!.millisecondsSinceEpoch ~/ 1000).toString(),
          ),
        );
      }
      break;
  }
  return forms;
}