1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! MailGun API client written in Rust.
//!
//! This crate helps facilitate interacting with the MailGun API. You will need
//! to supply both an *API Key* and *Domain*.
//!
//! [API Reference](https://documentation.mailgun.com/en/latest/api_reference.html)
//!
//! ### Send a Message
//!
//! ```no_run
//! use mailgun_sdk::{
//! Client,
//! ParamList,
//! send_message::{SendMessageParam, SendMessageParamList},
//! };
//! let client = Client::new("ApiKey", "Domain");
//!
//! let params = SendMessageParamList::default()
//! .add(SendMessageParam::To("to@test.com"))
//! .add(SendMessageParam::From("from@your-domain.com"))
//! .add(SendMessageParam::Subject("Test Message"))
//! .add(SendMessageParam::Html(r#"<html>
//! <body>
//! <h1>Test Message</h1>
//! </body>
//! </html>"#));
//!
//! if let Err(error) = client.send_message(params) {
//! eprintln!("Error: {:?}", error);
//! }
//! ```
//!
//! This crate does not enforce rules on sending messages. However, you should
//! almost always set the following when sending a message:
//!
//! - **Subject**
//! - **To**
//! - **From**
//! - **Html** _and/or_ **Text**
//!
//! **Caution:** Not all send message request parameters have been tested. If
//! you notice any that do not work, please feel free to create a ticket, or
//! create a pull a request.
//!
//! ### Pagination
//!
//! For API calls that return a list of results, MailGun returns a `paging`
//! structure. The paging fields are all URLs. Instead of having to parse these,
//! you may use the `call` method to fetch these pages.
//!
//! ```no_run
//! # use mailgun_sdk::{
//! # Client,
//! # get_bounces::GetBouncesParamList,
//! # };
//! # let client = Client::new("ApiKey", "Domain");
//! let mut response = client.get_bounces(GetBouncesParamList::default()).unwrap();
//! let mut bounces = response.items;
//!
//! if bounces.len() > 0 {
//! loop {
//! response = client.call(&response.paging.next).unwrap();
//!
//! if response.items.len() == 0 {
//! break;
//! } else {
//! bounces.append(&mut response.items);
//! }
//! }
//! }
//! ```
//!
//! ### Further Examples
//!
//! ```no_run
//! # use mailgun_sdk::{
//! # Client,
//! # get_bounces::GetBouncesParamList,
//! # get_events::GetEventsParamList,
//! # get_stats::GetStatsParamList,
//! # };
//! let client = Client::new("ApiKey", "Domain");
//!
//! // Get all events.
//! let events = client.get_events(GetEventsParamList::default()).unwrap();
//!
//! // Get all bounces.
//! let bounces = client.get_bounces(GetBouncesParamList::default()).unwrap();
//!
//! // Get account stats.
//! let stats = client.get_stats(GetStatsParamList::default()).unwrap();
//! ```
extern crate serde;
pub use ;
pub use *;
pub use *;
/// Base URL for the MailGun API.
pub const MAILGUN_API_BASE: &'static str = "https://api.mailgun.net/v3";