Skip to content

Commit

Permalink
Merge #54
Browse files Browse the repository at this point in the history
54: feat: Added Spaces Search endpoint (#23) r=myConsciousness a=myConsciousness

# 1. Description

<!-- Provide a description of what this PR is doing.
If you're modifying existing behavior, describe the existing behavior, how this PR is changing it,
and what motivated the change. If this is a breaking change, specify explicitly which APIs have been
changed. -->

## 1.1. Checklist

<!-- Before you create this PR confirm that it meets all requirements listed below by checking the
relevant checkboxes (`[x]`). This will ensure a smooth and quick review process. -->

- [x] The title of my PR starts with a [Conventional Commit] prefix (`fix:`, `feat:`, `docs:` etc).
- [x] I have read the [Contributor Guide] and followed the process outlined for submitting PRs.
- [x] I have updated/added tests for ALL new/updated/fixed functionality.
- [x] I have updated/added relevant documentation in `docs` and added dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples`.

## 1.2. Breaking Change

<!-- Does your PR require users to manually update their apps to accommodate your change?

If the PR is a breaking change this should be indicated with suffix "!"  (for example, `feat!:`, `fix!:`). See [Conventional Commit] for details.
-->

- [ ] Yes, this is a breaking change.
- [x] No, this is _not_ a breaking change.

## 1.3. Related Issues

<!-- Provide a list of issues related to this PR from the [issue database].
Indicate which of these issues are resolved or fixed by this PR, i.e. Fixes #xxxx* !-->

<!-- Links -->

[issue database]: https://github.com/twitter-dart/twitter-api-v2/issues
[contributor guide]: https://github.com/twitter-dart/twitter-api-v2/blob/main/CONTRIBUTING.md
[style guide]: https://github.com/twitter-dart/twitter-api-v2/blob/main/STYLEGUIDE.md
[conventional commit]: https://conventionalcommits.org


Co-authored-by: myConsciousness <kato.shinya.dev@gmail.com>
  • Loading branch information
bors[bot] and myConsciousness authored May 3, 2022
2 parents 538719d + d548bde commit f6ac91e
Show file tree
Hide file tree
Showing 14 changed files with 520 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- GET /2/users/by
- GET /2/users/by/username/:username
- GET /2/users/me
- Added **Spaces Search** endpoints. ([#23](https://github.com/twitter-dart/twitter-api-v2/issues/23))
- GET /2/spaces/search

## v1.0.0

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void main() async {
2. [GET /2/tweets/counts/recent](https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent)

2. **Users**

1. **Follows**
1. [DELETE /2/users/:source_user_id/following/:target_user_id](https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/delete-users-source_id-following)
2. [GET /2/users/:id/followers](https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-followers)
Expand All @@ -163,6 +164,10 @@ void main() async {
4. [GET /2/users/by/username/:username](https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by-username-username)
5. [GET /2/users/me](https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me)

3. **Spaces**
1. **Search Spaces**
1. [GET /2/spaces/search](https://developer.twitter.com/en/docs/twitter-api/spaces/search/api-reference/get-spaces-search)

## 1.3. Contribution

If you would like to contribute to `twitter_api_v2`, please create an [issue](https://github.com/twitter-dart/twitter-api-v2/issues) or create a Pull Request.
Expand Down
23 changes: 23 additions & 0 deletions lib/src/service/spaces/space_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

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

// Project imports:
import 'package:twitter_api_v2/src/service/spaces/space_state.dart';

part 'space_data.freezed.dart';
part 'space_data.g.dart';

@freezed
class SpaceData with _$SpaceData {
const factory SpaceData({
required String id,
SpaceState? state,
}) = _SpaceData;

factory SpaceData.fromJson(Map<String, Object?> json) =>
_$SpaceDataFromJson(json);
}
161 changes: 161 additions & 0 deletions lib/src/service/spaces/space_data.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// 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 'space_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');

SpaceData _$SpaceDataFromJson(Map<String, dynamic> json) {
return _SpaceData.fromJson(json);
}

/// @nodoc
mixin _$SpaceData {
String get id => throw _privateConstructorUsedError;
SpaceState? get state => throw _privateConstructorUsedError;

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

/// @nodoc
abstract class $SpaceDataCopyWith<$Res> {
factory $SpaceDataCopyWith(SpaceData value, $Res Function(SpaceData) then) =
_$SpaceDataCopyWithImpl<$Res>;
$Res call({String id, SpaceState? state});
}

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

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

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

/// @nodoc
abstract class _$SpaceDataCopyWith<$Res> implements $SpaceDataCopyWith<$Res> {
factory _$SpaceDataCopyWith(
_SpaceData value, $Res Function(_SpaceData) then) =
__$SpaceDataCopyWithImpl<$Res>;
@override
$Res call({String id, SpaceState? state});
}

/// @nodoc
class __$SpaceDataCopyWithImpl<$Res> extends _$SpaceDataCopyWithImpl<$Res>
implements _$SpaceDataCopyWith<$Res> {
__$SpaceDataCopyWithImpl(_SpaceData _value, $Res Function(_SpaceData) _then)
: super(_value, (v) => _then(v as _SpaceData));

@override
_SpaceData get _value => super._value as _SpaceData;

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

/// @nodoc
@JsonSerializable()
class _$_SpaceData implements _SpaceData {
const _$_SpaceData({required this.id, this.state});

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

@override
final String id;
@override
final SpaceState? state;

@override
String toString() {
return 'SpaceData(id: $id, state: $state)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _SpaceData &&
const DeepCollectionEquality().equals(other.id, id) &&
const DeepCollectionEquality().equals(other.state, state));
}

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

@JsonKey(ignore: true)
@override
_$SpaceDataCopyWith<_SpaceData> get copyWith =>
__$SpaceDataCopyWithImpl<_SpaceData>(this, _$identity);

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

abstract class _SpaceData implements SpaceData {
const factory _SpaceData(
{required final String id, final SpaceState? state}) = _$_SpaceData;

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

@override
String get id => throw _privateConstructorUsedError;
@override
SpaceState? get state => throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)
_$SpaceDataCopyWith<_SpaceData> get copyWith =>
throw _privateConstructorUsedError;
}
33 changes: 33 additions & 0 deletions lib/src/service/spaces/space_data.g.dart

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

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

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

part 'space_meta.freezed.dart';
part 'space_meta.g.dart';

@freezed
class SpaceMeta with _$SpaceMeta {
const factory SpaceMeta({
@JsonKey(name: 'result_count') required int? resultCount,
}) = _SpaceMeta;

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

0 comments on commit f6ac91e

Please sign in to comment.