initial api impl
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "spoticord_api_grpc"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bytes = "1.6.0"
|
||||
tonic = "0.12.3"
|
||||
prost = "0.13.3"
|
||||
tokio = {version = "1.38.0", features = ["io-util", "test-util"]}
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.12.3"
|
||||
@@ -0,0 +1,6 @@
|
||||
use std::io::Result;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
tonic_build::configure().compile_protos(&["src/service.proto"], &["src/"])?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
pub mod spoticord_api {
|
||||
pub mod service {
|
||||
include!(concat!(env!("OUT_DIR"), "/spoticord_api.service.rs"));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::spoticord_api::service::{PlayModes, PlayPlaylistRequest};
|
||||
|
||||
#[test]
|
||||
fn test_build_play_playlist() {
|
||||
let play_playlist = PlayPlaylistRequest {
|
||||
order: PlayModes::InOrder.into(),
|
||||
playlist_uri: "test".to_string(),
|
||||
};
|
||||
|
||||
assert_eq!(play_playlist.playlist_uri, "test");
|
||||
assert_eq!(play_playlist.order, PlayModes::InOrder.into());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package spoticord_api.service;
|
||||
|
||||
|
||||
enum PlayModes {
|
||||
SHUFFLE = 0;
|
||||
IN_ORDER = 1;
|
||||
}
|
||||
|
||||
message PlayPlaylistRequest {
|
||||
uint64 discord_user_id = 1;
|
||||
PlayModes order = 2;
|
||||
string playlist_uri = 3;
|
||||
}
|
||||
|
||||
enum Error {
|
||||
SpotifyError = 0;
|
||||
BotError = 1;
|
||||
UserNotRegistered = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
oneof resp {
|
||||
bool success = 1;
|
||||
Error error = 2;
|
||||
}
|
||||
}
|
||||
|
||||
service SpoticordApi {
|
||||
rpc PlayPlaylist(PlayPlaylistRequest) returns (Response);
|
||||
}
|
||||
Reference in New Issue
Block a user