1use crate::config::{Config, SharedConfig};
2use crate::services::*;
3
4#[derive(Debug, Clone)]
16pub struct UseSendApiClient {
17 pub domains: DomainsSvc,
18 pub emails: EmailsSvc,
19 pub contact_books: ContactBooksSvc,
20 pub contacts: ContactsSvc,
21 pub campaigns: CampaignsSvc,
22}
23
24impl UseSendApiClient {
25 pub fn new(api_key: impl Into<String>) -> Self {
26 Self::from_config(Config::new(api_key))
27 }
28
29 pub fn with_base_url(api_key: impl Into<String>, base_url: impl Into<String>) -> Self {
30 Self::from_config(Config::new(api_key).with_base_url(base_url))
31 }
32
33 pub fn with_client(api_key: impl Into<String>, client: reqwest::Client) -> Self {
34 Self::from_config(Config::new(api_key).with_client(client))
35 }
36
37 pub fn from_config(config: Config) -> Self {
38 let shared = SharedConfig::new(config);
39 Self {
40 domains: DomainsSvc(shared.clone()),
41 emails: EmailsSvc(shared.clone()),
42 contact_books: ContactBooksSvc(shared.clone()),
43 contacts: ContactsSvc(shared.clone()),
44 campaigns: CampaignsSvc(shared),
45 }
46 }
47}