Function api_config_from_env
pub fn api_config_from_env() -> Result<(FinamApiConfig, Option<String>), FinamError>Expand description
Reads the config from environment variables. Meant for examples and live tests.
Variables:
FINAM_SECRET(required): the API secret.FINAM_API_URL(optional): another endpoint instead of the production one. It must start withhttps://: the address of a local imitation is set in code withFinamApiConfig::with_endpoint.FINAM_ACCOUNT_ID(optional): returned as the second value, for user data connectors.
§Errors
[FinamError::Config] when FINAM_SECRET is not set, or FINAM_API_URL is set and is not an
https:// address. Nothing is sent to the network here.
§Examples
use brokapi_finam::api_config_from_env;
// Without FINAM_SECRET the call fails and says which variable is missing.
if std::env::var_os("FINAM_SECRET").is_none() {
let err = api_config_from_env().unwrap_err();
assert!(err.to_string().contains("FINAM_SECRET"));
}