refactor: adapters configured from config crate
This commit is contained in:
@@ -4,6 +4,7 @@ version = "0.1.0"
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
config = { workspace = true }
|
||||
domain = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -7,9 +7,11 @@ pub struct TmdbEnrichmentClient {
|
||||
}
|
||||
|
||||
impl TmdbEnrichmentClient {
|
||||
pub fn from_env() -> Result<Self, DomainError> {
|
||||
let api_key = std::env::var("TMDB_API_KEY")
|
||||
.map_err(|_| DomainError::InfrastructureError("TMDB_API_KEY is not set".into()))?;
|
||||
pub fn from_config(config: &config::MetadataConfig) -> Result<Self, DomainError> {
|
||||
let api_key = config
|
||||
.tmdb_api_key
|
||||
.clone()
|
||||
.ok_or_else(|| DomainError::InfrastructureError("TMDB_API_KEY is not set".into()))?;
|
||||
Ok(Self {
|
||||
api_key,
|
||||
http: reqwest::Client::new(),
|
||||
|
||||
Reference in New Issue
Block a user