-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from mineral-dart/feat-implement-http-endpoin…
…t-repository feat: implement http endpoint repositories
- Loading branch information
Showing
16 changed files
with
1,205 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
lib/internal/services/http/discord_endpoint_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:mineral/internal/services/http/repositories/audit_log_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/auto_moderation_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/channel_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/emoji_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/guild_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/guild_scheduled_event_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/guild_template_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/invite_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/state_instance_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/sticker_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/user_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/voice_repository.dart'; | ||
import 'package:mineral/internal/services/http/repositories/webhook_repository.dart'; | ||
|
||
final class DiscordEndpointRepository { | ||
/// Get [Channel] endpoints | ||
final ChannelRepository channels = ChannelRepository(); | ||
|
||
/// Get [Emoji] endpoints | ||
final EmojiRepository emojis = EmojiRepository(); | ||
|
||
/// Get [AutoModeration] endpoints | ||
final AutoModerationRepository moderation = AutoModerationRepository(); | ||
|
||
/// Get [AuditLog] endpoints | ||
final AuditLogRepository auditLogs = AuditLogRepository(); | ||
|
||
/// Get [Guild] endpoints | ||
final GuildRepository guilds = GuildRepository(); | ||
|
||
/// Get [ScheduledEvent] endpoints | ||
final GuildScheduledEventRepository scheduledEvents = GuildScheduledEventRepository(); | ||
|
||
/// Get [GuildTemplate] endpoints | ||
final GuildTemplateRepository templates = GuildTemplateRepository(); | ||
|
||
/// Get [Invite] endpoints | ||
final InviteRepository invites = InviteRepository(); | ||
|
||
/// Get [StageInstance] endpoints | ||
final StageInstanceRepository stageInstances = StageInstanceRepository(); | ||
|
||
/// Get [Sticker] endpoints | ||
final StickerRepository stickers = StickerRepository(); | ||
|
||
/// Get [User] endpoints | ||
final UserRepository users = UserRepository(); | ||
|
||
/// Get [Voice] endpoints | ||
final VoiceRepository voice = VoiceRepository(); | ||
|
||
/// Get [Webhook] endpoints | ||
final WebhookRepository webhooks = WebhookRepository(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
lib/internal/services/http/repositories/audit_log_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// [AuditLog] repository | ||
/// | ||
/// Related to the official [Discord API documentation](https://discord.com/developers/docs/resources/audit-log) | ||
final class AuditLogRepository { | ||
/// Get audit log | ||
/// Related [official documentation](https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log) | ||
/// ```dart | ||
/// final uri = http.endpoints.auditLogs.get('1234'); | ||
/// ``` | ||
String get({ required String guildId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'audit-logs']).path; | ||
} |
42 changes: 42 additions & 0 deletions
42
lib/internal/services/http/repositories/auto_moderation_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/// Repository for the [AutoModeration] | ||
/// | ||
/// Related [official documentation](https://discord.com/developers/docs/resources/auto-moderation) | ||
final class AutoModerationRepository { | ||
/// Returns a list of [AutoModeration] objects for the given [Guild]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild) documentation | ||
/// ```dart | ||
/// final moderation = await client.moderation.list(guildId: '1234567890'); | ||
/// ``` | ||
String list({ required String guildId }) => Uri(pathSegments: ['guilds', guildId, 'auto-moderation', 'rules']).path; | ||
|
||
/// Returns an [AutoModeration] object for the given [Guild] and rule IDs. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule) documentation | ||
/// ```dart | ||
/// final moderation = await client.moderation.get(guildId: '1234567890', ruleId: '1234567890'); | ||
/// ``` | ||
String get({ required String guildId, required String ruleId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'auto-moderation', 'rules', ruleId]).path; | ||
|
||
/// Create a new [AutoModeration] for the given [Guild]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule) documentation | ||
/// ```dart | ||
/// final moderation = await client.moderation.create(guildId: '1234567890', ruleId: '1234567890'); | ||
/// ``` | ||
String create({ required String guildId }) => Uri(pathSegments: ['guilds', guildId, 'auto-moderation', 'rules']).path; | ||
|
||
/// Modify the given [AutoModeration]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule) documentation | ||
/// ```dart | ||
/// final moderation = await client.moderation.update(guildId: '1234567890', ruleId: '1234567890'); | ||
/// ``` | ||
String update({ required String guildId, required String ruleId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'auto-moderation', 'rules', ruleId]).path; | ||
|
||
/// Delete the given [AutoModeration]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule) documentation | ||
/// ```dart | ||
/// final moderation = await client.moderation.delete(guildId: '1234567890', ruleId: '1234567890'); | ||
/// ``` | ||
String delete({ required String guildId, required String ruleId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'auto-moderation', 'rules', ruleId]).path; | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/internal/services/http/repositories/channel_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
final class ChannelRepository { | ||
/// Get one channel from Discord API. | ||
/// Related [official documentation](https://discord.com/developers/docs/resources/channel#get-channel) | ||
/// ```dart | ||
/// final uri = http.endpoints.channels.one('1234'); | ||
/// ``` | ||
String one({ required String channelId }) => | ||
Uri(pathSegments: ['channels', channelId]).path; | ||
|
||
/// Update one channel from Discord API. | ||
/// Related [official documentation](https://discord.com/developers/docs/resources/channel#modify-channel) | ||
/// ```dart | ||
/// final uri = http.endpoints.channels.update('1234'); | ||
/// ``` | ||
String update({ required String channelId }) => | ||
Uri(pathSegments: ['channels', channelId]).path; | ||
|
||
/// Delete one channel from Discord API. | ||
/// Related [official documentation](https://discord.com/developers/docs/resources/channel#deleteclose-channel) | ||
/// ```dart | ||
/// final uri = http.endpoints.channels.delete('1234'); | ||
/// ``` | ||
String delete({ required String channelId }) => | ||
Uri(pathSegments: ['channels', channelId]).path; | ||
} |
43 changes: 43 additions & 0 deletions
43
lib/internal/services/http/repositories/emoji_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/// Repository for the [Emoji] resource. | ||
/// Related official documentation: https://discord.com/developers/docs/resources/emoji | ||
final class EmojiRepository { | ||
/// Returns a list of [Emoji] objects for the given [Guild]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/emoji#list-guild-emojis) documentation | ||
/// ```dart | ||
/// final emojis = await http.endpoints.emojis.list(guildId: '1234567890'); | ||
/// ``` | ||
String list({ required String guildId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'emojis']).path; | ||
|
||
/// Returns an [Emoji] object for the given [Guild] and emoji IDs. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/emoji#get-guild-emoji) documentation | ||
/// ```dart | ||
/// final emoji = await http.endpoints.emojis.get(guildId: '1234567890', emojiId: '1234567890'); | ||
/// ``` | ||
String get({ required String guildId, required String emojiId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'emojis', emojiId]).path; | ||
|
||
/// Create a new [Emoji] for the given [Guild]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/emoji#create-guild-emoji) documentation | ||
/// ```dart | ||
/// final emoji = await http.endpoints.emojis.create(guildId: '1234567890', emojiId: '1234567890'); | ||
/// ``` | ||
String create({ required String guildId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'emojis']).path; | ||
|
||
/// Modify the given [Emoji]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/emoji#modify-guild-emoji) documentation | ||
/// ```dart | ||
/// final emoji = await http.endpoints.emojis.update(guildId: '1234567890', emojiId: '1234567890'); | ||
/// ``` | ||
String update({ required String guildId, required String emojiId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'emojis', emojiId]).path; | ||
|
||
/// Delete the given [Emoji]. | ||
/// Related to the official [Discord API](https://discord.com/developers/docs/resources/emoji#delete-guild-emoji) documentation | ||
/// ```dart | ||
/// final emoji = await http.endpoints.emojis.delete(guildId: '1234567890', emojiId: '1234567890'); | ||
/// ``` | ||
String delete({ required String guildId, required String emojiId }) => | ||
Uri(pathSegments: ['guilds', guildId, 'emojis', emojiId]).path; | ||
} |
Oops, something went wrong.