freedom_api/
gateway_licenses.rs

1use freedom_models::gateway_licenses;
2
3use crate::{Api, error::Error};
4
5/// Extension API for interacting with the Freedom Gateway licensing architecture
6pub trait GatewayApi: Api {
7    fn get_all_gateway_licenses(
8        &self,
9    ) -> impl Future<Output = Result<gateway_licenses::View, Error>> + Send + Sync {
10        let uri = self.path_to_url("gateway-licenses");
11        self.get_json_map(uri)
12    }
13
14    fn get_all_gateway_license(
15        &self,
16        id: u32,
17    ) -> impl Future<Output = Result<gateway_licenses::ViewOne, Error>> + Send + Sync {
18        let uri = self.path_to_url(format!("gateway-licenses/{id}"));
19        self.get_json_map(uri)
20    }
21
22    fn verify_gateway_license(
23        &self,
24        request: gateway_licenses::Verify,
25    ) -> impl Future<Output = Result<gateway_licenses::VerifyResponse, Error>> + Send + Sync {
26        let uri = self.path_to_url("gateway-licenses/verify");
27        self.post_deserialize(uri, request)
28    }
29
30    fn regenerate_gateway_license(
31        &self,
32        id: u32,
33    ) -> impl Future<Output = Result<gateway_licenses::RegenerateResponse, Error>> + Send + Sync
34    {
35        let uri = self.path_to_url(format!("gateway-licenses/{id}/regenerate"));
36        self.post_deserialize(uri, serde_json::json!({}))
37    }
38}
39
40impl<T> GatewayApi for T where T: Api {}