Skip to content

Commit

Permalink
Merge #140
Browse files Browse the repository at this point in the history
140: feat: fixed for the issue (#37) 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 16, 2023
2 parents d7d79b1 + 6cd5e7f commit 6f01da2
Show file tree
Hide file tree
Showing 7 changed files with 1,293 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Note

## v0.5.3

- Supported `directory API methods`. ([#37](https://github.com/mastodon-dart/mastodon-api/issues/37))
- `GET /api/v1/directory`

## v0.5.2

- Internal processing when searching for data from multiple IDs has been corrected. ([#136](https://github.com/mastodon-dart/mastodon-api/issues/136))
Expand Down
1 change: 1 addition & 0 deletions lib/mastodon_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export 'package:mastodon_api/src/service/v1/accounts/account_profile_meta_param.
export 'package:mastodon_api/src/service/v1/accounts/accounts_v1_service.dart';
export 'package:mastodon_api/src/service/v1/accounts/post_privacy.dart';
export 'package:mastodon_api/src/service/v1/apps/apps_v1_service.dart';
export 'package:mastodon_api/src/service/v1/instance/instance_account_order.dart';
export 'package:mastodon_api/src/service/v1/instance/instance_v1_service.dart';
export 'package:mastodon_api/src/service/v1/notifications/notifications_v1_service.dart';
export 'package:mastodon_api/src/service/v1/statuses/status_poll_param.dart';
Expand Down
15 changes: 15 additions & 0 deletions lib/src/service/v1/instance/instance_account_order.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2023 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

import '../../../core/serializable.dart';

enum InstanceAccountOrder implements Serializable {
active('active'),
newbie('new');

@override
final String value;

const InstanceAccountOrder(this.value);
}
55 changes: 55 additions & 0 deletions lib/src/service/v1/instance/instance_v1_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import '../../../core/client/client_context.dart';
import '../../../core/client/user_context.dart';
import '../../base_service.dart';
import '../../entities/account.dart';
import '../../entities/announcement.dart';
import '../../entities/blocked_domain.dart';
import '../../entities/emoji.dart';
Expand All @@ -18,6 +19,7 @@ import '../../entities/status.dart';
import '../../entities/tag.dart';
import '../../entities/trends_link.dart';
import '../../response/mastodon_response.dart';
import 'instance_account_order.dart';

abstract class InstanceV1Service {
/// Returns the new instance of [InstanceV1Service].
Expand Down Expand Up @@ -313,6 +315,38 @@ abstract class InstanceV1Service {
///
/// - https://docs.joinmastodon.org/methods/custom_emojis/#get
Future<MastodonResponse<List<Emoji>>> lookupAvailableEmoji();

/// List accounts visible in the directory.
///
/// ## Parameters
///
/// - [offset]: Skip the first n results.
///
/// - [limit]: How many accounts to load. Defaults to 40 accounts.
/// Max 80 accounts.
///
/// - [order]: Use active to sort by most recently posted statuses (default)
/// or new to sort by most recently created profiles.
///
/// - [onlyLocal]: If true, returns only local accounts.
///
/// ## Endpoint Url
///
/// - GET /api/v1/directory HTTP/1.1
///
/// ## Authentication Methods
///
/// - Anonymous
///
/// ## Reference
///
/// - https://docs.joinmastodon.org/methods/directory/#get
Future<MastodonResponse<List<Account>>> lookupAccounts({
int? offset,
int? limit,
InstanceAccountOrder? order,
bool? onlyLocal,
});
}

class _InstanceV1Service extends BaseService implements InstanceV1Service {
Expand Down Expand Up @@ -496,4 +530,25 @@ class _InstanceV1Service extends BaseService implements InstanceV1Service {
),
dataBuilder: Emoji.fromJson,
);

@override
Future<MastodonResponse<List<Account>>> lookupAccounts({
int? offset,
int? limit,
InstanceAccountOrder? order,
bool? onlyLocal,
}) async =>
super.transformMultiDataResponse(
await super.get(
UserContext.anonymousOnly,
'/api/v1/directory',
queryParameters: {
'offset': offset,
'limit': limit,
'order': order,
'local': onlyLocal,
},
),
dataBuilder: Account.fromJson,
);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mastodon_api
description: The easiest and powerful Dart/Flutter library for Mastodon API.
version: 0.5.2
version: 0.5.3
repository: https://github.com/mastodon-dart/mastodon-api
issue_tracker: https://github.com/mastodon-dart/mastodon-api/issues

Expand Down

0 comments on commit 6f01da2

Please sign in to comment.