sendgrid_api/csv_ui_only.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct CsvUiOnly {
5 pub client: Client,
6}
7
8impl CsvUiOnly {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 CsvUiOnly { client }
12 }
13
14 /**
15 * Request CSV.
16 *
17 * This function performs a `POST` to the `/messages/download` endpoint.
18 *
19 * This is BETA functionality. You may not have access, and we reserve the right to change functionality without notice.
20 *
21 * This request will kick off a backend process to generate a CSV file. Once generated, the worker will then send an email for the user download the file. The link will expire in 3 days.
22 *
23 * The CSV fill contain the last 1 million messages. This endpoint will be rate limited to 1 request every 12 hours (rate limit may change).
24 *
25 * This endpoint is similar to the GET Single Message endpoint - the only difference is that /download is added to indicate that this is a CSV download requests but the same query is used to determine what the CSV should contain.
26 *
27 * **Parameters:**
28 *
29 * * `query: &str` -- Uses a SQL like syntax to indicate which messages to include in the CSV.
30 * * `authorization: &str` -- The license key provided with your New Relic account.
31 */
32 pub async fn post_messages_download(
33 &self,
34 query: &str,
35 ) -> ClientResult<crate::Response<crate::types::PostMessagesDownloadResponse>> {
36 let mut query_args: Vec<(String, String)> = Default::default();
37 if !query.is_empty() {
38 query_args.push(("query".to_string(), query.to_string()));
39 }
40 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
41 let url = self
42 .client
43 .url(&format!("/messages/download?{}", query_), None);
44 self.client
45 .post(
46 &url,
47 crate::Message {
48 body: None,
49 content_type: None,
50 },
51 )
52 .await
53 }
54 /**
55 * Download CSV.
56 *
57 * This function performs a `GET` to the `/messages/download/{download_uuid}` endpoint.
58 *
59 * **This endpoint will return a presigned URL that can be used to download the CSV that was requested from the "Request a CSV" endpoint.**
60 *
61 * **Parameters:**
62 *
63 * * `authorization: &str` -- The license key provided with your New Relic account.
64 */
65 pub async fn get_messages_download(
66 &self,
67 download_uuid: &str,
68 ) -> ClientResult<crate::Response<crate::types::GetMessagesDownloadResponse>> {
69 let url = self.client.url(
70 &format!(
71 "/messages/download/{}",
72 crate::progenitor_support::encode_path(download_uuid),
73 ),
74 None,
75 );
76 self.client
77 .get(
78 &url,
79 crate::Message {
80 body: None,
81 content_type: None,
82 },
83 )
84 .await
85 }
86}