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
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;

pub struct EcommerceClient {
    pub http_client: HttpClient,
}

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

    /// Retrieve a paginated list of all ecommerce categories stored in your Brevo account. Results are sorted by creation date in descending order by default, and can be filtered by category IDs, name, modification date, creation date, or deletion status. The response includes a `count` field with the total number of matching categories, and pagination defaults to 50 categories per page (maximum 100).
    ///
    /// # Arguments
    ///
    /// * `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
    /// * `ids` - Filter by category ids
    /// * `name` - Filter by category name
    /// * `modified_since` - Filter (urlencoded) the categories modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.**
    /// * `created_since` - Filter (urlencoded) the categories created after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.**
    /// * `is_deleted` - Filter categories by their deletion status. If `false` is passed, only categories that are not deleted 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
    ///         .ecommerce
    ///         .get_categories(
    ///             &GetCategoriesQueryRequest {
    ///                 limit: None,
    ///                 offset: None,
    ///                 sort: None,
    ///                 ids: vec![],
    ///                 name: None,
    ///                 modified_since: None,
    ///                 created_since: None,
    ///                 is_deleted: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn get_categories(
        &self,
        request: &GetCategoriesQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<GetCategoriesResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                "categories",
                None,
                QueryBuilder::new()
                    .int("limit", request.limit.clone())
                    .int("offset", request.offset.clone())
                    .serialize("sort", request.sort.clone())
                    .string_array("ids", request.ids.clone())
                    .string("name", request.name.clone())
                    .string("modifiedSince", request.modified_since.clone())
                    .string("createdSince", request.created_since.clone())
                    .string("isDeleted", request.is_deleted.clone())
                    .build(),
                options,
            )
            .await
    }

    /// Create a new ecommerce category or update an existing one, identified by the mandatory `id` field. When `updateEnabled` is set to `false` (the default), the endpoint performs an insert and returns `201`; if the category ID already exists, a `400` error is returned. When `updateEnabled` is `true`, the endpoint performs an upsert, returning `201` for a new category or `204` when an existing category is updated. The `name` field is mandatory for creation but optional for updates.
    ///
    /// # 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
    ///         .ecommerce
    ///         .create_update_category(
    ///             &CreateUpdateCategoryRequest {
    ///                 id: "CAT123".to_string(),
    ///                 deleted_at: None,
    ///                 is_deleted: None,
    ///                 name: None,
    ///                 update_enabled: None,
    ///                 url: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_update_category(
        &self,
        request: &CreateUpdateCategoryRequest,
        options: Option<RequestOptions>,
    ) -> Result<Option<CreateUpdateCategoryResponse>, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "categories",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create or update multiple ecommerce categories in a single request. The `categories` array accepts up to 100 category objects, each requiring a unique `id`. When `updateEnabled` is `false` (the default), all categories are inserted as new; if any ID already exists, a `400` error is returned. When `updateEnabled` is `true`, existing categories are updated and new ones are created via upsert. Duplicate IDs within the same request payload are rejected. The response returns the count of created and updated categories.
    ///
    /// # 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
    ///         .ecommerce
    ///         .create_update_batch_category(
    ///             &CreateUpdateBatchCategoryRequest {
    ///                 categories: vec![CreateUpdateBatchCategoryRequestCategoriesItem {
    ///                     id: "CAT123".to_string(),
    ///                     ..Default::default()
    ///                 }],
    ///                 update_enabled: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_update_batch_category(
        &self,
        request: &CreateUpdateBatchCategoryRequest,
        options: Option<RequestOptions>,
    ) -> Result<CreateUpdateBatchCategoryResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "categories/batch",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Retrieve the full details of a single ecommerce category by its unique ID. The response includes the category name, URL, creation and modification timestamps, and deletion status. Returns a `404` error if no category matches the provided ID.
    ///
    /// # Arguments
    ///
    /// * `id` - Category ID
    /// * `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
    ///         .ecommerce
    ///         .get_category_info(&"id".to_string(), None)
    ///         .await;
    /// }
    /// ```
    pub async fn get_category_info(
        &self,
        id: &str,
        options: Option<RequestOptions>,
    ) -> Result<GetCategoryDetails, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                &format!("categories/{}", id),
                None,
                None,
                options,
            )
            .await
    }

    /// Getting access to Brevo eCommerce.
    ///
    /// # Arguments
    ///
    /// * `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.ecommerce.activate_the_e_commerce_app(None).await;
    /// }
    /// ```
    pub async fn activate_the_e_commerce_app(
        &self,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(Method::POST, "ecommerce/activate", None, None, options)
            .await
    }

    /// Retrieve aggregated ecommerce attribution metrics for one or more Brevo email campaigns, SMS campaigns, or automation workflows. You can optionally filter by a date range using `periodFrom` and `periodTo` in RFC3339 format. The response includes per-source metrics (orders count, revenue, and average basket) as well as aggregated totals across all requested sources.
    ///
    /// # Arguments
    ///
    /// * `period_from` - When getting metrics for a specific period, define the starting datetime in RFC3339 format
    /// * `period_to` - When getting metrics for a specific period, define the end datetime in RFC3339 format
    /// * `email_campaign_id_array` - The email campaign ID(s) to get metrics for
    /// * `sms_campaign_id_array` - The SMS campaign ID(s) to get metrics for
    /// * `automation_workflow_email_id_array` - The automation workflow ID(s) to get email attribution metrics for
    /// * `automation_workflow_sms_id_array` - The automation workflow ID(s) to get SMS attribution metrics for
    /// * `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
    ///         .ecommerce
    ///         .get_attribution_metrics_for_one_or_more_brevo_campaigns_or_workflows(
    ///             &GetAttributionMetricsForOneOrMoreBrevoCampaignsOrWorkflowsQueryRequest {
    ///                 period_from: Some(DateTime::parse_from_rfc3339("2022-01-02T00:00:00Z").unwrap()),
    ///                 period_to: Some(DateTime::parse_from_rfc3339("2022-01-03T00:00:00Z").unwrap()),
    ///                 email_campaign_id_array: vec![Some("sale".to_string())],
    ///                 sms_campaign_id_array: vec![],
    ///                 automation_workflow_email_id_array: vec![],
    ///                 automation_workflow_sms_id_array: vec![],
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn get_attribution_metrics_for_one_or_more_brevo_campaigns_or_workflows(
        &self,
        request: &GetAttributionMetricsForOneOrMoreBrevoCampaignsOrWorkflowsQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<GetEcommerceAttributionMetricsResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                "ecommerce/attribution/metrics",
                None,
                QueryBuilder::new()
                    .datetime("periodFrom", request.period_from.clone())
                    .datetime("periodTo", request.period_to.clone())
                    .string_array("emailCampaignId[]", request.email_campaign_id_array.clone())
                    .string_array("smsCampaignId[]", request.sms_campaign_id_array.clone())
                    .string_array(
                        "automationWorkflowEmailId[]",
                        request.automation_workflow_email_id_array.clone(),
                    )
                    .string_array(
                        "automationWorkflowSmsId[]",
                        request.automation_workflow_sms_id_array.clone(),
                    )
                    .build(),
                options,
            )
            .await
    }

    /// Retrieve detailed attribution metrics for a single Brevo campaign or automation workflow, identified by its conversion source type and ID. The response includes orders count, revenue, average basket value, and the number of new customers attributed to that specific campaign or workflow.
    ///
    /// # Arguments
    ///
    /// * `conversion_source` - The Brevo campaign type or workflow type for which data will be retrieved
    /// * `conversion_source_id` - The Brevo campaign or automation workflow id for which data will be retrieved
    /// * `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.ecommerce.get_detailed_attribution_metrics_for_a_single_brevo_campaign_or_workflow(&GetEcommerceAttributionMetricsConversionSourceConversionSourceIdRequestConversionSource::EmailCampaign, &"sale".to_string(), None).await;
    /// }
    /// ```
    pub async fn get_detailed_attribution_metrics_for_a_single_brevo_campaign_or_workflow(
        &self,
        conversion_source: &GetEcommerceAttributionMetricsConversionSourceConversionSourceIdRequestConversionSource,
        conversion_source_id: &str,
        options: Option<RequestOptions>,
    ) -> Result<GetEcommerceAttributionMetricsConversionSourceConversionSourceIdResponse, ApiError>
    {
        self.http_client
            .execute_request(
                Method::GET,
                &format!(
                    "ecommerce/attribution/metrics/{}/{}",
                    conversion_source, conversion_source_id
                ),
                None,
                None,
                options,
            )
            .await
    }

    /// Retrieve the list of products whose sales have been attributed to a specific Brevo campaign or automation workflow. Each product entry includes its ID, name, SKU, image URL, product URL, price, revenue, and orders count. The conversion source type must be one of `email_campaign`, `sms_campaign`, `automation_workflow_email`, or `automation_workflow_sms`.
    ///
    /// # Arguments
    ///
    /// * `conversion_source` - The Brevo campaign or automation workflow type for which data will be retrieved
    /// * `conversion_source_id` - The Brevo campaign or automation workflow id for which data will be retrieved
    /// * `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.ecommerce.get_attributed_product_sales_for_a_single_brevo_campaign_or_workflow(&GetEcommerceAttributionProductsConversionSourceConversionSourceIdRequestConversionSource::EmailCampaign, &"sale".to_string(), None).await;
    /// }
    /// ```
    pub async fn get_attributed_product_sales_for_a_single_brevo_campaign_or_workflow(
        &self,
        conversion_source: &GetEcommerceAttributionProductsConversionSourceConversionSourceIdRequestConversionSource,
        conversion_source_id: &str,
        options: Option<RequestOptions>,
    ) -> Result<GetEcommerceAttributionProductsConversionSourceConversionSourceIdResponse, ApiError>
    {
        self.http_client
            .execute_request(
                Method::GET,
                &format!(
                    "ecommerce/attribution/products/{}/{}",
                    conversion_source, conversion_source_id
                ),
                None,
                None,
                options,
            )
            .await
    }

    /// Retrieve the ISO 4217 display currency code currently configured for your Brevo ecommerce account. This currency is used to display monetary values across the ecommerce dashboard and reports. Returns a `403` error if ecommerce is not activated on the account.
    ///
    /// # 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
    ///         .ecommerce
    ///         .get_the_iso4217compliant_display_currency_code_for_your_brevo_account(None)
    ///         .await;
    /// }
    /// ```
    pub async fn get_the_iso4217compliant_display_currency_code_for_your_brevo_account(
        &self,
        options: Option<RequestOptions>,
    ) -> Result<GetEcommerceConfigDisplayCurrencyResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                "ecommerce/config/displayCurrency",
                None,
                None,
                options,
            )
            .await
    }

    /// Set or update the ISO 4217 display currency code for your Brevo ecommerce account. This currency determines how monetary values are displayed in the ecommerce dashboard and reports. The provided currency code must be a valid ISO 4217 code; invalid codes result in a `422` error. Returns a `403` error if ecommerce is not activated on the account.
    ///
    /// # 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
    ///         .ecommerce
    ///         .set_config_display_currency(
    ///             &SetConfigDisplayCurrencyRequest {
    ///                 code: "EUR".to_string(),
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn set_config_display_currency(
        &self,
        request: &SetConfigDisplayCurrencyRequest,
        options: Option<RequestOptions>,
    ) -> Result<SetConfigDisplayCurrencyResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "ecommerce/config/displayCurrency",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Returns the orders stored in your account. Each update sent for an order (for example a status change) is returned as a separate entry, so several entries can share the same `id`.
    ///
    /// # Arguments
    ///
    /// * `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
    /// * `secondary_sort_by_modified_at` - When `true`, orders with the same `createdAt` are then ordered by their `updatedAt`, in the same direction as `sort`. Use it to get a stable order when paging through the results with `limit` and `offset`. Default is `false`.
    /// * `modified_since` - Filter (urlencoded) the orders modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.**
    /// * `created_since` - Filter (urlencoded) the orders created after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.**
    /// * `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
    ///         .ecommerce
    ///         .get_orders(
    ///             &GetOrdersQueryRequest {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn get_orders(
        &self,
        request: &GetOrdersQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<serde_json::Value, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                "orders",
                None,
                QueryBuilder::new()
                    .int("limit", request.limit.clone())
                    .int("offset", request.offset.clone())
                    .serialize("sort", request.sort.clone())
                    .bool(
                        "secondarySortByModifiedAt",
                        request.secondary_sort_by_modified_at.clone(),
                    )
                    .string("modifiedSince", request.modified_since.clone())
                    .string("createdSince", request.created_since.clone())
                    .build(),
                options,
            )
            .await
    }

    /// Creates an order or records a change to an existing order, identified by `id`. Each call is stored as a new entry for the order rather than replacing the previous one, so [Get order details](/reference/get-orders) can return several entries with the same `id` (one per status change or other update). Orders sent to this endpoint are processed as live data and can trigger automation workflows. To import past orders without triggering workflows, use [Create orders in batch](/reference/create-batch-order) with `historical: true`.
    ///
    /// # Arguments
    ///
    /// * `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
    ///         .ecommerce
    ///         .create_order(
    ///             &Order {
    ///                 amount: 308.42,
    ///                 created_at: "2021-07-29T20:59:23.383Z".to_string(),
    ///                 id: "14".to_string(),
    ///                 products: vec![OrderProductsItem {
    ///                     price: 99.99,
    ///                     product_id: "P1".to_string(),
    ///                     ..Default::default()
    ///                 }],
    ///                 status: "completed".to_string(),
    ///                 updated_at: "2021-07-30T10:59:23.383Z".to_string(),
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_order(
        &self,
        request: &Order,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "orders/status",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Creates multiple orders in one request instead of one order at a time. Each order is stored as a new entry rather than replacing a previous order with the same `id`, so [Get order details](/reference/get-orders) can return several entries with the same `id`.
    ///
    /// # 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
    ///         .ecommerce
    ///         .create_batch_order(
    ///             &CreateBatchOrderRequest {
    ///                 orders: vec![Order {
    ///                     amount: 308.42,
    ///                     created_at: "2021-07-29T20:59:23.383Z".to_string(),
    ///                     id: "14".to_string(),
    ///                     products: vec![OrderProductsItem {
    ///                         price: 99.99,
    ///                         product_id: "P1".to_string(),
    ///                         ..Default::default()
    ///                     }],
    ///                     status: "completed".to_string(),
    ///                     updated_at: "2021-07-30T10:59:23.383Z".to_string(),
    ///                     ..Default::default()
    ///                 }],
    ///                 historical: None,
    ///                 notify_url: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_batch_order(
        &self,
        request: &CreateBatchOrderRequest,
        options: Option<RequestOptions>,
    ) -> Result<CreateBatchOrderResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "orders/status/batch",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Retrieve a paginated list of all ecommerce products stored in your Brevo account. Results are sorted by creation date in descending order by default, and can be filtered by product IDs, name (minimum 3 characters), price range, category IDs, modification date, creation date, or deletion status. Use the `search` parameter to query across SKU, name, and ID simultaneously — results are prioritized as exact SKU match > SKU prefix match > name match > ID match. Pagination defaults to 50 products per page (maximum 1000), and the response includes a `count` field with the total number of matching products.
    ///
    /// # Arguments
    ///
    /// * `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
    /// * `ids` - Filter by product ids
    /// * `search` - Search products simultaneously across SKU, name, and ID fields. Results are returned in the following priority order: **exact SKU match** > **SKU prefix match** > **name match** > **ID match**. For example, `?search=123` on products with `{sku: "123"}` and `{sku: "123456"}` returns the exact SKU match first.
    /// * `name` - Filter by product name, minimum 3 characters should be present for search.
    /// * `price_lte` - Price filter for products less than and equals to particular amount
    /// * `price_gte` - Price filter for products greater than and equals to particular amount
    /// * `price_lt` - Price filter for products less than particular amount
    /// * `price_gt` - Price filter for products greater than particular amount
    /// * `price_eq` - Price filter for products equals to particular amount
    /// * `price_ne` - Price filter for products not equals to particular amount
    /// * `alternative_price_lte` - Alternative price filter for products less than and equals to particular amount
    /// * `alternative_price_gte` - Alternative price filter for products greater than and equals to particular amount
    /// * `alternative_price_lt` - Alternative price filter for products less than particular amount
    /// * `alternative_price_gt` - Alternative price filter for products greater than particular amount
    /// * `alternative_price_eq` - Alternative price filter for products equals to particular amount
    /// * `alternative_price_ne` - Alternative price filter for products not equals to particular amount
    /// * `categories` - Filter by categories ids
    /// * `modified_since` - Filter (urlencoded) the products modified after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.**
    /// * `created_since` - Filter (urlencoded) the products created after a given UTC date-time (YYYY-MM-DDTHH:mm:ss.SSSZ). **Prefer to pass your timezone in date-time format for accurate result.**
    /// * `sort_by_field` - Sort the results by a specific field. Default sort field is `created_at` when not passed.
    /// * `is_deleted` - Filter products by their deletion status. If `false` is passed, only products that are not deleted 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
    ///         .ecommerce
    ///         .get_products(
    ///             &GetProductsQueryRequest {
    ///                 limit: None,
    ///                 offset: None,
    ///                 sort: None,
    ///                 ids: vec![],
    ///                 search: None,
    ///                 name: None,
    ///                 price_lte: None,
    ///                 price_gte: None,
    ///                 price_lt: None,
    ///                 price_gt: None,
    ///                 price_eq: None,
    ///                 price_ne: None,
    ///                 alternative_price_lte: None,
    ///                 alternative_price_gte: None,
    ///                 alternative_price_lt: None,
    ///                 alternative_price_gt: None,
    ///                 alternative_price_eq: None,
    ///                 alternative_price_ne: None,
    ///                 categories: vec![],
    ///                 modified_since: None,
    ///                 created_since: None,
    ///                 sort_by_field: None,
    ///                 is_deleted: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn get_products(
        &self,
        request: &GetProductsQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<GetProductsResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                "products",
                None,
                QueryBuilder::new()
                    .int("limit", request.limit.clone())
                    .int("offset", request.offset.clone())
                    .serialize("sort", request.sort.clone())
                    .string_array("ids", request.ids.clone())
                    .string("search", request.search.clone())
                    .string("name", request.name.clone())
                    .float("price[lte]", request.price_lte.clone())
                    .float("price[gte]", request.price_gte.clone())
                    .float("price[lt]", request.price_lt.clone())
                    .float("price[gt]", request.price_gt.clone())
                    .float("price[eq]", request.price_eq.clone())
                    .float("price[ne]", request.price_ne.clone())
                    .float(
                        "alternativePrice[lte]",
                        request.alternative_price_lte.clone(),
                    )
                    .float(
                        "alternativePrice[gte]",
                        request.alternative_price_gte.clone(),
                    )
                    .float("alternativePrice[lt]", request.alternative_price_lt.clone())
                    .float("alternativePrice[gt]", request.alternative_price_gt.clone())
                    .float("alternativePrice[eq]", request.alternative_price_eq.clone())
                    .float("alternativePrice[ne]", request.alternative_price_ne.clone())
                    .string_array("categories", request.categories.clone())
                    .string("modifiedSince", request.modified_since.clone())
                    .string("createdSince", request.created_since.clone())
                    .serialize("sortByField", request.sort_by_field.clone())
                    .string("isDeleted", request.is_deleted.clone())
                    .build(),
                options,
            )
            .await
    }

    /// Create a new ecommerce product or update an existing one, identified by the mandatory `id` field. When `updateEnabled` is `false` (the default), the endpoint inserts a new product and returns `201`; if the product ID already exists, a `400` error is returned. When `updateEnabled` is `true`, the endpoint performs an upsert, returning `201` for a new product or `204` for an update. The `name` field is mandatory for creation but optional for updates. Product images are downloaded, validated (max 5 MB, formats: jpeg, jpg, png, bmp, gif, webp), and re-hosted on S3. The `metaInfo` object supports up to 20 keys with a cumulative size limit of approximately 1000 KB.
    ///
    /// # 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
    ///         .ecommerce
    ///         .create_update_product(
    ///             &CreateUpdateProductRequest {
    ///                 id: "P11".to_string(),
    ///                 name: "Iphone 11".to_string(),
    ///                 brand: None,
    ///                 categories: None,
    ///                 deleted_at: None,
    ///                 description: None,
    ///                 image_url: None,
    ///                 is_deleted: None,
    ///                 meta_info: None,
    ///                 parent_id: None,
    ///                 price: None,
    ///                 alternative_price: None,
    ///                 sku: None,
    ///                 stock: None,
    ///                 update_enabled: None,
    ///                 url: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_update_product(
        &self,
        request: &CreateUpdateProductRequest,
        options: Option<RequestOptions>,
    ) -> Result<Option<CreateUpdateProductResponse>, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "products",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create or update multiple ecommerce products in a single request. The `products` array accepts up to 100 product objects for creation (or up to 1000 when `updateEnabled` is `true` and the account has an increased limit). Each product requires a unique `id` and `name` (name is mandatory for creation only). When `updateEnabled` is `false`, all products are inserted as new; if any ID already exists, a `400` error is returned. When `updateEnabled` is `true`, existing products are updated and new ones are created via upsert. Duplicate IDs within the same request payload are rejected. The response returns the count of created and updated products.
    ///
    /// # 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
    ///         .ecommerce
    ///         .create_update_batch_products(
    ///             &CreateUpdateBatchProductsRequest {
    ///                 products: vec![CreateUpdateBatchProductsRequestProductsItem {
    ///                     id: "P11".to_string(),
    ///                     name: "Iphone 11".to_string(),
    ///                     ..Default::default()
    ///                 }],
    ///                 update_enabled: None,
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_update_batch_products(
        &self,
        request: &CreateUpdateBatchProductsRequest,
        options: Option<RequestOptions>,
    ) -> Result<CreateUpdateBatchProductsResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "products/batch",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Retrieve the full details of a single ecommerce product by its unique ID. The response includes the product name, price, SKU, URL, image URLs (original and thumbnails), categories, stock level, meta information, creation and modification timestamps, and deletion status. Returns a `404` error if no product matches the provided ID.
    ///
    /// # Arguments
    ///
    /// * `id` - Product ID
    /// * `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
    ///         .ecommerce
    ///         .get_product_info(&"id".to_string(), None)
    ///         .await;
    /// }
    /// ```
    pub async fn get_product_info(
        &self,
        id: &str,
        options: Option<RequestOptions>,
    ) -> Result<GetProductDetails, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                &format!("products/{}", id),
                None,
                None,
                options,
            )
            .await
    }

    /// Register a contact to receive an alert for a specific product event, such as `back_in_stock`. At least one contact identifier (`ext_id`, `email`, or `sms`) must be provided; when multiple are given, priority is `ext_id` > `email` > `sms`. Returns a `404` error if the product ID does not exist, and a `403` error if product alerts are not enabled for the account.
    ///
    /// # Arguments
    ///
    /// * `id` - Product ID
    /// * `type_` - Alert type
    /// * `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
    ///         .ecommerce
    ///         .create_product_alert(
    ///             &"id".to_string(),
    ///             &"back_in_stock".to_string(),
    ///             &CreateProductAlertRequest {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn create_product_alert(
        &self,
        id: &str,
        type_: &str,
        request: &CreateProductAlertRequest,
        options: Option<RequestOptions>,
    ) -> Result<(), ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                &format!("products/{}/alerts/{}", id, type_),
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }
}