fundamentum_edge_mcu_http_client/
fundamentum_api.rs

1//! User facing structure to make calls to the Fundamentum API.
2
3use crate::{http_client_config::HttpClientConfig, HttpClient, HttpHandler};
4
5use super::{
6    api_version::{ApiVersion, V3},
7    provisioning_api::ProvisioningApi,
8};
9
10/// User facing structure to make calls to the Fundamentum API.
11///
12/// This may be used within a user application to register a device, provision
13/// it, and other actions available via the Fundamentum API ([swagger]).
14///
15/// [swagger]: https://devices.fundamentum-iot.com/api/v3/docs/#/Provisioning
16pub struct FundamentumApi<'a, V: ApiVersion, H: HttpHandler> {
17    client: HttpClient<'a, V, H>,
18}
19
20impl<'a, H: HttpHandler> FundamentumApi<'a, V3, H> {
21    /// Create a new structure to access Fundamentum's API with a type safe
22    /// interface.
23    #[must_use]
24    pub fn new(config: HttpClientConfig<'a>, http_handler: H) -> Self {
25        let client = HttpClient::new(config, http_handler);
26
27        Self { client }
28    }
29
30    /// Get the Provisioning API.
31    #[must_use]
32    pub const fn provisioning_api(&self) -> ProvisioningApi<V3, H> {
33        ProvisioningApi::new(&self.client)
34    }
35
36    /// Return the [`HttpClient`] used internally. This allows the
37    /// flexibility to use the client to make other requests not supported
38    /// by this crate, however known to exist.
39    #[must_use]
40    pub const fn get_http_client(&self) -> &HttpClient<'a, V3, H> {
41        &self.client
42    }
43}