-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add more api routes; refactor/rename
- Loading branch information
Showing
15 changed files
with
435 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
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,52 @@ | ||
#ifndef EKIZU_INVITE_HPP | ||
#define EKIZU_INVITE_HPP | ||
|
||
#include <ekizu/channel.hpp> | ||
#include <ekizu/guild.hpp> | ||
|
||
namespace ekizu { | ||
struct InviteChannel { | ||
Snowflake id; | ||
std::string name; | ||
ChannelType type; | ||
}; | ||
|
||
EKIZU_EXPORT void to_json(nlohmann::json &j, const InviteChannel &i); | ||
EKIZU_EXPORT void from_json(const nlohmann::json &j, InviteChannel &i); | ||
|
||
struct InviteGuild { | ||
Snowflake id; | ||
std::string name; | ||
std::optional<std::string> splash; | ||
std::optional<std::string> banner; | ||
std::optional<std::string> description; | ||
std::optional<std::string> icon; | ||
std::vector<GuildFeature> features; | ||
VerificationLevel verification_level; | ||
std::optional<std::string> vanity_url_code; | ||
NSFWLevel nsfw_level; | ||
uint64_t premium_subscription_count; | ||
}; | ||
|
||
EKIZU_EXPORT void to_json(nlohmann::json &j, const InviteGuild &i); | ||
EKIZU_EXPORT void from_json(const nlohmann::json &j, InviteGuild &i); | ||
|
||
enum class TargetType : uint8_t { Stream = 1, EmbeddedApplication = 2 }; | ||
|
||
struct Invite { | ||
std::string code; | ||
std::optional<InviteGuild> guild; | ||
InviteChannel channel; | ||
std::optional<User> inviter; | ||
TargetType target_type; | ||
std::optional<User> target_user; | ||
std::optional<uint64_t> approximate_presence_count; | ||
std::optional<uint64_t> approximate_member_count; | ||
std::optional<std::string> expires_at; | ||
}; | ||
|
||
EKIZU_EXPORT void to_json(nlohmann::json &j, const Invite &i); | ||
EKIZU_EXPORT void from_json(const nlohmann::json &j, Invite &i); | ||
} // namespace ekizu | ||
|
||
#endif // EKIZU_INVITE_HPP |
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,26 @@ | ||
#ifndef EKIZU_REQUEST_DELETE_ALL_REACTIONS_HPP | ||
#define EKIZU_REQUEST_DELETE_ALL_REACTIONS_HPP | ||
|
||
#include <ekizu/request/create_reaction.hpp> | ||
|
||
namespace ekizu { | ||
struct DeleteAllReactions { | ||
DeleteAllReactions( | ||
const std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> &make_request, | ||
Snowflake channel_id, Snowflake message_id); | ||
|
||
operator net::HttpRequest() const; | ||
|
||
Result<void> send(const asio::yield_context &yield) const; | ||
|
||
private: | ||
Snowflake m_channel_id; | ||
Snowflake m_message_id; | ||
std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> | ||
m_make_request; | ||
}; | ||
} // namespace ekizu | ||
|
||
#endif // EKIZU_REQUEST_DELETE_ALL_REACTIONS_HPP |
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,27 @@ | ||
#ifndef EKIZU_REQUEST_DELETE_ALL_REACTIONS_FOR_EMOJI_HPP | ||
#define EKIZU_REQUEST_DELETE_ALL_REACTIONS_FOR_EMOJI_HPP | ||
|
||
#include <ekizu/request/create_reaction.hpp> | ||
|
||
namespace ekizu { | ||
struct DeleteAllReactionsForEmoji { | ||
DeleteAllReactionsForEmoji( | ||
const std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> &make_request, | ||
Snowflake channel_id, Snowflake message_id, RequestReaction emoji); | ||
|
||
operator net::HttpRequest() const; | ||
|
||
Result<void> send(const asio::yield_context &yield) const; | ||
|
||
private: | ||
Snowflake m_channel_id; | ||
RequestReaction m_emoji; | ||
Snowflake m_message_id; | ||
std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> | ||
m_make_request; | ||
}; | ||
} // namespace ekizu | ||
|
||
#endif // EKIZU_REQUEST_DELETE_ALL_REACTIONS_FOR_EMOJI_HPP |
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,27 @@ | ||
#ifndef EKIZU_REQUEST_EDIT_CHANNEL_PERMISSIONS_HPP | ||
#define EKIZU_REQUEST_EDIT_CHANNEL_PERMISSIONS_HPP | ||
|
||
#include <ekizu/channel.hpp> | ||
#include <ekizu/http.hpp> | ||
|
||
namespace ekizu { | ||
struct EditChannelPermissions { | ||
EditChannelPermissions( | ||
const std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> &make_request, | ||
Snowflake channel_id, PermissionOverwrite overwrite); | ||
|
||
operator net::HttpRequest() const; | ||
|
||
Result<> send(const asio::yield_context &yield) const; | ||
|
||
private: | ||
Snowflake m_channel_id; | ||
PermissionOverwrite m_overwrite; | ||
std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> | ||
m_make_request; | ||
}; | ||
} // namespace ekizu | ||
|
||
#endif // EKIZU_REQUEST_EDIT_CHANNEL_PERMISSIONS_HPP |
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,27 @@ | ||
#ifndef EKIZU_REQUEST_GET_CHANNEL_INVITES_HPP | ||
#define EKIZU_REQUEST_GET_CHANNEL_INVITES_HPP | ||
|
||
#include <ekizu/http.hpp> | ||
#include <ekizu/invite.hpp> | ||
|
||
namespace ekizu { | ||
struct GetChannelInvites { | ||
GetChannelInvites( | ||
const std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> &make_request, | ||
Snowflake channel_id); | ||
|
||
operator net::HttpRequest() const; | ||
|
||
[[nodiscard]] Result<std::vector<Invite>> send( | ||
const asio::yield_context &yield) const; | ||
|
||
private: | ||
Snowflake m_channel_id; | ||
std::function<Result<net::HttpResponse>( | ||
net::HttpRequest, const asio::yield_context &)> | ||
m_make_request; | ||
}; | ||
} // namespace ekizu | ||
|
||
#endif // EKIZU_REQUEST_GET_CHANNEL_INVITES_HPP |
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
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,69 @@ | ||
#include <ekizu/invite.hpp> | ||
#include <ekizu/json_util.hpp> | ||
|
||
namespace ekizu { | ||
using json_util::deserialize; | ||
using json_util::serialize; | ||
|
||
void to_json(nlohmann::json &j, const InviteChannel &i) { | ||
serialize(j, "id", i.id); | ||
serialize(j, "name", i.name); | ||
serialize(j, "type", i.type); | ||
} | ||
|
||
void from_json(const nlohmann::json &j, InviteChannel &i) { | ||
deserialize(j, "id", i.id); | ||
deserialize(j, "name", i.name); | ||
deserialize(j, "type", i.type); | ||
} | ||
|
||
void to_json(nlohmann::json &j, const InviteGuild &i) { | ||
serialize(j, "id", i.id); | ||
serialize(j, "name", i.name); | ||
serialize(j, "splash", i.splash); | ||
serialize(j, "banner", i.banner); | ||
serialize(j, "description", i.description); | ||
serialize(j, "icon", i.icon); | ||
serialize(j, "features", i.features); | ||
serialize(j, "verification_level", i.verification_level); | ||
serialize(j, "vanity_url_code", i.vanity_url_code); | ||
serialize(j, "nsfw_level", i.nsfw_level); | ||
serialize(j, "premium_subscription_count", i.premium_subscription_count); | ||
} | ||
|
||
void from_json(const nlohmann::json &j, InviteGuild &i) { | ||
deserialize(j, "id", i.id); | ||
deserialize(j, "name", i.name); | ||
deserialize(j, "splash", i.splash); | ||
deserialize(j, "banner", i.banner); | ||
deserialize(j, "description", i.description); | ||
deserialize(j, "icon", i.icon); | ||
deserialize(j, "features", i.features); | ||
deserialize(j, "verification_level", i.verification_level); | ||
deserialize(j, "vanity_url_code", i.vanity_url_code); | ||
deserialize(j, "nsfw_level", i.nsfw_level); | ||
deserialize(j, "premium_subscription_count", i.premium_subscription_count); | ||
} | ||
|
||
void to_json(nlohmann::json &j, const Invite &i) { | ||
serialize(j, "code", i.code); | ||
serialize(j, "guild", i.guild); | ||
serialize(j, "channel", i.channel); | ||
serialize(j, "inviter", i.inviter); | ||
serialize(j, "target_user", i.target_user); | ||
serialize(j, "approximate_presence_count", i.approximate_presence_count); | ||
serialize(j, "approximate_member_count", i.approximate_member_count); | ||
serialize(j, "expires_at", i.expires_at); | ||
} | ||
|
||
void from_json(const nlohmann::json &j, Invite &i) { | ||
deserialize(j, "code", i.code); | ||
deserialize(j, "guild", i.guild); | ||
deserialize(j, "channel", i.channel); | ||
deserialize(j, "inviter", i.inviter); | ||
deserialize(j, "target_user", i.target_user); | ||
deserialize(j, "approximate_presence_count", i.approximate_presence_count); | ||
deserialize(j, "approximate_member_count", i.approximate_member_count); | ||
deserialize(j, "expires_at", i.expires_at); | ||
} | ||
} // namespace ekizu |
Oops, something went wrong.