use reqwest::Method;
use super::types::{CodeRequest, DynamicResponse};
use crate::{Error, HttpClient, QueryParam};
pub struct InviteApi<'a> {
http: &'a HttpClient,
}
impl<'a> InviteApi<'a> {
pub fn new(http: &'a HttpClient) -> Self {
Self { http }
}
pub async fn list_my_codes(&self) -> Result<DynamicResponse, Error> {
self.http
.send_typed(Method::GET, "/invite/my-codes", &[], None, true)
.await
}
pub async fn redeem_invite(&self, request: &CodeRequest) -> Result<DynamicResponse, Error> {
let body = serde_json::to_value(request).expect("invite request is serializable");
self.http
.send_typed(Method::POST, "/invite/redeem", &[], Some(&body), true)
.await
}
pub async fn get_invite_status(&self, query: &[QueryParam]) -> Result<DynamicResponse, Error> {
self.http
.send_typed(Method::GET, "/invite/status", query, None, true)
.await
}
}