Skip to content

Commit

Permalink
Merge #135
Browse files Browse the repository at this point in the history
135: feat: fixed for the issue (#51) 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/mastodon-dart/mastodon-api/issues
[contributor guide]: https://github.com/mastodon-dart/mastodon-api/blob/main/CONTRIBUTING.md
[style guide]: https://github.com/mastodon-dart/mastodon-api/blob/main/STYLEGUIDE.md
[conventional commit]: https://conventionalcommits.org


Co-authored-by: myConsciousness <contact@shinyakato.dev>
  • Loading branch information
bors[bot] and myConsciousness committed Feb 8, 2023
2 parents b420b42 + b2d9e09 commit 85ade11
Show file tree
Hide file tree
Showing 11 changed files with 644 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -7,6 +7,7 @@
"flac",
"iframe",
"Kato",
"oembed",
"quicktime",
"ratelimit",
"Reblog",
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@
- `GET /api/v1/follow_requests`
- `POST /api/v1/follow_requests/:account_id/authorize`
- `POST /api/v1/follow_requests/:account_id/reject`
- Added `oembed API methods`. ([#51](https://github.com/mastodon-dart/mastodon-api/issues/51))
- `GET /api/oembed`

## v0.5.0

Expand Down
2 changes: 2 additions & 0 deletions lib/mastodon_api.dart
Expand Up @@ -50,6 +50,7 @@ export 'package:mastodon_api/src/service/entities/media_attachment_type.dart';
export 'package:mastodon_api/src/service/entities/notification.dart';
export 'package:mastodon_api/src/service/entities/notification_snapshot.dart';
export 'package:mastodon_api/src/service/entities/notification_type.dart';
export 'package:mastodon_api/src/service/entities/oembed_metadata.dart';
export 'package:mastodon_api/src/service/entities/poll.dart';
export 'package:mastodon_api/src/service/entities/poll_option.dart';
export 'package:mastodon_api/src/service/entities/position_marker.dart';
Expand All @@ -75,6 +76,7 @@ export 'package:mastodon_api/src/service/entities/trends_link.dart';
export 'package:mastodon_api/src/service/entities/usage_statistics.dart';
export 'package:mastodon_api/src/service/mastodon_v1_service.dart';
export 'package:mastodon_api/src/service/mastodon_v2_service.dart';
export 'package:mastodon_api/src/service/oembed/oembed_service.dart';
export 'package:mastodon_api/src/service/response/mastodon_request.dart';
export 'package:mastodon_api/src/service/response/mastodon_response.dart';
export 'package:mastodon_api/src/service/v1/accounts/account_default_settings_param.dart';
Expand Down
15 changes: 15 additions & 0 deletions lib/src/mastodon_api.dart
Expand Up @@ -7,6 +7,7 @@ import 'core/client/client_context.dart';
import 'core/config/retry_config.dart';
import 'service/mastodon_v1_service.dart';
import 'service/mastodon_v2_service.dart';
import 'service/oembed/oembed_service.dart';

abstract class MastodonApi {
/// Returns the new instance of [MastodonApi].
Expand All @@ -28,6 +29,9 @@ abstract class MastodonApi {

/// Returns the v2 service.
MastodonV2Service get v2;

/// Returns the OEmbed service.
OEmbedService get oembed;
}

class _MastodonApi implements MastodonApi {
Expand All @@ -52,11 +56,22 @@ class _MastodonApi implements MastodonApi {
timeout: timeout,
retryConfig: retryConfig,
),
),
oembed = OEmbedService(
instance: instance,
context: ClientContext(
bearerToken: bearerToken,
timeout: timeout,
retryConfig: retryConfig,
),
);

@override
final MastodonV1Service v1;

@override
final MastodonV2Service v2;

@override
final OEmbedService oembed;
}
4 changes: 2 additions & 2 deletions lib/src/service/base_service.dart
Expand Up @@ -374,9 +374,9 @@ class RateLimitConverter {

String _getDateTimeString(final Map<String, String> input, final String key) {
if (!input.containsKey(key)) {
return DateTime.fromMillisecondsSinceEpoch(0).toIso8601String();
return DateTime.fromMillisecondsSinceEpoch(0).toLocal().toIso8601String();
}

return DateTime.parse(input[key]!).toIso8601String();
return DateTime.parse(input[key]!).toLocal().toIso8601String();
}
}
32 changes: 32 additions & 0 deletions lib/src/service/entities/oembed_metadata.dart
@@ -0,0 +1,32 @@
// Copyright 2023 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';

part 'oembed_metadata.freezed.dart';
part 'oembed_metadata.g.dart';

@freezed
class OEmbedMetadata with _$OEmbedMetadata {
@JsonSerializable(includeIfNull: false)
const factory OEmbedMetadata({
required String type,
required String version,
String? title,
required String authorName,
required String authorUrl,
required String providerName,
required String providerUrl,
required int cacheAge,
required String html,
required int width,
int? height,
}) = _OEmbedMetadata;

factory OEmbedMetadata.fromJson(Map<String, Object?> json) =>
_$OEmbedMetadataFromJson(json);
}

0 comments on commit 85ade11

Please sign in to comment.