brevo-rust 1.0.0

Official Rust SDK for the Brevo API.
Documentation
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;

pub struct EmailCampaignsClient {
    pub http_client: HttpClient,
}

impl EmailCampaignsClient {
    pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
        Ok(Self {
            http_client: HttpClient::new(config.clone())?,
        })
    }

    /// <Note>The response payload for this endpoint has changed
    /// You now need to specify which type of statistics you would like to retrieve. For more information visit [this page](https://developers.brevo.com/changelog/2023/2/7).</Note>
    ///
    /// # Arguments
    ///
    /// * `type_` - Filter on the type of the campaigns
    /// * `status` - Filter on the status of the campaign
    /// * `statistics` - Filter on the type of statistics required. Example: **globalStats** value will only fetch globalStats info of the campaign in the returned response. This option only returns data for events that occurred in the last 6 months. For older campaigns, it is advisable to use the **Get Campaign Report** endpoint.
    /// * `start_date` - **Mandatory if endDate is used.** Starting (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the sent email campaigns. **Prefer to pass your timezone in date-time format for accurate result.** Only available if `status` is not passed or is set to `sent`. The date range between `startDate` and `endDate` must not exceed 2 years. `startDate` must not be in the future.
    /// * `end_date` - **Mandatory if startDate is used.** Ending (urlencoded) UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ) to filter the sent email campaigns. **Prefer to pass your timezone in date-time format for accurate result.** Only available if `status` is not passed or is set to `sent`. The date range between `startDate` and `endDate` must not exceed 2 years. `endDate` must not be in the future.
    /// * `limit` - Number of documents per page
    /// * `offset` - Index of the first document in the page
    /// * `sort` - Sort the results in the ascending/descending order of record creation. Default order is **descending** if `sort` is not passed
    /// * `exclude_html_content` - Use this flag to exclude htmlContent from the response body. If set to **true**, the htmlContent field will be returned as an empty string in the response body.
    /// * `exclude_pdf_attachment` - Use this flag to filter out campaigns that have a PDF attachment. If set to **true**, only campaigns without a PDF attachment (or with no attachment at all) will be returned.
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .get_email_campaigns(
    ///             &GetEmailCampaignsQueryRequest {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn get_email_campaigns(
        &self,
        request: &GetEmailCampaignsQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<GetEmailCampaignsResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                "emailCampaigns",
                None,
                QueryBuilder::new()
                    .serialize("type", request.r#type.clone())
                    .serialize("status", request.status.clone())
                    .serialize("statistics", request.statistics.clone())
                    .string("startDate", request.start_date.clone())
                    .string("endDate", request.end_date.clone())
                    .int("limit", request.limit.clone())
                    .int("offset", request.offset.clone())
                    .serialize("sort", request.sort.clone())
                    .bool("excludeHtmlContent", request.exclude_html_content.clone())
                    .bool(
                        "excludePdfAttachment",
                        request.exclude_pdf_attachment.clone(),
                    )
                    .build(),
                options,
            )
            .await
    }

    /// Create a new email campaign. The campaign requires at minimum a name and sender details, and is created in draft status by default. You must provide email content via one of three mutually exclusive options: htmlContent (inline HTML), htmlUrl (remote URL), or templateId (existing template); additionally, A/B testing can be enabled by setting abTesting to true with subjectA and subjectB, but this is incompatible with sendAtBestTime.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .create_email_campaign(
    ///             &CreateEmailCampaignRequest {
    ///                 name: "Newsletter - May 2017".to_string(),
    ///                 sender: CreateEmailCampaignRequestSender {
    ///                     ..Default::default()
    ///                 },
    ///                 ab_testing: None,
    ///                 attachment_url: None,
    ///                 email_expiration_date: None,
    ///                 footer: None,
    ///                 header: None,
    ///                 html_content: None,
    ///                 html_url: None,
    ///                 increase_rate: None,
    ///                 initial_quota: None,
    ///                 inline_image_activation: None,
    ///                 ip_warmup_enable: None,
    ///                 mirror_active: None,
    ///                 params: None,
    ///                 preview_text: None,
    ///                 recipients: None,
    ///                 reply_to: None,
    ///                 scheduled_at: None,
    ///                 send_at_best_time: None,
    ///                 split_rule: None,
    ///                 subject: None,
    ///                 subject_a: None,
    ///                 subject_b: None,
    ///                 tag: None,
    ///                 template_id: None,
    ///                 to_field: None,
    ///                 unsubscription_page_id: None,
    ///                 update_form_id: None,
    ///                 utm_campaign: None,
    ///                 utm_content: None,
    ///                 utm_id: None,
    ///                 utm_medium: None,
    ///                 utm_source: None,
    ///                 utm_term: None,
    ///                 winner_criteria: None,
    ///                 winner_delay: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_email_campaign(
        &self,
        request: &CreateEmailCampaignRequest,
        options: Option<RequestOptions>,
    ) -> Result<CreateEmailCampaignResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "emailCampaigns",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Upload an image to your account''s image gallery by providing an absolute URL to the image. The maximum allowed image size is 2MB and supported formats are jpeg, jpg, png, bmp, and gif; local file uploads are not supported.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .upload_image_to_gallery(
    ///             &UploadImageToGalleryRequest {
    ///                 image_url: "https://somedomain.com/image1.jpg".to_string(),
    ///                 name: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn upload_image_to_gallery(
        &self,
        request: &UploadImageToGalleryRequest,
        options: Option<RequestOptions>,
    ) -> Result<UploadImageToGalleryResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "emailCampaigns/images",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Retrieve detailed information about a specific email campaign by its ID, including recipients, statistics, and HTML content. Use the statistics query parameter to select which statistics to include (globalStats, linksStats, statsByDomain, statsByDevice, or statsByBrowser); statsByDevice and statsByBrowser are only available on this single-campaign endpoint. You can exclude HTML content from the response by setting excludeHtmlContent to true.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `statistics` - Filter on the type of statistics required. Example: **globalStats** value will only fetch globalStats info of the campaign in the returned response. `statsByDevice` and `statsByBrowser` are only available when retrieving a single campaign (not in the list endpoint).
    /// * `exclude_html_content` - Use this flag to exclude htmlContent from the response body. If set to **true**, htmlContent field will be returned as empty string in the response body
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .get_email_campaign(
    ///             1000000,
    ///             &GetEmailCampaignQueryRequest {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn get_email_campaign(
        &self,
        campaign_id: i64,
        request: &GetEmailCampaignQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<GetEmailCampaignResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                &format!("emailCampaigns/{}", campaign_id),
                None,
                QueryBuilder::new()
                    .serialize("statistics", request.statistics.clone())
                    .bool("excludeHtmlContent", request.exclude_html_content.clone())
                    .build(),
                options,
            )
            .await
    }

    /// Update an existing email campaign''s properties such as name, subject, content, sender, recipients, schedule, and A/B testing configuration. The campaign must exist and the request body must contain at least one valid field to update. Only draft or scheduled campaigns can be modified; if sendAtBestTime is enabled, IP warmup will be automatically disabled.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// Empty response
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .update_email_campaign(
    ///             1000000,
    ///             &UpdateEmailCampaignRequest {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn update_email_campaign(
        &self,
        campaign_id: i64,
        request: &UpdateEmailCampaignRequest,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::PUT,
                &format!("emailCampaigns/{}", campaign_id),
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Delete an email campaign by its campaign ID. Only campaigns that have not been scheduled can be deleted; attempting to delete a campaign that has already been scheduled will return a 403 permission denied error. Related data in templates, newsletter builder, and schedule collections is also cleaned up.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// Empty response
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .delete_email_campaign(1000000, None)
    ///         .await;
    /// }
    /// ```
    pub async fn delete_email_campaign(
        &self,
        campaign_id: i64,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::DELETE,
                &format!("emailCampaigns/{}", campaign_id),
                None,
                None,
                options,
            )
            .await
    }

    /// Obtain winning version of an A/B test email campaign
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the A/B test campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .get_ab_test_campaign_result(1000000, None)
    ///         .await;
    /// }
    /// ```
    pub async fn get_ab_test_campaign_result(
        &self,
        campaign_id: i64,
        options: Option<RequestOptions>,
    ) -> Result<GetAbTestCampaignResultResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                &format!("emailCampaigns/{}/abTestCampaignResult", campaign_id),
                None,
                None,
                options,
            )
            .await
    }

    /// Export the recipients of a sent email campaign as an asynchronous process, filtered by recipient type (e.g. openers, clickers, hardBounces). The recipientsType field is required and determines which subset of recipients to export. An optional notifyURL webhook will be called once the export is complete, and the response returns a processId to track the export status.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .email_export_recipients(
    ///             1000000,
    ///             &EmailExportRecipientsRequest {
    ///                 recipients_type: EmailExportRecipientsRequestRecipientsType::All,
    ///                 notify_url: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn email_export_recipients(
        &self,
        campaign_id: i64,
        request: &EmailExportRecipientsRequest,
        options: Option<RequestOptions>,
    ) -> Result<EmailExportRecipientsResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                &format!("emailCampaigns/{}/exportRecipients", campaign_id),
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Send an existing email campaign immediately by scheduling it for the current time. The campaign must have valid recipients and content configured before sending. The system verifies your account''s send limit and credit balance before dispatching; if credits are insufficient, a 402 error is returned.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// Empty response
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .send_email_campaign_now(1000000, None)
    ///         .await;
    /// }
    /// ```
    pub async fn send_email_campaign_now(
        &self,
        campaign_id: i64,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                &format!("emailCampaigns/{}/sendNow", campaign_id),
                None,
                None,
                options,
            )
            .await
    }

    /// A PDF will be sent to the specified email addresses
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// Empty response
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .send_report(
    ///             1000000,
    ///             &SendReport {
    ///                 email: SendReportEmail {
    ///                     body: "Please find attached the report of our last email campaign.".to_string(),
    ///                     to: vec!["jim.suehan@example.com".to_string()],
    ///                     ..Default::default()
    ///                 },
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn send_report(
        &self,
        campaign_id: i64,
        request: &SendReport,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                &format!("emailCampaigns/{}/sendReport", campaign_id),
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Send a test version of an email campaign to specified email addresses or your entire test list. If the emailTo array is left empty, the test mail will be sent to all addresses in your test list. You can send a maximum of 50 test emails per day.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// Empty response
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .send_test_email(
    ///             1000000,
    ///             &SendTestEmail {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn send_test_email(
        &self,
        campaign_id: i64,
        request: &SendTestEmail,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                &format!("emailCampaigns/{}/sendTest", campaign_id),
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Get a unique URL to share & import an email template from one Brevo account to another.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign or template
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .get_shared_template_url(1000000, None)
    ///         .await;
    /// }
    /// ```
    pub async fn get_shared_template_url(
        &self,
        campaign_id: i64,
        options: Option<RequestOptions>,
    ) -> Result<GetSharedTemplateUrlResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                &format!("emailCampaigns/{}/sharedUrl", campaign_id),
                None,
                None,
                options,
            )
            .await
    }

    /// Update the status of an email campaign, such as suspending, archiving, or replicating it. Available status values include suspended, archive, darchive, sent, queued, replicate, replicateTemplate, cancel, and draft. Note that the replicateTemplate status is only available for template type campaigns.
    ///
    /// # Arguments
    ///
    /// * `campaign_id` - Id of the campaign
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// Empty response
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use brevo_rust::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         api_key: Some("<value>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = BrevoClient::new(config).expect("Failed to build client");
    ///     client
    ///         .email_campaigns
    ///         .update_campaign_status(
    ///             1000000,
    ///             &UpdateCampaignStatus {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn update_campaign_status(
        &self,
        campaign_id: i64,
        request: &UpdateCampaignStatus,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::PUT,
                &format!("emailCampaigns/{}/status", campaign_id),
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }
}