kameleoon-client 0.9.0

Rust client SDK for feature experimentation and feature flags with Kameleoon.
use crate::client::KameleoonClient;
use kameleoon_core::{
    config::KameleoonClientConfig,
    core_factory::{CoreKameleoonClientFactory, ForgetParams},
    error::KameleoonError,
};

const SDK_NAME: &str = "RUST";
const SDK_VERSION: &str = env!("CARGO_PKG_VERSION");

pub struct KameleoonClientFactory;

impl KameleoonClientFactory {
    pub fn create_with_config(
        site_code: &str,
        config: KameleoonClientConfig,
    ) -> Result<KameleoonClient, KameleoonError> {
        CoreKameleoonClientFactory::create(site_code, None, Some(config), SDK_NAME, SDK_VERSION)
            .map(KameleoonClient::new)
    }

    pub fn create_with_file(site_code: &str, config_path: &str) -> Result<KameleoonClient, KameleoonError> {
        CoreKameleoonClientFactory::create(site_code, Some(config_path), None, SDK_NAME, SDK_VERSION)
            .map(KameleoonClient::new)
    }

    pub fn forget(site_code: &str) -> Result<(), KameleoonError> {
        CoreKameleoonClientFactory::forget(site_code)
    }

    pub fn forget_with_environment(site_code: &str, environment: &str) -> Result<(), KameleoonError> {
        CoreKameleoonClientFactory::forget_with_params(site_code, ForgetParams::Environment(environment))
    }
}