Skip to content

Commit

Permalink
feat: fixed for the issue (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
myConsciousness committed Nov 29, 2022
1 parent fb61628 commit e76192b
Show file tree
Hide file tree
Showing 16 changed files with 7,035 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"nullcast",
"nullcasted",
"Pageable",
"parentid",
"PKCE",
"Shinya",
"sublist",
Expand All @@ -30,6 +31,7 @@
"unliked",
"unmute",
"unmuted",
"woeid",
"writeln"
],
"files.trimTrailingWhitespace": true,
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Note

## v4.6.0

- Supported `Trends` service. ([#582](https://github.com/twitter-dart/twitter-api-v2/issues/582))
- `GET /1.1/trends/place.json`
- `GET /1.1/trends/available.json`
- `GET /1.1/trends/closest.json`

## v4.5.0

- Supported `Geo` service. ([#578](https://github.com/twitter-dart/twitter-api-v2/issues/578))
Expand Down
3 changes: 2 additions & 1 deletion lib/src/service/geo/geo_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// Package imports:
// Dart imports:
import 'dart:convert';

// Package imports:
import 'package:twitter_api_core/twitter_api_core.dart' as core;

// Project imports:
Expand Down
28 changes: 28 additions & 0 deletions lib/src/service/trends/trend_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2022 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// ignore_for_file: invalid_annotation_target

// Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

// Project imports:
import '../common/data.dart';

part 'trend_data.freezed.dart';
part 'trend_data.g.dart';

@freezed
class TrendData with _$TrendData implements Data {
@JsonSerializable(includeIfNull: false)
const factory TrendData({
/// The name of this trend.
///
/// It includes "#" as prefix if it's a hashtag trend.
required String name,
}) = _TrendData;

factory TrendData.fromJson(Map<String, Object?> json) =>
_$TrendDataFromJson(json);
}
156 changes: 156 additions & 0 deletions lib/src/service/trends/trend_data.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target

part of 'trend_data.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

TrendData _$TrendDataFromJson(Map<String, dynamic> json) {
return _TrendData.fromJson(json);
}

/// @nodoc
mixin _$TrendData {
/// The name of this trend.
///
/// It includes "#" as prefix if it's a hashtag trend.
String get name => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TrendDataCopyWith<TrendData> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $TrendDataCopyWith<$Res> {
factory $TrendDataCopyWith(TrendData value, $Res Function(TrendData) then) =
_$TrendDataCopyWithImpl<$Res>;
$Res call({String name});
}

/// @nodoc
class _$TrendDataCopyWithImpl<$Res> implements $TrendDataCopyWith<$Res> {
_$TrendDataCopyWithImpl(this._value, this._then);

final TrendData _value;
// ignore: unused_field
final $Res Function(TrendData) _then;

@override
$Res call({
Object? name = freezed,
}) {
return _then(_value.copyWith(
name: name == freezed
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
abstract class _$$_TrendDataCopyWith<$Res> implements $TrendDataCopyWith<$Res> {
factory _$$_TrendDataCopyWith(
_$_TrendData value, $Res Function(_$_TrendData) then) =
__$$_TrendDataCopyWithImpl<$Res>;
@override
$Res call({String name});
}

/// @nodoc
class __$$_TrendDataCopyWithImpl<$Res> extends _$TrendDataCopyWithImpl<$Res>
implements _$$_TrendDataCopyWith<$Res> {
__$$_TrendDataCopyWithImpl(
_$_TrendData _value, $Res Function(_$_TrendData) _then)
: super(_value, (v) => _then(v as _$_TrendData));

@override
_$_TrendData get _value => super._value as _$_TrendData;

@override
$Res call({
Object? name = freezed,
}) {
return _then(_$_TrendData(
name: name == freezed
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
@JsonSerializable(includeIfNull: false)
class _$_TrendData implements _TrendData {
const _$_TrendData({required this.name});

factory _$_TrendData.fromJson(Map<String, dynamic> json) =>
_$$_TrendDataFromJson(json);

/// The name of this trend.
///
/// It includes "#" as prefix if it's a hashtag trend.
@override
final String name;

@override
String toString() {
return 'TrendData(name: $name)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_TrendData &&
const DeepCollectionEquality().equals(other.name, name));
}

@JsonKey(ignore: true)
@override
int get hashCode =>
Object.hash(runtimeType, const DeepCollectionEquality().hash(name));

@JsonKey(ignore: true)
@override
_$$_TrendDataCopyWith<_$_TrendData> get copyWith =>
__$$_TrendDataCopyWithImpl<_$_TrendData>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$_TrendDataToJson(
this,
);
}
}

abstract class _TrendData implements TrendData {
const factory _TrendData({required final String name}) = _$_TrendData;

factory _TrendData.fromJson(Map<String, dynamic> json) =
_$_TrendData.fromJson;

@override

/// The name of this trend.
///
/// It includes "#" as prefix if it's a hashtag trend.
String get name;
@override
@JsonKey(ignore: true)
_$$_TrendDataCopyWith<_$_TrendData> get copyWith =>
throw _privateConstructorUsedError;
}
25 changes: 25 additions & 0 deletions lib/src/service/trends/trend_data.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions lib/src/service/trends/trending_location_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2022 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// ignore_for_file: invalid_annotation_target

// Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:twitter_api_core/twitter_api_core.dart';

// Project imports:
import '../common/data.dart';

part 'trending_location_data.freezed.dart';
part 'trending_location_data.g.dart';

@freezed
class TrendingLocationData with _$TrendingLocationData implements Data {
@JsonSerializable(includeIfNull: false)
const factory TrendingLocationData({
/// The identifier of location for trending topics.
@JsonKey(name: 'woeid') required int id,

/// The identifier for parent location.
@JsonKey(name: 'parentid') required int parentId,

/// The name of this location.
required String name,

/// The country name of this location.
@JsonKey(name: 'country') required String countryName,

/// The country code of this location.
@JsonKey(name: 'countryCode') required Country? country,
}) = _TrendingLocationData;

factory TrendingLocationData.fromJson(Map<String, Object?> json) =>
_$TrendingLocationDataFromJson(json);
}
Loading

0 comments on commit e76192b

Please sign in to comment.