use base64::prelude::BASE64_STANDARD;
use base64::Engine;
use serde::Serialize;
#[derive(Serialize)]
pub struct DeviceToken {
#[serde(rename = "id")]
pub signature: String,
pub name: String,
#[serde(rename = "productId")]
pub product_id: String,
format: String,
}
impl DeviceToken {
pub fn new(signature: String, name: String, product_id: String) -> Self {
Self {
signature,
name,
product_id,
format: "JWT".into(),
}
}
pub fn serialize(&self) -> String {
BASE64_STANDARD.encode(serde_json::to_string(self).unwrap())
}
}