toJson method

Map<String, dynamic> toJson()

Returns a JSON map for the request body.

Implementation

Map<String, dynamic> toJson() {
  final map = <String, dynamic>{};

  if (status != null) {
    map['status'] = status;
  }
  if (spoilerText != null) {
    map['spoiler_text'] = spoilerText;
  }
  if (sensitive != null) {
    map['sensitive'] = sensitive;
  }
  if (language != null) {
    map['language'] = language;
  }
  if (mediaIds != null) {
    map['media_ids'] = mediaIds;
  }
  if (mediaAttributes != null) {
    map['media_attributes'] = mediaAttributes!
        .map(
          (a) => <String, dynamic>{
            'id': a.id,
            if (a.description != null) 'description': a.description,
            if (a.focus != null) 'focus': a.focus,
          },
        )
        .toList();
  }
  if (poll != null) {
    map['poll'] = <String, dynamic>{
      'options': poll!.options,
      'expires_in': poll!.expiresIn,
      'multiple': poll!.multiple,
      'hide_totals': poll!.hideTotals,
    };
  }
  if (quoteApprovalPolicy != null) {
    map['quote_approval_policy'] = quoteApprovalPolicy;
  }

  return map;
}