From 38c528dc993203282a257dff0925dce894e0f925 Mon Sep 17 00:00:00 2001 From: myConsciousness Date: Thu, 24 Nov 2022 11:02:17 +0900 Subject: [PATCH] fix: fixed for the issue (#569) --- CHANGELOG.md | 6 +- README.md | 113 ++++++++++++--- example/example.dart | 6 + lib/src/service/common/includes.dart | 1 + lib/src/service/common/includes.freezed.dart | 3 +- lib/src/service/common/includes.g.dart | 26 ++-- lib/src/service/common/mention.dart | 1 + lib/src/service/common/mention.freezed.dart | 3 +- lib/src/service/common/mention.g.dart | 22 ++- lib/src/service/common/url.dart | 1 + lib/src/service/common/url.freezed.dart | 3 +- lib/src/service/common/url.g.dart | 28 ++-- lib/src/service/dms/dm_event_data.dart | 1 + .../service/dms/dm_event_data.freezed.dart | 3 +- lib/src/service/dms/dm_event_data.g.dart | 33 +++-- lib/src/service/dms/dm_event_meta.dart | 1 + .../service/dms/dm_event_meta.freezed.dart | 3 +- lib/src/service/dms/dm_event_meta.g.dart | 21 ++- lib/src/service/lists/list_data.dart | 1 + lib/src/service/lists/list_data.freezed.dart | 3 +- lib/src/service/lists/list_data.g.dart | 31 ++-- lib/src/service/lists/list_meta.dart | 1 + lib/src/service/lists/list_meta.freezed.dart | 3 +- lib/src/service/lists/list_meta.g.dart | 20 ++- lib/src/service/media/media_data.dart | 1 + lib/src/service/media/media_data.freezed.dart | 3 +- lib/src/service/media/media_data.g.dart | 41 ++++-- .../service/media/uploaded_media_data.dart | 1 + .../media/uploaded_media_data.freezed.dart | 3 +- .../service/media/uploaded_media_data.g.dart | 21 ++- lib/src/service/media/variant.dart | 1 + lib/src/service/media/variant.freezed.dart | 3 +- lib/src/service/media/variant.g.dart | 20 ++- lib/src/service/places/place_data.dart | 1 + .../service/places/place_data.freezed.dart | 3 +- lib/src/service/places/place_data.g.dart | 31 ++-- lib/src/service/polls/poll_data.dart | 1 + lib/src/service/polls/poll_data.freezed.dart | 3 +- lib/src/service/polls/poll_data.g.dart | 26 +++- .../service/response/twitter_response.dart | 29 +++- lib/src/service/spaces/space_data.dart | 1 + .../service/spaces/space_data.freezed.dart | 3 +- lib/src/service/spaces/space_data.g.dart | 49 ++++--- lib/src/service/spaces/space_meta.dart | 1 + .../service/spaces/space_meta.freezed.dart | 3 +- lib/src/service/spaces/space_meta.g.dart | 16 +- .../service/tweets/filtering_rule_data.dart | 1 + .../tweets/filtering_rule_data.freezed.dart | 3 +- .../service/tweets/filtering_rule_data.g.dart | 21 ++- .../service/tweets/filtering_rule_meta.dart | 1 + .../tweets/filtering_rule_meta.freezed.dart | 3 +- .../service/tweets/filtering_rule_meta.g.dart | 18 ++- .../tweets/filtering_rule_summary.dart | 1 + .../filtering_rule_summary.freezed.dart | 3 +- .../tweets/filtering_rule_summary.g.dart | 22 ++- lib/src/service/tweets/geo.dart | 1 + lib/src/service/tweets/geo.freezed.dart | 3 +- lib/src/service/tweets/geo.g.dart | 17 ++- .../service/tweets/organic_tweet_metrics.dart | 1 + .../tweets/organic_tweet_metrics.freezed.dart | 3 +- .../tweets/organic_tweet_metrics.g.dart | 27 ++-- .../service/tweets/private_tweet_metrics.dart | 1 + .../tweets/private_tweet_metrics.freezed.dart | 3 +- .../tweets/private_tweet_metrics.g.dart | 21 ++- .../tweets/promoted_tweet_metrics.dart | 1 + .../promoted_tweet_metrics.freezed.dart | 3 +- .../tweets/promoted_tweet_metrics.g.dart | 27 ++-- lib/src/service/tweets/tweet_attachments.dart | 1 + .../tweets/tweet_attachments.freezed.dart | 3 +- .../service/tweets/tweet_attachments.g.dart | 18 ++- .../tweets/tweet_context_annotation.dart | 1 + .../tweet_context_annotation.freezed.dart | 3 +- .../tweets/tweet_context_annotation.g.dart | 21 ++- lib/src/service/tweets/tweet_count_meta.dart | 1 + .../tweets/tweet_count_meta.freezed.dart | 3 +- .../service/tweets/tweet_count_meta.g.dart | 19 ++- lib/src/service/tweets/tweet_data.dart | 1 + .../service/tweets/tweet_data.freezed.dart | 3 +- lib/src/service/tweets/tweet_data.g.dart | 63 ++++---- lib/src/service/tweets/tweet_entities.dart | 1 + .../tweets/tweet_entities.freezed.dart | 3 +- lib/src/service/tweets/tweet_entities.g.dart | 25 +++- lib/src/service/tweets/tweet_meta.dart | 1 + .../service/tweets/tweet_meta.freezed.dart | 3 +- lib/src/service/tweets/tweet_meta.g.dart | 24 ++- lib/src/service/users/user_data.dart | 1 + lib/src/service/users/user_data.freezed.dart | 3 +- lib/src/service/users/user_data.g.dart | 43 +++--- .../users/user_description_entity.dart | 1 + .../user_description_entity.freezed.dart | 3 +- .../users/user_description_entity.g.dart | 22 ++- lib/src/service/users/user_entities.dart | 1 + .../service/users/user_entities.freezed.dart | 3 +- lib/src/service/users/user_entities.g.dart | 18 ++- lib/src/service/users/user_meta.dart | 1 + lib/src/service/users/user_meta.freezed.dart | 3 +- lib/src/service/users/user_meta.g.dart | 21 ++- pubspec.yaml | 2 +- test/mocks/mock.mocks.dart | 3 - .../response/twitter_response_test.dart | 137 +----------------- 100 files changed, 764 insertions(+), 468 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebd5cf29..e8dc3d5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Release Note -## 4.4.2 +## v4.4.3 + +- Fixed to exclude null fields when performing `toJson` on `TwitterResponse` and other model objects. With this fix, the JSON obtained from `toJson` is now fully equivalent to the raw JSON returned by Twitter. ([#569](https://github.com/twitter-dart/twitter-api-v2/issues/569)) + +## v4.4.2 - Improved internal process for checking rate limit. ([#562](https://github.com/twitter-dart/twitter-api-v2/issues/562)) - Supported `entity:` filtering rule operator. You can use this operator with following methods. ([#557](https://github.com/twitter-dart/twitter-api-v2/issues/557)) diff --git a/README.md b/README.md index 6a4fc849..a4b040cf 100644 --- a/README.md +++ b/README.md @@ -86,18 +86,19 @@ - [1.4.3. Null Parameter at Request](#143-null-parameter-at-request) - [1.4.4. Expand Object Fields with `expansions`](#144-expand-object-fields-with-expansions) - [1.4.5. Expand Object Fields with `fields`](#145-expand-object-fields-with-fields) - - [1.4.6. OAuth 2.0 Authorization Code Flow with PKCE](#146-oauth-20-authorization-code-flow-with-pkce) - - [1.4.7. Change the Timeout Duration](#147-change-the-timeout-duration) - - [1.4.8. Automatic Retry](#148-automatic-retry) - - [1.4.8.1. Regular Intervals](#1481-regular-intervals) - - [1.4.8.2. Exponential Backoff](#1482-exponential-backoff) - - [1.4.8.3. Exponential Backoff and Jitter](#1483-exponential-backoff-and-jitter) - - [1.4.8.4. Do Something on Retry](#1484-do-something-on-retry) - - [1.4.9. Meaning of the Returned Boolean](#149-meaning-of-the-returned-boolean) - - [1.4.10. Thrown Exceptions](#1410-thrown-exceptions) - - [1.4.11. Upload Media](#1411-upload-media) - - [1.4.12. Check the Progress of Media Upload](#1412-check-the-progress-of-media-upload) - - [1.4.13. Generate Filtering Rules Safely and Easily](#1413-generate-filtering-rules-safely-and-easily) + - [1.4.6. JSON Serialization and Deserialization](#146-json-serialization-and-deserialization) + - [1.4.7. OAuth 2.0 Authorization Code Flow with PKCE](#147-oauth-20-authorization-code-flow-with-pkce) + - [1.4.8. Change the Timeout Duration](#148-change-the-timeout-duration) + - [1.4.9. Automatic Retry](#149-automatic-retry) + - [1.4.9.1. Regular Intervals](#1491-regular-intervals) + - [1.4.9.2. Exponential Backoff](#1492-exponential-backoff) + - [1.4.9.3. Exponential Backoff and Jitter](#1493-exponential-backoff-and-jitter) + - [1.4.9.4. Do Something on Retry](#1494-do-something-on-retry) + - [1.4.10. Meaning of the Returned Boolean](#1410-meaning-of-the-returned-boolean) + - [1.4.11. Thrown Exceptions](#1411-thrown-exceptions) + - [1.4.12. Upload Media](#1412-upload-media) + - [1.4.13. Check the Progress of Media Upload](#1413-check-the-progress-of-media-upload) + - [1.4.14. Generate Filtering Rules Safely and Easily](#1414-generate-filtering-rules-safely-and-easily) - [1.5. Contribution 🏆](#15-contribution-) - [1.6. Contributors ✨](#16-contributors-) - [1.7. Support ❤️](#17-support-️) @@ -235,6 +236,12 @@ Future main() async { }, ); + //! You can serialize & deserialize JSON from response object + //! and model object. + final tweetJson = tweets.data.first.toJson(); + final tweet = v2.TweetData.fromJson(tweetJson); + print(tweet); + await twitter.tweets.createLike( userId: me.data.id, tweetId: tweets.data.first.id, @@ -704,7 +711,65 @@ Future main() async { You can see more details about `fields` from [Official Documentation](https://developer.twitter.com/en/docs/twitter-api/fields). -### 1.4.6. OAuth 2.0 Authorization Code Flow with PKCE +### 1.4.6. JSON Serialization and Deserialization + +All Twitter API responses obtained using **twitter_api_v2** are returned stored in a safe type object. However, there may be cases where the raw JSON returned from the Twitter API is needed when creating applications in combination with other libraries. + +In that case, you can use the **`toJson`** method provided by the `TwitterResponse` or other model objects to convert it to the raw JSON format returned by the Twitter API. + +The JSON converted by this **`toJson`** method is **completely equivalent to the JSON returned by the Twitter API** and can be deserialized by using the factory constructor **`fromJson`** provided with each model object. + +```dart +import 'package:twitter_api_v2/twitter_api_v2.dart' as v2; + +Future main() async { + final twitter = v2.TwitterApi(bearerToken: 'YOUR_BEARER_TOKEN'); + + try { + final response = await twitter.tweets.searchRecent( + query: '#ElonMusk', + maxResults: 10, + expansions: v2.TweetExpansion.values, + ); + + //! You can get raw JSON from this response. + print(response.toJson()); + + //! Or you can get raw JSON from specific model object. + print(response.data.first.toJson()); + } on v2.TwitterException catch (e) { + print(e); + } +} +``` + +You could also write like: + +```dart +import 'package:twitter_api_v2/twitter_api_v2.dart' as v2; + +Future main() async { + final twitter = v2.TwitterApi(bearerToken: 'YOUR_BEARER_TOKEN'); + + try { + final response = await twitter.tweets.searchRecent( + query: '#ElonMusk', + maxResults: 10, + expansions: v2.TweetExpansion.values, + ); + + //! Serialize & Deserialize + final tweetJson = response.data.first.toJson(); + final tweet = v2.TweetData.fromJson(tweetJson); + + print(tweet); + } on v2.TwitterException catch (e) { + print(e); + } +} +``` + +### 1.4.7. OAuth 2.0 Authorization Code Flow with PKCE **Twitter API v2.0** supports authentication methods with [OAuth 2.0 PKCE](https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code), and it allows users of apps using **Twitter API v2.0** to request authorization for the minimum necessary [scope](https://developer.twitter.com/en/docs/authentication/guides/v2-authentication-mapping) of operation. @@ -719,7 +784,7 @@ Also, please refer to the next simple sample Flutter application that combines * - [Example Tweet App](https://github.com/twitter-dart/example-tweet-app-with-twitter-api-v2) -### 1.4.7. Change the Timeout Duration +### 1.4.8. Change the Timeout Duration The library specifies a default timeout of **10 seconds** for all API communications. @@ -738,7 +803,7 @@ Future main() { } ``` -### 1.4.8. Automatic Retry +### 1.4.9. Automatic Retry Due to the nature of this library's communication with external systems, timeouts may occur due to inevitable communication failures or temporary crashes of the server to which requests are sent. @@ -758,7 +823,7 @@ Also, errors subject to retry are as follows. - When the network is temporarily lost and a `SocketException` is thrown. - When communication times out temporarily and a `TimeoutException` is thrown -#### 1.4.8.1. Regular Intervals +#### 1.4.9.1. Regular Intervals It would be easy to imagine **retries at regular intervals**. For example, if a timeout occurs and the request is assumed to be retried 3 times, waiting for 5 seconds and then sending the request again, it can be defined as follows. @@ -778,7 +843,7 @@ Future main() async { } ``` -#### 1.4.8.2. Exponential Backoff +#### 1.4.9.2. Exponential Backoff Although retries can be effective by simply performing them at regular intervals as in the above example, sending a large number of requests at regular intervals when the server to which the request is being sent is experiencing a failure is something that should be avoided. Even if the network or server is already down, the retry process can further aggravate the situation by adding to the load. @@ -804,7 +869,7 @@ In the above implementation, the interval increases exponentially for each retry > 2 ^ retryCount -#### 1.4.8.3. Exponential Backoff and Jitter +#### 1.4.9.3. Exponential Backoff and Jitter Although the algorithm introduced earlier that exponentially increases the retry interval is already powerful, some may believe that it is not yet sufficient to distribute the sensation of retries. It's more distributed than equally spaced retries, but retries still occur at static intervals. @@ -831,7 +896,7 @@ In the above implementation, the interval increases exponentially for each retry > **(2 ^ retryCount) + jitter(Random Number between 0 ~ 3)** -#### 1.4.8.4. Do Something on Retry +#### 1.4.9.4. Do Something on Retry It would be useful to output logging on retries and a popup notifying the user that a retry has been executed. So **twitter_api_v2** provides callbacks that can perform arbitrary processing when retries are executed. @@ -856,7 +921,7 @@ Future main() async { The [RetryEvent](https://pub.dev/documentation/twitter_api_v2/latest/twitter_api_v2/RetryEvent-class.html) passed to the callback contains information on retries. -### 1.4.9. Meaning of the Returned Boolean +### 1.4.10. Meaning of the Returned Boolean A boolean value is returned from the endpoint when the communication is primarily POST, DELETE, or PUT. @@ -876,7 +941,7 @@ Note that this specification differs from the official [Twitter API v2.0](https: However, as mentioned earlier in **twitter_api_v2**, for example if you use the [createRetweet](https://pub.dev/documentation/twitter_api_v2/latest/twitter_api_v2/TweetsService/createRetweet.html) method, it will return a **flag indicating whether the process was successful or not**. This principle applies not only to the [createRetweet](https://pub.dev/documentation/twitter_api_v2/latest/twitter_api_v2/TweetsService/createRetweet.html) method, but to all methods that return flags as a result of processing. -### 1.4.10. Thrown Exceptions +### 1.4.11. Thrown Exceptions **twitter_api_v2** provides a convenient exception object for easy handling of exceptional responses and errors returned from [Twitter API v2.0](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/introduction). @@ -921,7 +986,7 @@ Future main() async { } ``` -### 1.4.11. Upload Media +### 1.4.12. Upload Media Uploading media on Twitter and sharing it with various people is a very interesting activity. Also, from a business perspective, accompanying tweets with media will attract even more interest from people. @@ -972,7 +1037,7 @@ This upload process works very safely, but note that [TwitterUploadException](ht > **Note**
> Also note that the v1.1 endpoint is used to achieve this specification in twitter_api_v2. This is because the official Twitter API v2.0 does not yet support media uploads. While I'm trying to keep the implementation as non-disruptive as possible in the future, there may be disruptive changes when media uploads are supported by the official Twitter API v2.0. -### 1.4.12. Check the Progress of Media Upload +### 1.4.13. Check the Progress of Media Upload Uploading small images to Twitter does not take long, but uploading large videos takes longer to complete. At that time, it would be very useful if you could show users how far along we are in the uploading process. @@ -1044,7 +1109,7 @@ And the trigger that calls the `onProgress` callback is as follows. But if the m Note that media uploads may also fail for reasons such as broken media. In such cases, [TwitterUploadException](https://pub.dev/documentation/twitter_api_core/latest/twitter_api_core/TwitterUploadException-class.html) is always thrown. -### 1.4.13. Generate Filtering Rules Safely and Easily +### 1.4.14. Generate Filtering Rules Safely and Easily The [Filtered Stream](https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/api-reference/get-tweets-search-stream) endpoint in [Twitter API v2.0](https://developer.twitter.com/en/docs/twitter-api/data-dictionary/introduction) supports a number of operators for advanced searches, not just `keywords` and `hashtags`. diff --git a/example/example.dart b/example/example.dart index b1526eb2..339ff145 100644 --- a/example/example.dart +++ b/example/example.dart @@ -82,6 +82,12 @@ Future main() async { }, ); + //! You can serialize & deserialize JSON from response object + //! and model object. + final tweetJson = tweets.data.first.toJson(); + final tweet = v2.TweetData.fromJson(tweetJson); + print(tweet); + await twitter.tweets.createLike( userId: me.data.id, tweetId: tweets.data.first.id, diff --git a/lib/src/service/common/includes.dart b/lib/src/service/common/includes.dart index a6dae5f0..d8a42454 100644 --- a/lib/src/service/common/includes.dart +++ b/lib/src/service/common/includes.dart @@ -18,6 +18,7 @@ part 'includes.g.dart'; @freezed class Includes with _$Includes { + @JsonSerializable(includeIfNull: false) const factory Includes({ /// This includes a list of referenced Retweets, Quoted Tweets, or replies /// in the form of Tweet objects with their default fields and any diff --git a/lib/src/service/common/includes.freezed.dart b/lib/src/service/common/includes.freezed.dart index fbf34d3d..4c025599 100644 --- a/lib/src/service/common/includes.freezed.dart +++ b/lib/src/service/common/includes.freezed.dart @@ -184,7 +184,8 @@ class __$$_IncludesCopyWithImpl<$Res> extends _$IncludesCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_Includes implements _Includes { const _$_Includes( {final List? tweets, diff --git a/lib/src/service/common/includes.g.dart b/lib/src/service/common/includes.g.dart index 96aeda64..4b69949b 100644 --- a/lib/src/service/common/includes.g.dart +++ b/lib/src/service/common/includes.g.dart @@ -54,12 +54,20 @@ _$_Includes _$$_IncludesFromJson(Map json) => $checkedCreate( }, ); -Map _$$_IncludesToJson(_$_Includes instance) => - { - 'tweets': instance.tweets?.map((e) => e.toJson()).toList(), - 'users': instance.users?.map((e) => e.toJson()).toList(), - 'media': instance.media?.map((e) => e.toJson()).toList(), - 'places': instance.places?.map((e) => e.toJson()).toList(), - 'polls': instance.polls?.map((e) => e.toJson()).toList(), - 'topics': instance.topics?.map((e) => e.toJson()).toList(), - }; +Map _$$_IncludesToJson(_$_Includes instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('tweets', instance.tweets?.map((e) => e.toJson()).toList()); + writeNotNull('users', instance.users?.map((e) => e.toJson()).toList()); + writeNotNull('media', instance.media?.map((e) => e.toJson()).toList()); + writeNotNull('places', instance.places?.map((e) => e.toJson()).toList()); + writeNotNull('polls', instance.polls?.map((e) => e.toJson()).toList()); + writeNotNull('topics', instance.topics?.map((e) => e.toJson()).toList()); + return val; +} diff --git a/lib/src/service/common/mention.dart b/lib/src/service/common/mention.dart index 5585200c..0a525bbb 100644 --- a/lib/src/service/common/mention.dart +++ b/lib/src/service/common/mention.dart @@ -10,6 +10,7 @@ part 'mention.g.dart'; @freezed class Mention with _$Mention { + @JsonSerializable(includeIfNull: false) const factory Mention({ /// The user id that created the mentions. String? id, diff --git a/lib/src/service/common/mention.freezed.dart b/lib/src/service/common/mention.freezed.dart index 487e4e4f..a6d8b394 100644 --- a/lib/src/service/common/mention.freezed.dart +++ b/lib/src/service/common/mention.freezed.dart @@ -133,7 +133,8 @@ class __$$_MentionCopyWithImpl<$Res> extends _$MentionCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_Mention implements _Mention { const _$_Mention( {this.id, diff --git a/lib/src/service/common/mention.g.dart b/lib/src/service/common/mention.g.dart index 1de3cb44..be69829c 100644 --- a/lib/src/service/common/mention.g.dart +++ b/lib/src/service/common/mention.g.dart @@ -22,10 +22,18 @@ _$_Mention _$$_MentionFromJson(Map json) => $checkedCreate( }, ); -Map _$$_MentionToJson(_$_Mention instance) => - { - 'id': instance.id, - 'username': instance.username, - 'start': instance.start, - 'end': instance.end, - }; +Map _$$_MentionToJson(_$_Mention instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('id', instance.id); + val['username'] = instance.username; + val['start'] = instance.start; + val['end'] = instance.end; + return val; +} diff --git a/lib/src/service/common/url.dart b/lib/src/service/common/url.dart index 8c507e84..517ede2d 100644 --- a/lib/src/service/common/url.dart +++ b/lib/src/service/common/url.dart @@ -12,6 +12,7 @@ part 'url.g.dart'; @freezed class Url with _$Url { + @JsonSerializable(includeIfNull: false) const factory Url({ /// The start position (zero-based) of the recognized URL within the object. /// All start indices are inclusive. diff --git a/lib/src/service/common/url.freezed.dart b/lib/src/service/common/url.freezed.dart index 3a130f48..eb2f670f 100644 --- a/lib/src/service/common/url.freezed.dart +++ b/lib/src/service/common/url.freezed.dart @@ -181,7 +181,8 @@ class __$$_UrlCopyWithImpl<$Res> extends _$UrlCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_Url implements _Url { const _$_Url( {required this.start, diff --git a/lib/src/service/common/url.g.dart b/lib/src/service/common/url.g.dart index 36090447..f2bf3a1d 100644 --- a/lib/src/service/common/url.g.dart +++ b/lib/src/service/common/url.g.dart @@ -31,12 +31,22 @@ _$_Url _$$_UrlFromJson(Map json) => $checkedCreate( }, ); -Map _$$_UrlToJson(_$_Url instance) => { - 'start': instance.start, - 'end': instance.end, - 'url': instance.url, - 'expanded_url': instance.expandedUrl, - 'display_url': instance.displayUrl, - 'unwound_url': instance.unwoundUrl, - 'media_key': instance.mediaKey, - }; +Map _$$_UrlToJson(_$_Url instance) { + final val = { + 'start': instance.start, + 'end': instance.end, + 'url': instance.url, + 'expanded_url': instance.expandedUrl, + 'display_url': instance.displayUrl, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('unwound_url', instance.unwoundUrl); + writeNotNull('media_key', instance.mediaKey); + return val; +} diff --git a/lib/src/service/dms/dm_event_data.dart b/lib/src/service/dms/dm_event_data.dart index 11235612..50d76922 100644 --- a/lib/src/service/dms/dm_event_data.dart +++ b/lib/src/service/dms/dm_event_data.dart @@ -18,6 +18,7 @@ part 'dm_event_data.g.dart'; @freezed class DMEventData with _$DMEventData implements Data { + @JsonSerializable(includeIfNull: false) const factory DMEventData({ /// The id of the Direct Message event. required String id, diff --git a/lib/src/service/dms/dm_event_data.freezed.dart b/lib/src/service/dms/dm_event_data.freezed.dart index f16dc179..62b12738 100644 --- a/lib/src/service/dms/dm_event_data.freezed.dart +++ b/lib/src/service/dms/dm_event_data.freezed.dart @@ -221,7 +221,8 @@ class __$$_DMEventDataCopyWithImpl<$Res> extends _$DMEventDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_DMEventData implements _DMEventData { const _$_DMEventData( {required this.id, diff --git a/lib/src/service/dms/dm_event_data.g.dart b/lib/src/service/dms/dm_event_data.g.dart index 2312c708..28259919 100644 --- a/lib/src/service/dms/dm_event_data.g.dart +++ b/lib/src/service/dms/dm_event_data.g.dart @@ -46,18 +46,27 @@ _$_DMEventData _$$_DMEventDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_DMEventDataToJson(_$_DMEventData instance) => - { - 'id': instance.id, - 'event_type': _$DMEventTypeEnumMap[instance.eventType]!, - 'text': instance.text, - 'sender_id': instance.senderId, - 'dm_conversation_id': instance.conversationId, - 'referenced_tweets': - instance.referencedTweets?.map((e) => e.toJson()).toList(), - 'attachments': instance.attachments?.toJson(), - 'created_at': instance.createdAt?.toIso8601String(), - }; +Map _$$_DMEventDataToJson(_$_DMEventData instance) { + final val = { + 'id': instance.id, + 'event_type': _$DMEventTypeEnumMap[instance.eventType]!, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('text', instance.text); + writeNotNull('sender_id', instance.senderId); + writeNotNull('dm_conversation_id', instance.conversationId); + writeNotNull('referenced_tweets', + instance.referencedTweets?.map((e) => e.toJson()).toList()); + writeNotNull('attachments', instance.attachments?.toJson()); + writeNotNull('created_at', instance.createdAt?.toIso8601String()); + return val; +} const _$DMEventTypeEnumMap = { DMEventType.messageCreate: 'MessageCreate', diff --git a/lib/src/service/dms/dm_event_meta.dart b/lib/src/service/dms/dm_event_meta.dart index e45ca841..395eb228 100644 --- a/lib/src/service/dms/dm_event_meta.dart +++ b/lib/src/service/dms/dm_event_meta.dart @@ -13,6 +13,7 @@ part 'dm_event_meta.g.dart'; @freezed class DMEventMeta with _$DMEventMeta implements Pageable { + @JsonSerializable(includeIfNull: false) const factory DMEventMeta({ /// The number of results in the current page. required int resultCount, diff --git a/lib/src/service/dms/dm_event_meta.freezed.dart b/lib/src/service/dms/dm_event_meta.freezed.dart index 0bb5cccf..6e3a3aa6 100644 --- a/lib/src/service/dms/dm_event_meta.freezed.dart +++ b/lib/src/service/dms/dm_event_meta.freezed.dart @@ -120,7 +120,8 @@ class __$$_DMEventMetaCopyWithImpl<$Res> extends _$DMEventMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_DMEventMeta implements _DMEventMeta { const _$_DMEventMeta( {required this.resultCount, this.nextToken, this.previousToken}); diff --git a/lib/src/service/dms/dm_event_meta.g.dart b/lib/src/service/dms/dm_event_meta.g.dart index 00fab54b..451a5b58 100644 --- a/lib/src/service/dms/dm_event_meta.g.dart +++ b/lib/src/service/dms/dm_event_meta.g.dart @@ -26,9 +26,18 @@ _$_DMEventMeta _$$_DMEventMetaFromJson(Map json) => $checkedCreate( }, ); -Map _$$_DMEventMetaToJson(_$_DMEventMeta instance) => - { - 'result_count': instance.resultCount, - 'next_token': instance.nextToken, - 'previous_token': instance.previousToken, - }; +Map _$$_DMEventMetaToJson(_$_DMEventMeta instance) { + final val = { + 'result_count': instance.resultCount, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('next_token', instance.nextToken); + writeNotNull('previous_token', instance.previousToken); + return val; +} diff --git a/lib/src/service/lists/list_data.dart b/lib/src/service/lists/list_data.dart index 59b37322..3a8bd8f3 100644 --- a/lib/src/service/lists/list_data.dart +++ b/lib/src/service/lists/list_data.dart @@ -30,6 +30,7 @@ part 'list_data.g.dart'; /// complete the expansion object. @freezed class ListData with _$ListData implements Data { + @JsonSerializable(includeIfNull: false) const factory ListData({ /// The unique identifier of this List. /// diff --git a/lib/src/service/lists/list_data.freezed.dart b/lib/src/service/lists/list_data.freezed.dart index f7cd8113..1f2435fe 100644 --- a/lib/src/service/lists/list_data.freezed.dart +++ b/lib/src/service/lists/list_data.freezed.dart @@ -213,7 +213,8 @@ class __$$_ListDataCopyWithImpl<$Res> extends _$ListDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_ListData implements _ListData { const _$_ListData( {required this.id, diff --git a/lib/src/service/lists/list_data.g.dart b/lib/src/service/lists/list_data.g.dart index 0868ac69..dac0a68f 100644 --- a/lib/src/service/lists/list_data.g.dart +++ b/lib/src/service/lists/list_data.g.dart @@ -34,14 +34,23 @@ _$_ListData _$$_ListDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_ListDataToJson(_$_ListData instance) => - { - 'id': instance.id, - 'name': instance.name, - 'description': instance.description, - 'owner_id': instance.ownerId, - 'follower_count': instance.followerCount, - 'member_count': instance.memberCount, - 'private': instance.isPrivate, - 'created_at': instance.createdAt?.toIso8601String(), - }; +Map _$$_ListDataToJson(_$_ListData instance) { + final val = { + 'id': instance.id, + 'name': instance.name, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('description', instance.description); + writeNotNull('owner_id', instance.ownerId); + writeNotNull('follower_count', instance.followerCount); + writeNotNull('member_count', instance.memberCount); + writeNotNull('private', instance.isPrivate); + writeNotNull('created_at', instance.createdAt?.toIso8601String()); + return val; +} diff --git a/lib/src/service/lists/list_meta.dart b/lib/src/service/lists/list_meta.dart index fa4d72e0..9a82e499 100644 --- a/lib/src/service/lists/list_meta.dart +++ b/lib/src/service/lists/list_meta.dart @@ -13,6 +13,7 @@ part 'list_meta.g.dart'; @freezed class ListMeta with _$ListMeta implements Pageable { + @JsonSerializable(includeIfNull: false) const factory ListMeta({ /// The number of users returned in this request. Note that this number /// may be lower than what was specified in the max_results query parameter. diff --git a/lib/src/service/lists/list_meta.freezed.dart b/lib/src/service/lists/list_meta.freezed.dart index 6ddf5715..2af6e6e2 100644 --- a/lib/src/service/lists/list_meta.freezed.dart +++ b/lib/src/service/lists/list_meta.freezed.dart @@ -127,7 +127,8 @@ class __$$_ListMetaCopyWithImpl<$Res> extends _$ListMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_ListMeta implements _ListMeta { const _$_ListMeta({this.resultCount, this.nextToken, this.previousToken}); diff --git a/lib/src/service/lists/list_meta.g.dart b/lib/src/service/lists/list_meta.g.dart index a170df94..56ca727b 100644 --- a/lib/src/service/lists/list_meta.g.dart +++ b/lib/src/service/lists/list_meta.g.dart @@ -26,9 +26,17 @@ _$_ListMeta _$$_ListMetaFromJson(Map json) => $checkedCreate( }, ); -Map _$$_ListMetaToJson(_$_ListMeta instance) => - { - 'result_count': instance.resultCount, - 'next_token': instance.nextToken, - 'previous_token': instance.previousToken, - }; +Map _$$_ListMetaToJson(_$_ListMeta instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('result_count', instance.resultCount); + writeNotNull('next_token', instance.nextToken); + writeNotNull('previous_token', instance.previousToken); + return val; +} diff --git a/lib/src/service/media/media_data.dart b/lib/src/service/media/media_data.dart index 05d5be43..4684921a 100644 --- a/lib/src/service/media/media_data.dart +++ b/lib/src/service/media/media_data.dart @@ -30,6 +30,7 @@ part 'media_data.g.dart'; /// Note that video URLs are not currently available, only static images. @freezed class MediaData with _$MediaData { + @JsonSerializable(includeIfNull: false) const factory MediaData({ /// Unique identifier of the expanded media content. /// diff --git a/lib/src/service/media/media_data.freezed.dart b/lib/src/service/media/media_data.freezed.dart index e7058afe..ebbf90e1 100644 --- a/lib/src/service/media/media_data.freezed.dart +++ b/lib/src/service/media/media_data.freezed.dart @@ -380,7 +380,8 @@ class __$$_MediaDataCopyWithImpl<$Res> extends _$MediaDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_MediaData implements _MediaData { const _$_MediaData( {@JsonKey(name: 'media_key') required this.key, diff --git a/lib/src/service/media/media_data.g.dart b/lib/src/service/media/media_data.g.dart index 1189aaee..a09d3233 100644 --- a/lib/src/service/media/media_data.g.dart +++ b/lib/src/service/media/media_data.g.dart @@ -69,22 +69,31 @@ _$_MediaData _$$_MediaDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_MediaDataToJson(_$_MediaData instance) => - { - 'media_key': instance.key, - 'type': _$MediaTypeEnumMap[instance.type]!, - 'url': instance.url, - 'alt_text': instance.altText, - 'duration_ms': instance.durationMilliseconds, - 'height': instance.height, - 'width': instance.width, - 'non_public_metrics': instance.privateMetrics?.toJson(), - 'organic_metrics': instance.organicMetrics?.toJson(), - 'preview_image_url': instance.previewImageUrl, - 'promoted_metrics': instance.promotedMetrics?.toJson(), - 'public_metrics': instance.publicMetrics?.toJson(), - 'variants': instance.variants?.map((e) => e.toJson()).toList(), - }; +Map _$$_MediaDataToJson(_$_MediaData instance) { + final val = { + 'media_key': instance.key, + 'type': _$MediaTypeEnumMap[instance.type]!, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('url', instance.url); + writeNotNull('alt_text', instance.altText); + writeNotNull('duration_ms', instance.durationMilliseconds); + writeNotNull('height', instance.height); + writeNotNull('width', instance.width); + writeNotNull('non_public_metrics', instance.privateMetrics?.toJson()); + writeNotNull('organic_metrics', instance.organicMetrics?.toJson()); + writeNotNull('preview_image_url', instance.previewImageUrl); + writeNotNull('promoted_metrics', instance.promotedMetrics?.toJson()); + writeNotNull('public_metrics', instance.publicMetrics?.toJson()); + writeNotNull('variants', instance.variants?.map((e) => e.toJson()).toList()); + return val; +} const _$MediaTypeEnumMap = { MediaType.photo: 'photo', diff --git a/lib/src/service/media/uploaded_media_data.dart b/lib/src/service/media/uploaded_media_data.dart index 7e65cc37..d25c96f1 100644 --- a/lib/src/service/media/uploaded_media_data.dart +++ b/lib/src/service/media/uploaded_media_data.dart @@ -17,6 +17,7 @@ part 'uploaded_media_data.g.dart'; /// This object represents uploaded media data. @freezed class UploadedMediaData with _$UploadedMediaData implements Data { + @JsonSerializable(includeIfNull: false) const factory UploadedMediaData({ /// The identifier for the uploaded media. @JsonKey(name: 'media_id_string') required String id, diff --git a/lib/src/service/media/uploaded_media_data.freezed.dart b/lib/src/service/media/uploaded_media_data.freezed.dart index aaa573c0..07572172 100644 --- a/lib/src/service/media/uploaded_media_data.freezed.dart +++ b/lib/src/service/media/uploaded_media_data.freezed.dart @@ -145,7 +145,8 @@ class __$$_UploadedMediaDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_UploadedMediaData implements _UploadedMediaData { const _$_UploadedMediaData( {@JsonKey(name: 'media_id_string') required this.id, diff --git a/lib/src/service/media/uploaded_media_data.g.dart b/lib/src/service/media/uploaded_media_data.g.dart index 994222c4..dd2dc5fd 100644 --- a/lib/src/service/media/uploaded_media_data.g.dart +++ b/lib/src/service/media/uploaded_media_data.g.dart @@ -28,9 +28,18 @@ _$_UploadedMediaData _$$_UploadedMediaDataFromJson(Map json) => $checkedCreate( ); Map _$$_UploadedMediaDataToJson( - _$_UploadedMediaData instance) => - { - 'media_id_string': instance.id, - 'expires_at': instance.expiresAt.toIso8601String(), - 'locale': instance.locale?.toJson(), - }; + _$_UploadedMediaData instance) { + final val = { + 'media_id_string': instance.id, + 'expires_at': instance.expiresAt.toIso8601String(), + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('locale', instance.locale?.toJson()); + return val; +} diff --git a/lib/src/service/media/variant.dart b/lib/src/service/media/variant.dart index f87b1106..3e3206e2 100644 --- a/lib/src/service/media/variant.dart +++ b/lib/src/service/media/variant.dart @@ -10,6 +10,7 @@ part 'variant.g.dart'; @freezed class Variant with _$Variant { + @JsonSerializable(includeIfNull: false) const factory Variant({ /// The number of bit rates in the content. /// diff --git a/lib/src/service/media/variant.freezed.dart b/lib/src/service/media/variant.freezed.dart index ec614661..9fdb958f 100644 --- a/lib/src/service/media/variant.freezed.dart +++ b/lib/src/service/media/variant.freezed.dart @@ -116,7 +116,8 @@ class __$$_VariantCopyWithImpl<$Res> extends _$VariantCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_Variant implements _Variant { const _$_Variant( {this.bitRate, required this.contentType, required this.url}); diff --git a/lib/src/service/media/variant.g.dart b/lib/src/service/media/variant.g.dart index 3dab56d9..3e64e9ba 100644 --- a/lib/src/service/media/variant.g.dart +++ b/lib/src/service/media/variant.g.dart @@ -22,9 +22,17 @@ _$_Variant _$$_VariantFromJson(Map json) => $checkedCreate( fieldKeyMap: const {'bitRate': 'bit_rate', 'contentType': 'content_type'}, ); -Map _$$_VariantToJson(_$_Variant instance) => - { - 'bit_rate': instance.bitRate, - 'content_type': instance.contentType, - 'url': instance.url, - }; +Map _$$_VariantToJson(_$_Variant instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('bit_rate', instance.bitRate); + val['content_type'] = instance.contentType; + val['url'] = instance.url; + return val; +} diff --git a/lib/src/service/places/place_data.dart b/lib/src/service/places/place_data.dart index a8be55f3..8931147a 100644 --- a/lib/src/service/places/place_data.dart +++ b/lib/src/service/places/place_data.dart @@ -21,6 +21,7 @@ part 'place_data.g.dart'; /// additional fields to complete the object. @freezed class PlaceData with _$PlaceData { + @JsonSerializable(includeIfNull: false) const factory PlaceData({ /// The unique identifier of the expanded place, if this is a point of /// interest tagged in the Tweet. diff --git a/lib/src/service/places/place_data.freezed.dart b/lib/src/service/places/place_data.freezed.dart index 1b17418f..32721023 100644 --- a/lib/src/service/places/place_data.freezed.dart +++ b/lib/src/service/places/place_data.freezed.dart @@ -240,7 +240,8 @@ class __$$_PlaceDataCopyWithImpl<$Res> extends _$PlaceDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_PlaceData implements _PlaceData { const _$_PlaceData( {required this.id, diff --git a/lib/src/service/places/place_data.g.dart b/lib/src/service/places/place_data.g.dart index 70e5d10f..b3765831 100644 --- a/lib/src/service/places/place_data.g.dart +++ b/lib/src/service/places/place_data.g.dart @@ -37,14 +37,23 @@ _$_PlaceData _$$_PlaceDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_PlaceDataToJson(_$_PlaceData instance) => - { - 'id': instance.id, - 'full_name': instance.fullName, - 'name': instance.name, - 'place_type': instance.placeType, - 'country': instance.country, - 'country_code': instance.countryCode, - 'geo': instance.geo?.toJson(), - 'contained_within': instance.containedWithin, - }; +Map _$$_PlaceDataToJson(_$_PlaceData instance) { + final val = { + 'id': instance.id, + 'full_name': instance.fullName, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('name', instance.name); + writeNotNull('place_type', instance.placeType); + writeNotNull('country', instance.country); + writeNotNull('country_code', instance.countryCode); + writeNotNull('geo', instance.geo?.toJson()); + writeNotNull('contained_within', instance.containedWithin); + return val; +} diff --git a/lib/src/service/polls/poll_data.dart b/lib/src/service/polls/poll_data.dart index d05e546e..31cabd98 100644 --- a/lib/src/service/polls/poll_data.dart +++ b/lib/src/service/polls/poll_data.dart @@ -24,6 +24,7 @@ part 'poll_data.g.dart'; /// additional fields to complete the object. @freezed class PollData with _$PollData { + @JsonSerializable(includeIfNull: false) const factory PollData({ /// Unique identifier of the expanded poll. required String id, diff --git a/lib/src/service/polls/poll_data.freezed.dart b/lib/src/service/polls/poll_data.freezed.dart index e114fd39..ad2bf840 100644 --- a/lib/src/service/polls/poll_data.freezed.dart +++ b/lib/src/service/polls/poll_data.freezed.dart @@ -154,7 +154,8 @@ class __$$_PollDataCopyWithImpl<$Res> extends _$PollDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_PollData implements _PollData { const _$_PollData( {required this.id, diff --git a/lib/src/service/polls/poll_data.g.dart b/lib/src/service/polls/poll_data.g.dart index 2519e8d3..fb503b01 100644 --- a/lib/src/service/polls/poll_data.g.dart +++ b/lib/src/service/polls/poll_data.g.dart @@ -36,14 +36,24 @@ _$_PollData _$$_PollDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_PollDataToJson(_$_PollData instance) => - { - 'id': instance.id, - 'options': instance.options.map((e) => e.toJson()).toList(), - 'voting_status': _$PollVotingStatusEnumMap[instance.votingStatus], - 'duration_minutes': instance.durationMinutes, - 'end_datetime': instance.endAt?.toIso8601String(), - }; +Map _$$_PollDataToJson(_$_PollData instance) { + final val = { + 'id': instance.id, + 'options': instance.options.map((e) => e.toJson()).toList(), + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull( + 'voting_status', _$PollVotingStatusEnumMap[instance.votingStatus]); + writeNotNull('duration_minutes', instance.durationMinutes); + writeNotNull('end_datetime', instance.endAt?.toIso8601String()); + return val; +} const _$PollVotingStatusEnumMap = { PollVotingStatus.open: 'open', diff --git a/lib/src/service/response/twitter_response.dart b/lib/src/service/response/twitter_response.dart index 3abd9f0f..fc689903 100644 --- a/lib/src/service/response/twitter_response.dart +++ b/lib/src/service/response/twitter_response.dart @@ -40,13 +40,28 @@ class TwitterResponse { /// Returns true if this response has not [meta], otherwise false. bool get hasNotMeta => !hasMeta; - Map toJson() => { - 'data': data is List - ? (data as List).map((e) => e.toJson()).toList() - : (data as dynamic).toJson(), - 'includes': includes?.toJson(), - 'meta': (meta as dynamic)?.toJson(), - }; + /// Returns the JSON representation of this response. + /// + /// It equals to raw JSON response from Twitter. + Map toJson() { + final json = { + 'data': data is List + ? (data as List).map((e) => e.toJson()).toList() + : (data as dynamic).toJson() + }; + + final $includes = includes?.toJson(); + if ($includes != null) { + json['includes'] = $includes; + } + + final $meta = (meta as dynamic)?.toJson(); + if ($meta != null) { + json['meta'] = $meta; + } + + return json; + } @override String toString() { diff --git a/lib/src/service/spaces/space_data.dart b/lib/src/service/spaces/space_data.dart index 64034779..ea02e301 100644 --- a/lib/src/service/spaces/space_data.dart +++ b/lib/src/service/spaces/space_data.dart @@ -31,6 +31,7 @@ part 'space_data.g.dart'; /// expectations and intent. @freezed class SpaceData with _$SpaceData implements Data { + @JsonSerializable(includeIfNull: false) const factory SpaceData({ /// The unique identifier of the requested Space. /// diff --git a/lib/src/service/spaces/space_data.freezed.dart b/lib/src/service/spaces/space_data.freezed.dart index a61e96dc..c45d56c6 100644 --- a/lib/src/service/spaces/space_data.freezed.dart +++ b/lib/src/service/spaces/space_data.freezed.dart @@ -412,7 +412,8 @@ class __$$_SpaceDataCopyWithImpl<$Res> extends _$SpaceDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_SpaceData implements _SpaceData { const _$_SpaceData( {required this.id, diff --git a/lib/src/service/spaces/space_data.g.dart b/lib/src/service/spaces/space_data.g.dart index 0ebc18ab..83de77c4 100644 --- a/lib/src/service/spaces/space_data.g.dart +++ b/lib/src/service/spaces/space_data.g.dart @@ -63,26 +63,35 @@ _$_SpaceData _$$_SpaceDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_SpaceDataToJson(_$_SpaceData instance) => - { - 'id': instance.id, - 'title': instance.title, - 'state': _$SpaceStateEnumMap[instance.state], - 'creator_id': instance.creatorId, - 'lang': _$SpaceLanguageEnumMap[instance.lang], - 'host_ids': instance.hostIds, - 'topic_ids': instance.topicIds, - 'speaker_ids': instance.speakerIds, - 'invited_user_ids': instance.invitedUserIds, - 'subscriber_count': instance.subscriberCount, - 'participant_count': instance.participantCount, - 'is_ticketed': instance.isTicketed, - 'scheduled_start': instance.scheduledStart?.toIso8601String(), - 'started_at': instance.startedAt?.toIso8601String(), - 'ended_at': instance.endedAt?.toIso8601String(), - 'created_at': instance.createdAt?.toIso8601String(), - 'updated_at': instance.updatedAt?.toIso8601String(), - }; +Map _$$_SpaceDataToJson(_$_SpaceData instance) { + final val = { + 'id': instance.id, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('title', instance.title); + writeNotNull('state', _$SpaceStateEnumMap[instance.state]); + writeNotNull('creator_id', instance.creatorId); + writeNotNull('lang', _$SpaceLanguageEnumMap[instance.lang]); + writeNotNull('host_ids', instance.hostIds); + writeNotNull('topic_ids', instance.topicIds); + writeNotNull('speaker_ids', instance.speakerIds); + writeNotNull('invited_user_ids', instance.invitedUserIds); + writeNotNull('subscriber_count', instance.subscriberCount); + writeNotNull('participant_count', instance.participantCount); + writeNotNull('is_ticketed', instance.isTicketed); + writeNotNull('scheduled_start', instance.scheduledStart?.toIso8601String()); + writeNotNull('started_at', instance.startedAt?.toIso8601String()); + writeNotNull('ended_at', instance.endedAt?.toIso8601String()); + writeNotNull('created_at', instance.createdAt?.toIso8601String()); + writeNotNull('updated_at', instance.updatedAt?.toIso8601String()); + return val; +} const _$SpaceStateEnumMap = { SpaceState.scheduled: 'scheduled', diff --git a/lib/src/service/spaces/space_meta.dart b/lib/src/service/spaces/space_meta.dart index 2c0a5e93..d16df145 100644 --- a/lib/src/service/spaces/space_meta.dart +++ b/lib/src/service/spaces/space_meta.dart @@ -13,6 +13,7 @@ part 'space_meta.g.dart'; @freezed class SpaceMeta with _$SpaceMeta implements Meta { + @JsonSerializable(includeIfNull: false) const factory SpaceMeta({ /// The number of spaces returned in this request. required int? resultCount, diff --git a/lib/src/service/spaces/space_meta.freezed.dart b/lib/src/service/spaces/space_meta.freezed.dart index 7a86c3b7..d9e57a0d 100644 --- a/lib/src/service/spaces/space_meta.freezed.dart +++ b/lib/src/service/spaces/space_meta.freezed.dart @@ -90,7 +90,8 @@ class __$$_SpaceMetaCopyWithImpl<$Res> extends _$SpaceMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_SpaceMeta implements _SpaceMeta { const _$_SpaceMeta({required this.resultCount}); diff --git a/lib/src/service/spaces/space_meta.g.dart b/lib/src/service/spaces/space_meta.g.dart index f9f6a6bd..b9ae321e 100644 --- a/lib/src/service/spaces/space_meta.g.dart +++ b/lib/src/service/spaces/space_meta.g.dart @@ -20,7 +20,15 @@ _$_SpaceMeta _$$_SpaceMetaFromJson(Map json) => $checkedCreate( fieldKeyMap: const {'resultCount': 'result_count'}, ); -Map _$$_SpaceMetaToJson(_$_SpaceMeta instance) => - { - 'result_count': instance.resultCount, - }; +Map _$$_SpaceMetaToJson(_$_SpaceMeta instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('result_count', instance.resultCount); + return val; +} diff --git a/lib/src/service/tweets/filtering_rule_data.dart b/lib/src/service/tweets/filtering_rule_data.dart index 02d97876..42e93fb5 100644 --- a/lib/src/service/tweets/filtering_rule_data.dart +++ b/lib/src/service/tweets/filtering_rule_data.dart @@ -13,6 +13,7 @@ part 'filtering_rule_data.g.dart'; @freezed class FilteringRuleData with _$FilteringRuleData implements Data { + @JsonSerializable(includeIfNull: false) const factory FilteringRuleData({ /// Unique identifier of this rule. This is returned as a string in order /// to avoid complications with languages and tools that cannot diff --git a/lib/src/service/tweets/filtering_rule_data.freezed.dart b/lib/src/service/tweets/filtering_rule_data.freezed.dart index 80b83659..fd74cb54 100644 --- a/lib/src/service/tweets/filtering_rule_data.freezed.dart +++ b/lib/src/service/tweets/filtering_rule_data.freezed.dart @@ -122,7 +122,8 @@ class __$$_FilteringRuleDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_FilteringRuleData implements _FilteringRuleData { const _$_FilteringRuleData({required this.id, required this.value, this.tag}); diff --git a/lib/src/service/tweets/filtering_rule_data.g.dart b/lib/src/service/tweets/filtering_rule_data.g.dart index 13de21bc..7deb452d 100644 --- a/lib/src/service/tweets/filtering_rule_data.g.dart +++ b/lib/src/service/tweets/filtering_rule_data.g.dart @@ -22,9 +22,18 @@ _$_FilteringRuleData _$$_FilteringRuleDataFromJson(Map json) => $checkedCreate( ); Map _$$_FilteringRuleDataToJson( - _$_FilteringRuleData instance) => - { - 'id': instance.id, - 'value': instance.value, - 'tag': instance.tag, - }; + _$_FilteringRuleData instance) { + final val = { + 'id': instance.id, + 'value': instance.value, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('tag', instance.tag); + return val; +} diff --git a/lib/src/service/tweets/filtering_rule_meta.dart b/lib/src/service/tweets/filtering_rule_meta.dart index 652496ab..a4cf337d 100644 --- a/lib/src/service/tweets/filtering_rule_meta.dart +++ b/lib/src/service/tweets/filtering_rule_meta.dart @@ -16,6 +16,7 @@ part 'filtering_rule_meta.g.dart'; @freezed class FilteringRuleMeta with _$FilteringRuleMeta implements Meta { + @JsonSerializable(includeIfNull: false) const factory FilteringRuleMeta({ /// The time when the request body was returned. @JsonKey(name: 'sent') DateTime? sentAt, diff --git a/lib/src/service/tweets/filtering_rule_meta.freezed.dart b/lib/src/service/tweets/filtering_rule_meta.freezed.dart index 00eb6e93..57733810 100644 --- a/lib/src/service/tweets/filtering_rule_meta.freezed.dart +++ b/lib/src/service/tweets/filtering_rule_meta.freezed.dart @@ -128,7 +128,8 @@ class __$$_FilteringRuleMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_FilteringRuleMeta implements _FilteringRuleMeta { const _$_FilteringRuleMeta( {@JsonKey(name: 'sent') this.sentAt, this.summary}); diff --git a/lib/src/service/tweets/filtering_rule_meta.g.dart b/lib/src/service/tweets/filtering_rule_meta.g.dart index 2ddc65fd..ea80fa48 100644 --- a/lib/src/service/tweets/filtering_rule_meta.g.dart +++ b/lib/src/service/tweets/filtering_rule_meta.g.dart @@ -28,8 +28,16 @@ _$_FilteringRuleMeta _$$_FilteringRuleMetaFromJson(Map json) => $checkedCreate( ); Map _$$_FilteringRuleMetaToJson( - _$_FilteringRuleMeta instance) => - { - 'sent': instance.sentAt?.toIso8601String(), - 'summary': instance.summary?.toJson(), - }; + _$_FilteringRuleMeta instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('sent', instance.sentAt?.toIso8601String()); + writeNotNull('summary', instance.summary?.toJson()); + return val; +} diff --git a/lib/src/service/tweets/filtering_rule_summary.dart b/lib/src/service/tweets/filtering_rule_summary.dart index aee4bdec..1d6304ae 100644 --- a/lib/src/service/tweets/filtering_rule_summary.dart +++ b/lib/src/service/tweets/filtering_rule_summary.dart @@ -12,6 +12,7 @@ part 'filtering_rule_summary.g.dart'; @freezed class FilteringRuleSummary with _$FilteringRuleSummary { + @JsonSerializable(includeIfNull: false) const factory FilteringRuleSummary({ /// The count of created filtering rules. @JsonKey(name: 'created') int? createdCount, diff --git a/lib/src/service/tweets/filtering_rule_summary.freezed.dart b/lib/src/service/tweets/filtering_rule_summary.freezed.dart index 5fa2cd05..609c88b6 100644 --- a/lib/src/service/tweets/filtering_rule_summary.freezed.dart +++ b/lib/src/service/tweets/filtering_rule_summary.freezed.dart @@ -145,7 +145,8 @@ class __$$_FilteringRuleSummaryCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_FilteringRuleSummary implements _FilteringRuleSummary { const _$_FilteringRuleSummary( {@JsonKey(name: 'created') this.createdCount, diff --git a/lib/src/service/tweets/filtering_rule_summary.g.dart b/lib/src/service/tweets/filtering_rule_summary.g.dart index 19dc13bf..264803f0 100644 --- a/lib/src/service/tweets/filtering_rule_summary.g.dart +++ b/lib/src/service/tweets/filtering_rule_summary.g.dart @@ -30,10 +30,18 @@ _$_FilteringRuleSummary _$$_FilteringRuleSummaryFromJson(Map json) => ); Map _$$_FilteringRuleSummaryToJson( - _$_FilteringRuleSummary instance) => - { - 'created': instance.createdCount, - 'not_created': instance.notCreatedCount, - 'deleted': instance.deletedCount, - 'not_deleted': instance.notDeletedCount, - }; + _$_FilteringRuleSummary instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('created', instance.createdCount); + writeNotNull('not_created', instance.notCreatedCount); + writeNotNull('deleted', instance.deletedCount); + writeNotNull('not_deleted', instance.notDeletedCount); + return val; +} diff --git a/lib/src/service/tweets/geo.dart b/lib/src/service/tweets/geo.dart index 41e07306..e48263cc 100644 --- a/lib/src/service/tweets/geo.dart +++ b/lib/src/service/tweets/geo.dart @@ -15,6 +15,7 @@ part 'geo.g.dart'; @freezed class Geo with _$Geo { + @JsonSerializable(includeIfNull: false) const factory Geo({ /// The unique identifier of the place, if this is a point of interest /// tagged in the Tweet. diff --git a/lib/src/service/tweets/geo.freezed.dart b/lib/src/service/tweets/geo.freezed.dart index e81ddaf8..bc2f31ec 100644 --- a/lib/src/service/tweets/geo.freezed.dart +++ b/lib/src/service/tweets/geo.freezed.dart @@ -121,7 +121,8 @@ class __$$_GeoCopyWithImpl<$Res> extends _$GeoCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_Geo implements _Geo { const _$_Geo({this.placeId, this.coordinates}); diff --git a/lib/src/service/tweets/geo.g.dart b/lib/src/service/tweets/geo.g.dart index a1243df8..c5e5310b 100644 --- a/lib/src/service/tweets/geo.g.dart +++ b/lib/src/service/tweets/geo.g.dart @@ -26,7 +26,16 @@ _$_Geo _$$_GeoFromJson(Map json) => $checkedCreate( fieldKeyMap: const {'placeId': 'place_id'}, ); -Map _$$_GeoToJson(_$_Geo instance) => { - 'place_id': instance.placeId, - 'coordinates': instance.coordinates?.toJson(), - }; +Map _$$_GeoToJson(_$_Geo instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('place_id', instance.placeId); + writeNotNull('coordinates', instance.coordinates?.toJson()); + return val; +} diff --git a/lib/src/service/tweets/organic_tweet_metrics.dart b/lib/src/service/tweets/organic_tweet_metrics.dart index fa48a344..5b0f3184 100644 --- a/lib/src/service/tweets/organic_tweet_metrics.dart +++ b/lib/src/service/tweets/organic_tweet_metrics.dart @@ -12,6 +12,7 @@ part 'organic_tweet_metrics.g.dart'; @freezed class OrganicTweetMetrics with _$OrganicTweetMetrics { + @JsonSerializable(includeIfNull: false) const factory OrganicTweetMetrics({ /// A count of how many times the Tweet has been viewed /// (not unique by user). A view is counted if any part of the Tweet is diff --git a/lib/src/service/tweets/organic_tweet_metrics.freezed.dart b/lib/src/service/tweets/organic_tweet_metrics.freezed.dart index 53f476a6..08d0aa7b 100644 --- a/lib/src/service/tweets/organic_tweet_metrics.freezed.dart +++ b/lib/src/service/tweets/organic_tweet_metrics.freezed.dart @@ -178,7 +178,8 @@ class __$$_OrganicTweetMetricsCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_OrganicTweetMetrics implements _OrganicTweetMetrics { const _$_OrganicTweetMetrics( {required this.impressionCount, diff --git a/lib/src/service/tweets/organic_tweet_metrics.g.dart b/lib/src/service/tweets/organic_tweet_metrics.g.dart index 79f7c795..ee95851c 100644 --- a/lib/src/service/tweets/organic_tweet_metrics.g.dart +++ b/lib/src/service/tweets/organic_tweet_metrics.g.dart @@ -35,12 +35,21 @@ _$_OrganicTweetMetrics _$$_OrganicTweetMetricsFromJson(Map json) => ); Map _$$_OrganicTweetMetricsToJson( - _$_OrganicTweetMetrics instance) => - { - 'impression_count': instance.impressionCount, - 'like_count': instance.likeCount, - 'retweet_count': instance.retweetCount, - 'reply_count': instance.replyCount, - 'user_profile_clicks': instance.profileClickCount, - 'url_link_clicks': instance.linkClickCount, - }; + _$_OrganicTweetMetrics instance) { + final val = { + 'impression_count': instance.impressionCount, + 'like_count': instance.likeCount, + 'retweet_count': instance.retweetCount, + 'reply_count': instance.replyCount, + 'user_profile_clicks': instance.profileClickCount, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('url_link_clicks', instance.linkClickCount); + return val; +} diff --git a/lib/src/service/tweets/private_tweet_metrics.dart b/lib/src/service/tweets/private_tweet_metrics.dart index 91f588a8..cec33d5c 100644 --- a/lib/src/service/tweets/private_tweet_metrics.dart +++ b/lib/src/service/tweets/private_tweet_metrics.dart @@ -12,6 +12,7 @@ part 'private_tweet_metrics.g.dart'; @freezed class PrivateTweetMetrics with _$PrivateTweetMetrics { + @JsonSerializable(includeIfNull: false) const factory PrivateTweetMetrics({ /// A count of how many times the Tweet has been viewed /// (not unique by user). A view is counted if any part of the Tweet is diff --git a/lib/src/service/tweets/private_tweet_metrics.freezed.dart b/lib/src/service/tweets/private_tweet_metrics.freezed.dart index a77295ff..5899cb8c 100644 --- a/lib/src/service/tweets/private_tweet_metrics.freezed.dart +++ b/lib/src/service/tweets/private_tweet_metrics.freezed.dart @@ -132,7 +132,8 @@ class __$$_PrivateTweetMetricsCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_PrivateTweetMetrics implements _PrivateTweetMetrics { const _$_PrivateTweetMetrics( {required this.impressionCount, diff --git a/lib/src/service/tweets/private_tweet_metrics.g.dart b/lib/src/service/tweets/private_tweet_metrics.g.dart index ae85e3ea..a37a5023 100644 --- a/lib/src/service/tweets/private_tweet_metrics.g.dart +++ b/lib/src/service/tweets/private_tweet_metrics.g.dart @@ -29,9 +29,18 @@ _$_PrivateTweetMetrics _$$_PrivateTweetMetricsFromJson(Map json) => ); Map _$$_PrivateTweetMetricsToJson( - _$_PrivateTweetMetrics instance) => - { - 'impression_count': instance.impressionCount, - 'user_profile_clicks': instance.profileClickCount, - 'url_link_clicks': instance.linkClickCount, - }; + _$_PrivateTweetMetrics instance) { + final val = { + 'impression_count': instance.impressionCount, + 'user_profile_clicks': instance.profileClickCount, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('url_link_clicks', instance.linkClickCount); + return val; +} diff --git a/lib/src/service/tweets/promoted_tweet_metrics.dart b/lib/src/service/tweets/promoted_tweet_metrics.dart index 9d48945a..57e27644 100644 --- a/lib/src/service/tweets/promoted_tweet_metrics.dart +++ b/lib/src/service/tweets/promoted_tweet_metrics.dart @@ -12,6 +12,7 @@ part 'promoted_tweet_metrics.g.dart'; @freezed class PromotedTweetMetrics with _$PromotedTweetMetrics { + @JsonSerializable(includeIfNull: false) const factory PromotedTweetMetrics({ /// A count of how many times the Tweet has been viewed /// (not unique by user). A view is counted if any part of the Tweet is diff --git a/lib/src/service/tweets/promoted_tweet_metrics.freezed.dart b/lib/src/service/tweets/promoted_tweet_metrics.freezed.dart index 2c170acc..ddcd92ff 100644 --- a/lib/src/service/tweets/promoted_tweet_metrics.freezed.dart +++ b/lib/src/service/tweets/promoted_tweet_metrics.freezed.dart @@ -178,7 +178,8 @@ class __$$_PromotedTweetMetricsCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_PromotedTweetMetrics implements _PromotedTweetMetrics { const _$_PromotedTweetMetrics( {required this.impressionCount, diff --git a/lib/src/service/tweets/promoted_tweet_metrics.g.dart b/lib/src/service/tweets/promoted_tweet_metrics.g.dart index 340e1649..ddd2cb9c 100644 --- a/lib/src/service/tweets/promoted_tweet_metrics.g.dart +++ b/lib/src/service/tweets/promoted_tweet_metrics.g.dart @@ -35,12 +35,21 @@ _$_PromotedTweetMetrics _$$_PromotedTweetMetricsFromJson(Map json) => ); Map _$$_PromotedTweetMetricsToJson( - _$_PromotedTweetMetrics instance) => - { - 'impression_count': instance.impressionCount, - 'like_count': instance.likeCount, - 'retweet_count': instance.retweetCount, - 'reply_count': instance.replyCount, - 'user_profile_clicks': instance.profileClickCount, - 'url_link_clicks': instance.linkClickCount, - }; + _$_PromotedTweetMetrics instance) { + final val = { + 'impression_count': instance.impressionCount, + 'like_count': instance.likeCount, + 'retweet_count': instance.retweetCount, + 'reply_count': instance.replyCount, + 'user_profile_clicks': instance.profileClickCount, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('url_link_clicks', instance.linkClickCount); + return val; +} diff --git a/lib/src/service/tweets/tweet_attachments.dart b/lib/src/service/tweets/tweet_attachments.dart index a9b0b38b..c8095e42 100644 --- a/lib/src/service/tweets/tweet_attachments.dart +++ b/lib/src/service/tweets/tweet_attachments.dart @@ -10,6 +10,7 @@ part 'tweet_attachments.g.dart'; @freezed class TweetAttachments with _$TweetAttachments { + @JsonSerializable(includeIfNull: false) const factory TweetAttachments({ /// List of unique identifiers of media attached to this Tweet. These /// identifiers use the same media key format as those returned by the diff --git a/lib/src/service/tweets/tweet_attachments.freezed.dart b/lib/src/service/tweets/tweet_attachments.freezed.dart index e08efa76..68ba3f9f 100644 --- a/lib/src/service/tweets/tweet_attachments.freezed.dart +++ b/lib/src/service/tweets/tweet_attachments.freezed.dart @@ -117,7 +117,8 @@ class __$$_TweetAttachmentsCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_TweetAttachments implements _TweetAttachments { const _$_TweetAttachments( {final List? mediaKeys, final List? pollIds}) diff --git a/lib/src/service/tweets/tweet_attachments.g.dart b/lib/src/service/tweets/tweet_attachments.g.dart index 3a2c09d4..c3c9533b 100644 --- a/lib/src/service/tweets/tweet_attachments.g.dart +++ b/lib/src/service/tweets/tweet_attachments.g.dart @@ -23,8 +23,16 @@ _$_TweetAttachments _$$_TweetAttachmentsFromJson(Map json) => $checkedCreate( fieldKeyMap: const {'mediaKeys': 'media_keys', 'pollIds': 'poll_ids'}, ); -Map _$$_TweetAttachmentsToJson(_$_TweetAttachments instance) => - { - 'media_keys': instance.mediaKeys, - 'poll_ids': instance.pollIds, - }; +Map _$$_TweetAttachmentsToJson(_$_TweetAttachments instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('media_keys', instance.mediaKeys); + writeNotNull('poll_ids', instance.pollIds); + return val; +} diff --git a/lib/src/service/tweets/tweet_context_annotation.dart b/lib/src/service/tweets/tweet_context_annotation.dart index a1e6b7be..e8ee36af 100644 --- a/lib/src/service/tweets/tweet_context_annotation.dart +++ b/lib/src/service/tweets/tweet_context_annotation.dart @@ -10,6 +10,7 @@ part 'tweet_context_annotation.g.dart'; @freezed class TweetContextAnnotation with _$TweetContextAnnotation { + @JsonSerializable(includeIfNull: false) const factory TweetContextAnnotation({ /// Domain: Contains the numeric value of the domain. /// diff --git a/lib/src/service/tweets/tweet_context_annotation.freezed.dart b/lib/src/service/tweets/tweet_context_annotation.freezed.dart index 3893faf1..d7f9acac 100644 --- a/lib/src/service/tweets/tweet_context_annotation.freezed.dart +++ b/lib/src/service/tweets/tweet_context_annotation.freezed.dart @@ -129,7 +129,8 @@ class __$$_TweetContextAnnotationCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_TweetContextAnnotation implements _TweetContextAnnotation { const _$_TweetContextAnnotation( {required this.id, required this.name, this.description}); diff --git a/lib/src/service/tweets/tweet_context_annotation.g.dart b/lib/src/service/tweets/tweet_context_annotation.g.dart index 36c7c48c..46e6c9b2 100644 --- a/lib/src/service/tweets/tweet_context_annotation.g.dart +++ b/lib/src/service/tweets/tweet_context_annotation.g.dart @@ -23,9 +23,18 @@ _$_TweetContextAnnotation _$$_TweetContextAnnotationFromJson(Map json) => ); Map _$$_TweetContextAnnotationToJson( - _$_TweetContextAnnotation instance) => - { - 'id': instance.id, - 'name': instance.name, - 'description': instance.description, - }; + _$_TweetContextAnnotation instance) { + final val = { + 'id': instance.id, + 'name': instance.name, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('description', instance.description); + return val; +} diff --git a/lib/src/service/tweets/tweet_count_meta.dart b/lib/src/service/tweets/tweet_count_meta.dart index e4ca3aac..0879f575 100644 --- a/lib/src/service/tweets/tweet_count_meta.dart +++ b/lib/src/service/tweets/tweet_count_meta.dart @@ -15,6 +15,7 @@ part 'tweet_count_meta.g.dart'; @freezed class TweetCountMeta with _$TweetCountMeta implements ForwardPageable { + @JsonSerializable(includeIfNull: false) const factory TweetCountMeta({ /// Total count of the Tweets that match the query. @JsonKey(name: 'total_tweet_count') required int total, diff --git a/lib/src/service/tweets/tweet_count_meta.freezed.dart b/lib/src/service/tweets/tweet_count_meta.freezed.dart index 002efeed..027993ae 100644 --- a/lib/src/service/tweets/tweet_count_meta.freezed.dart +++ b/lib/src/service/tweets/tweet_count_meta.freezed.dart @@ -110,7 +110,8 @@ class __$$_TweetCountMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_TweetCountMeta implements _TweetCountMeta { const _$_TweetCountMeta( {@JsonKey(name: 'total_tweet_count') required this.total, diff --git a/lib/src/service/tweets/tweet_count_meta.g.dart b/lib/src/service/tweets/tweet_count_meta.g.dart index 2c96f5b1..e206acf1 100644 --- a/lib/src/service/tweets/tweet_count_meta.g.dart +++ b/lib/src/service/tweets/tweet_count_meta.g.dart @@ -24,8 +24,17 @@ _$_TweetCountMeta _$$_TweetCountMetaFromJson(Map json) => $checkedCreate( }, ); -Map _$$_TweetCountMetaToJson(_$_TweetCountMeta instance) => - { - 'total_tweet_count': instance.total, - 'next_token': instance.nextToken, - }; +Map _$$_TweetCountMetaToJson(_$_TweetCountMeta instance) { + final val = { + 'total_tweet_count': instance.total, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('next_token', instance.nextToken); + return val; +} diff --git a/lib/src/service/tweets/tweet_data.dart b/lib/src/service/tweets/tweet_data.dart index db911669..1b634d64 100644 --- a/lib/src/service/tweets/tweet_data.dart +++ b/lib/src/service/tweets/tweet_data.dart @@ -43,6 +43,7 @@ part 'tweet_data.g.dart'; /// tweet.fields when requesting additional fields to complete the object. @freezed class TweetData with _$TweetData implements Data { + @JsonSerializable(includeIfNull: false) const factory TweetData({ /// Unique identifier of this Tweet. This is returned as a string in order /// to avoid complications with languages and tools that cannot handle diff --git a/lib/src/service/tweets/tweet_data.freezed.dart b/lib/src/service/tweets/tweet_data.freezed.dart index 41bea880..8be62959 100644 --- a/lib/src/service/tweets/tweet_data.freezed.dart +++ b/lib/src/service/tweets/tweet_data.freezed.dart @@ -705,7 +705,8 @@ class __$$_TweetDataCopyWithImpl<$Res> extends _$TweetDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_TweetData implements _TweetData { const _$_TweetData( {required this.id, diff --git a/lib/src/service/tweets/tweet_data.g.dart b/lib/src/service/tweets/tweet_data.g.dart index ca22c82f..ee3886b7 100644 --- a/lib/src/service/tweets/tweet_data.g.dart +++ b/lib/src/service/tweets/tweet_data.g.dart @@ -117,33 +117,42 @@ _$_TweetData _$$_TweetDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_TweetDataToJson(_$_TweetData instance) => - { - 'id': instance.id, - 'text': instance.text, - 'author_id': instance.authorId, - 'in_reply_to_user_id': instance.inReplyToUserId, - 'conversation_id': instance.conversationId, - 'referenced_tweets': - instance.referencedTweets?.map((e) => e.toJson()).toList(), - 'context_annotations': - instance.contextAnnotations?.map((e) => e.toJson()).toList(), - 'entities': instance.entities?.toJson(), - 'attachments': instance.attachments?.toJson(), - 'non_public_metrics': instance.privateMetrics?.toJson(), - 'organic_metrics': instance.organicMetrics?.toJson(), - 'promoted_metrics': instance.promotedMetrics?.toJson(), - 'public_metrics': instance.publicMetrics?.toJson(), - 'geo': instance.geo?.toJson(), - 'lang': _$LanguageEnumMap[instance.lang], - 'possibly_sensitive': instance.isPossiblySensitive, - 'reply_settings': _$ReplySettingEnumMap[instance.replySetting], - 'source': instance.source, - 'edit_controls': instance.editControls?.toJson(), - 'edit_history_tweet_ids': instance.editHistoryTweetIds, - 'withheld': instance.withheld?.toJson(), - 'created_at': instance.createdAt?.toIso8601String(), - }; +Map _$$_TweetDataToJson(_$_TweetData instance) { + final val = { + 'id': instance.id, + 'text': instance.text, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('author_id', instance.authorId); + writeNotNull('in_reply_to_user_id', instance.inReplyToUserId); + writeNotNull('conversation_id', instance.conversationId); + writeNotNull('referenced_tweets', + instance.referencedTweets?.map((e) => e.toJson()).toList()); + writeNotNull('context_annotations', + instance.contextAnnotations?.map((e) => e.toJson()).toList()); + writeNotNull('entities', instance.entities?.toJson()); + writeNotNull('attachments', instance.attachments?.toJson()); + writeNotNull('non_public_metrics', instance.privateMetrics?.toJson()); + writeNotNull('organic_metrics', instance.organicMetrics?.toJson()); + writeNotNull('promoted_metrics', instance.promotedMetrics?.toJson()); + writeNotNull('public_metrics', instance.publicMetrics?.toJson()); + writeNotNull('geo', instance.geo?.toJson()); + writeNotNull('lang', _$LanguageEnumMap[instance.lang]); + writeNotNull('possibly_sensitive', instance.isPossiblySensitive); + writeNotNull('reply_settings', _$ReplySettingEnumMap[instance.replySetting]); + writeNotNull('source', instance.source); + writeNotNull('edit_controls', instance.editControls?.toJson()); + writeNotNull('edit_history_tweet_ids', instance.editHistoryTweetIds); + writeNotNull('withheld', instance.withheld?.toJson()); + writeNotNull('created_at', instance.createdAt?.toIso8601String()); + return val; +} const _$LanguageEnumMap = { Language.amharic: 'am', diff --git a/lib/src/service/tweets/tweet_entities.dart b/lib/src/service/tweets/tweet_entities.dart index b7f259ad..e686c09f 100644 --- a/lib/src/service/tweets/tweet_entities.dart +++ b/lib/src/service/tweets/tweet_entities.dart @@ -16,6 +16,7 @@ part 'tweet_entities.g.dart'; @freezed class TweetEntities with _$TweetEntities { + @JsonSerializable(includeIfNull: false) const factory TweetEntities({ /// Contains details about annotations relative to the text within a Tweet. List? annotations, diff --git a/lib/src/service/tweets/tweet_entities.freezed.dart b/lib/src/service/tweets/tweet_entities.freezed.dart index 4d13c76e..c9322fda 100644 --- a/lib/src/service/tweets/tweet_entities.freezed.dart +++ b/lib/src/service/tweets/tweet_entities.freezed.dart @@ -156,7 +156,8 @@ class __$$_TweetEntitiesCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_TweetEntities implements _TweetEntities { const _$_TweetEntities( {final List? annotations, diff --git a/lib/src/service/tweets/tweet_entities.g.dart b/lib/src/service/tweets/tweet_entities.g.dart index 5b2de788..2332d736 100644 --- a/lib/src/service/tweets/tweet_entities.g.dart +++ b/lib/src/service/tweets/tweet_entities.g.dart @@ -48,11 +48,20 @@ _$_TweetEntities _$$_TweetEntitiesFromJson(Map json) => $checkedCreate( }, ); -Map _$$_TweetEntitiesToJson(_$_TweetEntities instance) => - { - 'annotations': instance.annotations?.map((e) => e.toJson()).toList(), - 'hashtags': instance.hashtags?.map((e) => e.toJson()).toList(), - 'cashtags': instance.cashtags?.map((e) => e.toJson()).toList(), - 'mentions': instance.mentions?.map((e) => e.toJson()).toList(), - 'urls': instance.urls?.map((e) => e.toJson()).toList(), - }; +Map _$$_TweetEntitiesToJson(_$_TweetEntities instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull( + 'annotations', instance.annotations?.map((e) => e.toJson()).toList()); + writeNotNull('hashtags', instance.hashtags?.map((e) => e.toJson()).toList()); + writeNotNull('cashtags', instance.cashtags?.map((e) => e.toJson()).toList()); + writeNotNull('mentions', instance.mentions?.map((e) => e.toJson()).toList()); + writeNotNull('urls', instance.urls?.map((e) => e.toJson()).toList()); + return val; +} diff --git a/lib/src/service/tweets/tweet_meta.dart b/lib/src/service/tweets/tweet_meta.dart index 8921080d..d50272f4 100644 --- a/lib/src/service/tweets/tweet_meta.dart +++ b/lib/src/service/tweets/tweet_meta.dart @@ -13,6 +13,7 @@ part 'tweet_meta.g.dart'; @freezed class TweetMeta with _$TweetMeta implements Pageable { + @JsonSerializable(includeIfNull: false) const factory TweetMeta({ /// The Tweet ID of the most recent Tweet returned in the response. String? newestId, diff --git a/lib/src/service/tweets/tweet_meta.freezed.dart b/lib/src/service/tweets/tweet_meta.freezed.dart index f9ceb40f..c5c6b285 100644 --- a/lib/src/service/tweets/tweet_meta.freezed.dart +++ b/lib/src/service/tweets/tweet_meta.freezed.dart @@ -154,7 +154,8 @@ class __$$_TweetMetaCopyWithImpl<$Res> extends _$TweetMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_TweetMeta implements _TweetMeta { const _$_TweetMeta( {this.newestId, diff --git a/lib/src/service/tweets/tweet_meta.g.dart b/lib/src/service/tweets/tweet_meta.g.dart index fd517cb7..afe53ca3 100644 --- a/lib/src/service/tweets/tweet_meta.g.dart +++ b/lib/src/service/tweets/tweet_meta.g.dart @@ -30,11 +30,19 @@ _$_TweetMeta _$$_TweetMetaFromJson(Map json) => $checkedCreate( }, ); -Map _$$_TweetMetaToJson(_$_TweetMeta instance) => - { - 'newest_id': instance.newestId, - 'oldest_id': instance.oldestId, - 'result_count': instance.resultCount, - 'next_token': instance.nextToken, - 'previous_token': instance.previousToken, - }; +Map _$$_TweetMetaToJson(_$_TweetMeta instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('newest_id', instance.newestId); + writeNotNull('oldest_id', instance.oldestId); + writeNotNull('result_count', instance.resultCount); + writeNotNull('next_token', instance.nextToken); + writeNotNull('previous_token', instance.previousToken); + return val; +} diff --git a/lib/src/service/users/user_data.dart b/lib/src/service/users/user_data.dart index 6ac3626f..514e8ce1 100644 --- a/lib/src/service/users/user_data.dart +++ b/lib/src/service/users/user_data.dart @@ -31,6 +31,7 @@ part 'user_data.g.dart'; /// object. @freezed class UserData with _$UserData implements Data { + @JsonSerializable(includeIfNull: false) const factory UserData({ /// The unique identifier of this user. /// diff --git a/lib/src/service/users/user_data.freezed.dart b/lib/src/service/users/user_data.freezed.dart index f6dd2976..8f529386 100644 --- a/lib/src/service/users/user_data.freezed.dart +++ b/lib/src/service/users/user_data.freezed.dart @@ -388,7 +388,8 @@ class __$$_UserDataCopyWithImpl<$Res> extends _$UserDataCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_UserData implements _UserData { const _$_UserData( {required this.id, diff --git a/lib/src/service/users/user_data.g.dart b/lib/src/service/users/user_data.g.dart index 7ab7da6d..6c26c397 100644 --- a/lib/src/service/users/user_data.g.dart +++ b/lib/src/service/users/user_data.g.dart @@ -56,20 +56,29 @@ _$_UserData _$$_UserDataFromJson(Map json) => $checkedCreate( }, ); -Map _$$_UserDataToJson(_$_UserData instance) => - { - 'id': instance.id, - 'name': instance.name, - 'username': instance.username, - 'description': instance.description, - 'url': instance.url, - 'profile_image_url': instance.profileImageUrl, - 'location': instance.location, - 'protected': instance.isProtected, - 'verified': instance.isVerified, - 'pinned_tweet_id': instance.pinnedTweetId, - 'entities': instance.entities?.toJson(), - 'public_metrics': instance.publicMetrics?.toJson(), - 'created_at': instance.createdAt?.toIso8601String(), - 'withheld': instance.withheld?.toJson(), - }; +Map _$$_UserDataToJson(_$_UserData instance) { + final val = { + 'id': instance.id, + 'name': instance.name, + 'username': instance.username, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('description', instance.description); + writeNotNull('url', instance.url); + writeNotNull('profile_image_url', instance.profileImageUrl); + writeNotNull('location', instance.location); + writeNotNull('protected', instance.isProtected); + writeNotNull('verified', instance.isVerified); + writeNotNull('pinned_tweet_id', instance.pinnedTweetId); + writeNotNull('entities', instance.entities?.toJson()); + writeNotNull('public_metrics', instance.publicMetrics?.toJson()); + writeNotNull('created_at', instance.createdAt?.toIso8601String()); + writeNotNull('withheld', instance.withheld?.toJson()); + return val; +} diff --git a/lib/src/service/users/user_description_entity.dart b/lib/src/service/users/user_description_entity.dart index e14db69f..b2d30c1d 100644 --- a/lib/src/service/users/user_description_entity.dart +++ b/lib/src/service/users/user_description_entity.dart @@ -15,6 +15,7 @@ part 'user_description_entity.g.dart'; @freezed class UserDescriptionEntity with _$UserDescriptionEntity { + @JsonSerializable(includeIfNull: false) const factory UserDescriptionEntity({ /// Contains details about any URLs included in the user's description. List? urls, diff --git a/lib/src/service/users/user_description_entity.freezed.dart b/lib/src/service/users/user_description_entity.freezed.dart index f7f9bb11..c40f6ee5 100644 --- a/lib/src/service/users/user_description_entity.freezed.dart +++ b/lib/src/service/users/user_description_entity.freezed.dart @@ -143,7 +143,8 @@ class __$$_UserDescriptionEntityCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_UserDescriptionEntity implements _UserDescriptionEntity { const _$_UserDescriptionEntity( {final List? urls, diff --git a/lib/src/service/users/user_description_entity.g.dart b/lib/src/service/users/user_description_entity.g.dart index 6e907cc0..69b4b2c8 100644 --- a/lib/src/service/users/user_description_entity.g.dart +++ b/lib/src/service/users/user_description_entity.g.dart @@ -44,10 +44,18 @@ _$_UserDescriptionEntity _$$_UserDescriptionEntityFromJson(Map json) => ); Map _$$_UserDescriptionEntityToJson( - _$_UserDescriptionEntity instance) => - { - 'urls': instance.urls?.map((e) => e.toJson()).toList(), - 'hashtags': instance.hashtags?.map((e) => e.toJson()).toList(), - 'cashtags': instance.cashtags?.map((e) => e.toJson()).toList(), - 'mentions': instance.mentions?.map((e) => e.toJson()).toList(), - }; + _$_UserDescriptionEntity instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('urls', instance.urls?.map((e) => e.toJson()).toList()); + writeNotNull('hashtags', instance.hashtags?.map((e) => e.toJson()).toList()); + writeNotNull('cashtags', instance.cashtags?.map((e) => e.toJson()).toList()); + writeNotNull('mentions', instance.mentions?.map((e) => e.toJson()).toList()); + return val; +} diff --git a/lib/src/service/users/user_entities.dart b/lib/src/service/users/user_entities.dart index da202fa0..ae43e43a 100644 --- a/lib/src/service/users/user_entities.dart +++ b/lib/src/service/users/user_entities.dart @@ -14,6 +14,7 @@ part 'user_entities.g.dart'; @freezed class UserEntities with _$UserEntities { + @JsonSerializable(includeIfNull: false) const factory UserEntities({ /// Contains details about the user's profile website. UserUrlEntity? url, diff --git a/lib/src/service/users/user_entities.freezed.dart b/lib/src/service/users/user_entities.freezed.dart index 3aba29ef..0e6a0c70 100644 --- a/lib/src/service/users/user_entities.freezed.dart +++ b/lib/src/service/users/user_entities.freezed.dart @@ -137,7 +137,8 @@ class __$$_UserEntitiesCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_UserEntities implements _UserEntities { const _$_UserEntities({this.url, this.description}); diff --git a/lib/src/service/users/user_entities.g.dart b/lib/src/service/users/user_entities.g.dart index 9dbf75c9..9dd2487e 100644 --- a/lib/src/service/users/user_entities.g.dart +++ b/lib/src/service/users/user_entities.g.dart @@ -30,8 +30,16 @@ _$_UserEntities _$$_UserEntitiesFromJson(Map json) => $checkedCreate( }, ); -Map _$$_UserEntitiesToJson(_$_UserEntities instance) => - { - 'url': instance.url?.toJson(), - 'description': instance.description?.toJson(), - }; +Map _$$_UserEntitiesToJson(_$_UserEntities instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('url', instance.url?.toJson()); + writeNotNull('description', instance.description?.toJson()); + return val; +} diff --git a/lib/src/service/users/user_meta.dart b/lib/src/service/users/user_meta.dart index 38a32567..22d11aef 100644 --- a/lib/src/service/users/user_meta.dart +++ b/lib/src/service/users/user_meta.dart @@ -13,6 +13,7 @@ part 'user_meta.g.dart'; @freezed class UserMeta with _$UserMeta implements Pageable { + @JsonSerializable(includeIfNull: false) const factory UserMeta({ /// The number of users returned in this request. Note that this number /// may be lower than what was specified in the max_results query parameter. diff --git a/lib/src/service/users/user_meta.freezed.dart b/lib/src/service/users/user_meta.freezed.dart index 0206c2a8..f40c58e9 100644 --- a/lib/src/service/users/user_meta.freezed.dart +++ b/lib/src/service/users/user_meta.freezed.dart @@ -127,7 +127,8 @@ class __$$_UserMetaCopyWithImpl<$Res> extends _$UserMetaCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() + +@JsonSerializable(includeIfNull: false) class _$_UserMeta implements _UserMeta { const _$_UserMeta( {required this.resultCount, this.nextToken, this.previousToken}); diff --git a/lib/src/service/users/user_meta.g.dart b/lib/src/service/users/user_meta.g.dart index 9d212992..0234f46d 100644 --- a/lib/src/service/users/user_meta.g.dart +++ b/lib/src/service/users/user_meta.g.dart @@ -26,9 +26,18 @@ _$_UserMeta _$$_UserMetaFromJson(Map json) => $checkedCreate( }, ); -Map _$$_UserMetaToJson(_$_UserMeta instance) => - { - 'result_count': instance.resultCount, - 'next_token': instance.nextToken, - 'previous_token': instance.previousToken, - }; +Map _$$_UserMetaToJson(_$_UserMeta instance) { + final val = { + 'result_count': instance.resultCount, + }; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('next_token', instance.nextToken); + writeNotNull('previous_token', instance.previousToken); + return val; +} diff --git a/pubspec.yaml b/pubspec.yaml index 584d006e..e3dad0be 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: twitter_api_v2 description: The most famous and powerful Dart/Flutter library for Twitter API v2.0. -version: 4.4.2 +version: 4.4.3 repository: https://github.com/twitter-dart/twitter-api-v2 issue_tracker: https://github.com/twitter-dart/twitter-api-v2/issues diff --git a/test/mocks/mock.mocks.dart b/test/mocks/mock.mocks.dart index 1f5fbd6f..45547c6d 100644 --- a/test/mocks/mock.mocks.dart +++ b/test/mocks/mock.mocks.dart @@ -3,11 +3,8 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes - -// Dart imports: import 'dart:async' as _i4; -// Package imports: import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; import 'package:twitter_api_core/src/client/client_context.dart' as _i3; diff --git a/test/src/service/response/twitter_response_test.dart b/test/src/service/response/twitter_response_test.dart index f0424eb3..e828c5d8 100644 --- a/test/src/service/response/twitter_response_test.dart +++ b/test/src/service/response/twitter_response_test.dart @@ -88,88 +88,13 @@ void main() { ); expect(response.toJson(), { - 'data': { - 'id': 'test1', - 'text': 'test2', - 'author_id': null, - 'in_reply_to_user_id': null, - 'conversation_id': null, - 'referenced_tweets': null, - 'context_annotations': null, - 'entities': null, - 'attachments': null, - 'non_public_metrics': null, - 'organic_metrics': null, - 'promoted_metrics': null, - 'public_metrics': null, - 'geo': null, - 'lang': null, - 'possibly_sensitive': null, - 'reply_settings': null, - 'source': null, - 'edit_controls': null, - 'edit_history_tweet_ids': null, - 'withheld': null, - 'created_at': null - }, + 'data': {'id': 'test1', 'text': 'test2'}, 'includes': { 'tweets': [ - { - 'id': 'test1', - 'text': 'test2', - 'author_id': null, - 'in_reply_to_user_id': null, - 'conversation_id': null, - 'referenced_tweets': null, - 'context_annotations': null, - 'entities': null, - 'attachments': null, - 'non_public_metrics': null, - 'organic_metrics': null, - 'promoted_metrics': null, - 'public_metrics': null, - 'geo': null, - 'lang': null, - 'possibly_sensitive': null, - 'reply_settings': null, - 'source': null, - 'edit_controls': null, - 'edit_history_tweet_ids': null, - 'withheld': null, - 'created_at': null - }, - { - 'id': 'test3', - 'text': 'test4', - 'author_id': null, - 'in_reply_to_user_id': null, - 'conversation_id': null, - 'referenced_tweets': null, - 'context_annotations': null, - 'entities': null, - 'attachments': null, - 'non_public_metrics': null, - 'organic_metrics': null, - 'promoted_metrics': null, - 'public_metrics': null, - 'geo': null, - 'lang': null, - 'possibly_sensitive': null, - 'reply_settings': null, - 'source': null, - 'edit_controls': null, - 'edit_history_tweet_ids': null, - 'withheld': null, - 'created_at': null - } + {'id': 'test1', 'text': 'test2'}, + {'id': 'test3', 'text': 'test4'} ], - 'users': null, - 'media': null, - 'places': null, - 'polls': null, - 'topics': null - }, - 'meta': null, + } }); }); @@ -189,57 +114,9 @@ void main() { expect(response.toJson(), { 'data': [ - { - 'id': 'test1', - 'text': 'test2', - 'author_id': null, - 'in_reply_to_user_id': null, - 'conversation_id': null, - 'referenced_tweets': null, - 'context_annotations': null, - 'entities': null, - 'attachments': null, - 'non_public_metrics': null, - 'organic_metrics': null, - 'promoted_metrics': null, - 'public_metrics': null, - 'geo': null, - 'lang': null, - 'possibly_sensitive': null, - 'reply_settings': null, - 'source': null, - 'edit_controls': null, - 'edit_history_tweet_ids': null, - 'withheld': null, - 'created_at': null - }, - { - 'id': 'test3', - 'text': 'test4', - 'author_id': null, - 'in_reply_to_user_id': null, - 'conversation_id': null, - 'referenced_tweets': null, - 'context_annotations': null, - 'entities': null, - 'attachments': null, - 'non_public_metrics': null, - 'organic_metrics': null, - 'promoted_metrics': null, - 'public_metrics': null, - 'geo': null, - 'lang': null, - 'possibly_sensitive': null, - 'reply_settings': null, - 'source': null, - 'edit_controls': null, - 'edit_history_tweet_ids': null, - 'withheld': null, - 'created_at': null - } - ], - 'includes': null, - 'meta': null, + {'id': 'test1', 'text': 'test2'}, + {'id': 'test3', 'text': 'test4'} + ] }); }); });