update method

Future<ParseResponse> update()

Send the updated object to the server.

Will only send the dirty (modified) data and not the entire object

The object should hold an objectId in order to update it

Prefer using save over update

Implementation

Future<ParseResponse> update() async {
  assert(
    objectId != null && (objectId?.isNotEmpty ?? false),
    "Can't update a parse object while the objectId property is null or empty",
  );

  try {
    final Uri url = getSanitisedUri(_client, '$_path/$objectId');
    final String body = json.encode(toJson(forApiRQ: true));

    _saveChanges();

    final Map<String, String> headers = {
      keyHeaderContentType: keyHeaderContentTypeJson
    };

    final ParseNetworkResponse result = await _client.put(url.toString(),
        data: body, options: ParseNetworkOptions(headers: headers));

    final response = handleResponse<ParseObject>(
        this, result, ParseApiRQ.save, _debug, parseClassName);

    if (!response.success) {
      _notifyChildrenAboutErrorSaving();
    }

    return response;
  } on Exception catch (e) {
    _notifyChildrenAboutErrorSaving();
    return handleException(e, ParseApiRQ.save, _debug, parseClassName);
  }
}