Skip to content

Commit f33db55

Browse files
committed
Add Documentation Example
This patch adds an example of using a custom client to help clear up any confusion.
1 parent a14e23c commit f33db55

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/v3/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ impl Sender {
208208
/// Construct a new V3 message sender. The `client` parameter is optional and `None` uses the
209209
/// default. If you provide your own configured Client, you must call [Sender::get_headers] and
210210
/// set the returned value as default headers.
211+
///
212+
/// ```rust,no_run
213+
/// use reqwest::Client;
214+
/// use sendgrid::SendgridResult;
215+
/// use sendgrid::v3::Sender;
216+
///
217+
/// fn main() -> SendgridResult<()> {
218+
/// // Below is an example of providing your own custom client.
219+
/// let client = Client::builder()
220+
/// .default_headers(Sender::get_headers("API_KEY".into())?)
221+
/// .build()?;
222+
/// Ok(())
223+
/// }
224+
/// ```
211225
pub fn new(api_key: String, client: Option<Client>) -> Sender {
212226
let client = client.unwrap_or(clients::new_client(&api_key));
213227

@@ -222,6 +236,20 @@ impl Sender {
222236
/// Construct a new V3 message sender with a blocking client. The `client` parameter is
223237
/// optional and `None` uses the default. If you provide your own configured Client, you must
224238
/// call [Sender::get_headers] and set the returned value as default headers.
239+
///
240+
/// ```rust,no_run
241+
/// use reqwest::blocking::Client;
242+
/// use sendgrid::SendgridResult;
243+
/// use sendgrid::v3::Sender;
244+
///
245+
/// fn main() -> SendgridResult<()> {
246+
/// // Below is an example of providing your own custom client.
247+
/// let client = Client::builder()
248+
/// .default_headers(Sender::get_headers("API_KEY".into())?)
249+
/// .build()?;
250+
/// Ok(())
251+
/// }
252+
/// ```
225253
#[cfg(feature = "blocking")]
226254
pub fn new_blocking(
227255
api_key: String,

0 commit comments

Comments
 (0)