mailerlite_rs/
lib.rs

1use automation::Automation;
2use batch::Batch;
3use campaign::Campaign;
4use client::Client;
5use field::Field;
6use form::Form;
7use group::Group;
8use segment::Segment;
9use subscriber::Subscriber;
10use timezone::Timezone;
11use webhook::Webhook;
12
13pub mod automation;
14pub mod batch;
15pub mod campaign;
16pub mod client;
17pub mod data;
18pub mod field;
19pub mod form;
20pub mod group;
21pub mod parameter;
22pub mod response;
23pub mod segment;
24pub mod subscriber;
25pub mod timezone;
26pub mod webhook;
27
28const BASE_PATH: &str = "https://connect.mailerlite.com/api/";
29
30#[derive(Debug, Clone)]
31pub struct MailerLite {
32    client: Client,
33}
34
35impl MailerLite {
36    pub fn new(api_key: String) -> Self {
37        Self {
38            client: Client::new(api_key),
39        }
40    }
41
42    pub fn subscriber(&self) -> Subscriber {
43        Subscriber::new(self.clone())
44    }
45
46    pub fn campaign(&self) -> Campaign {
47        Campaign::new(self.clone())
48    }
49
50    pub fn group(&self) -> Group {
51        Group::new(self.clone())
52    }
53
54    pub fn segment(&self) -> Segment {
55        Segment::new(self.clone())
56    }
57
58    pub fn field(&self) -> Field {
59        Field::new(self.clone())
60    }
61
62    pub fn form(&self) -> Form {
63        Form::new(self.clone())
64    }
65
66    pub fn automation(&self) -> Automation {
67        Automation::new(self.clone())
68    }
69
70    pub fn webhook(&self) -> Webhook {
71        Webhook::new(self.clone())
72    }
73
74    pub fn batch(&self) -> Batch {
75        Batch::new(self.clone())
76    }
77
78    pub fn timezone(&self) -> Timezone {
79        Timezone::new(self.clone())
80    }
81}