update method

Future<Tweet> update({
  1. required String status,
  2. String? inReplyToStatusId,
  3. bool? autoPopulateReplyMetadata,
  4. List<String>? excludeReplyUserId,
  5. String? attachmentUrl,
  6. List<String>? mediaIds,
  7. bool? possiblySensitive,
  8. double? lat,
  9. double? long,
  10. String? placeId,
  11. bool? displayCoordinates,
  12. bool? trimUser,
  13. bool? enableDmcommands,
  14. bool? failDmcommands,
  15. String? cardUri,
  16. bool? includeExtEditControl,
  17. String tweetMode = 'extended',
  18. TransformResponse<Tweet> transform = defaultTweetTransform,
})

Updates the authenticating user's current status, also known as Tweeting.

For each update attempt, the update text is compared with the authenticating user's recent Tweets. Any attempt that would result in duplication will be blocked, resulting in a 403 error. A user cannot submit the same status twice in a row.

inReplyToStatusId: The ID of an existing status that the update is in reply to. Note: This parameter will be ignored unless the author of the Tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced Tweet, within the update.

autoPopulateReplyMetadata: If set to true and used with inReplyToStatusId, leading @mentions will be looked up from the original Tweet, and added to the new Tweet from there. This wil append @mentions into the metadata of an extended Tweet as a reply chain grows, until the limit on @mentions is reached. In cases where the original Tweet has been deleted, the reply will fail.

excludeReplyUserId: When used with autoPopulateReplyMetadata, a comma-separated list of user ids which will be removed from the server-generated @mentions prefix on an extended Tweet. Note that the leading @mention cannot be removed as it would break the inReplyToStatusId semantics. Attempting to remove it will be silently ignored.

attachmentUrl: In order for a URL to not be counted in the status body of an extended Tweet, provide a URL as a Tweet attachment. This URL must be a Tweet permalink, or Direct Message deep link. Arbitrary, non-Twitter URLs must remain in the status text. URLs passed to the attachmentUrl parameter not matching either a Tweet permalink or Direct Message deep link will fail at Tweet creation and cause an exception.

mediaIds: A comma-delimited list of mediaIds to associate with the Tweet. You may include up to 4 photos or 1 animated GIF or 1 video in a Tweet. See Uploading Media for further details on uploading media.

possiblySensitive: If you upload Tweet media that might be considered sensitive content such as nudity, or medical procedures, you must set this value to true.

lat: The latitude of the location this Tweet refers to. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there is no corresponding long parameter.

long: The longitude of the location this Tweet refers to. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there no corresponding lat parameter. (geo_enabled has to be enabled for the user.)

placeId: A Place in the world.

displayCoordinates: Whether or not to put a pin on the exact coordinates a Tweet has been sent from.

trimUser: When set to true, the response will include a user object including only the author's ID.

enableDmcommands: When set to true, enables shortcode commands for sending Direct Messages as part of the status text to send a Direct Message to a user. When set to false, disables this behavior and includes any leading characters in the status text that is posted.

failDmcommands: When set to true, causes any status text that starts with shortcode commands to return an API error. When set to false, allows shortcode commands to be sent in the status text and acted on by the API.

cardUri: Associate an ads card with the Tweet using the cardUri value from any ads card response.

tweetMode: When set to extended, uses the extended Tweets. See https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/intro-to-tweet-json#extendedtweet.

transform: Can be used to parse the request. By default, the response is parsed in an isolate.

includeExtEditControl: The includeExtEditControl node will not be included when set to false. See https://developer.twitter.com/en/docs/twitter-api/v1/edit-tweets

See https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update.

Implementation

Future<Tweet> update({
  required String status,
  String? inReplyToStatusId,
  bool? autoPopulateReplyMetadata,
  List<String>? excludeReplyUserId,
  String? attachmentUrl,
  List<String>? mediaIds,
  bool? possiblySensitive,
  double? lat,
  double? long,
  String? placeId,
  bool? displayCoordinates,
  bool? trimUser,
  bool? enableDmcommands,
  bool? failDmcommands,
  String? cardUri,
  bool? includeExtEditControl,
  String tweetMode = 'extended',
  TransformResponse<Tweet> transform = defaultTweetTransform,
}) {
  final body = <String, String>{}
    ..addParameter('tweet_mode', tweetMode)
    ..addParameter('status', status)
    ..addParameter('in_reply_to_status_id', inReplyToStatusId)
    ..addParameter('auto_populate_reply_metadata', autoPopulateReplyMetadata)
    ..addParameter('exclude_reply_user_ids', excludeReplyUserId)
    ..addParameter('attachment_url', attachmentUrl)
    ..addParameter('media_ids', mediaIds)
    ..addParameter('possibly_sensitive', possiblySensitive)
    ..addParameter('lat', lat)
    ..addParameter('long', long)
    ..addParameter('place_id', placeId)
    ..addParameter('display_coordinates', displayCoordinates)
    ..addParameter('trim_user', trimUser)
    ..addParameter('enable_dmcommands', enableDmcommands)
    ..addParameter('fail_dmcommands', failDmcommands)
    ..addParameter('card_uri', cardUri)
    ..addParameter('include_ext_edit_control', includeExtEditControl);

  return client
      .post(
        Uri.https('api.twitter.com', '1.1/statuses/update.json'),
        body: body,
      )
      .then(transform);
}