use reqwest::Method;
use super::types::{CodeRequest, DynamicResponse};
use crate::{Error, HttpClient};
pub struct CouponsApi<'a> {
http: &'a HttpClient,
}
impl<'a> CouponsApi<'a> {
pub fn new(http: &'a HttpClient) -> Self {
Self { http }
}
pub async fn list_my_coupons(&self) -> Result<DynamicResponse, Error> {
self.http
.send_typed(Method::GET, "/coupons/me", &[], None, true)
.await
}
pub async fn redeem_coupon(&self, request: &CodeRequest) -> Result<DynamicResponse, Error> {
let body = serde_json::to_value(request).expect("coupon request is serializable");
self.http
.send_typed(Method::POST, "/coupons/redeem", &[], Some(&body), true)
.await
}
}