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
use anyhow::Result;
use crate::Client;
pub struct SingleSends {
pub client: Client,
}
impl SingleSends {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
SingleSends { client }
}
/**
* Get All Single Sends.
*
* This function performs a `GET` to the `/marketing/singlesends` endpoint.
*
* **This endpoint allows you to retrieve all your Single Sends.**
*
* Returns all of your Single Sends with condensed details about each, including the Single Sends' IDs. For more details about an individual Single Send, pass the Single Send's ID to the `/marketing/singlesends/{id}` endpoint.
*
* **Parameters:**
*
* * `page_size: i64`
* * `page_token: &str` -- The license key provided with your New Relic account.
*/
pub async fn get_marketing_singlesends(
&self,
page_size: i64,
page_token: &str,
) -> Result<crate::types::GetMarketingSinglesendsResponse> {
let mut query_args: Vec<(String, String)> = Default::default();
if page_size > 0 {
query_args.push(("page_size".to_string(), page_size.to_string()));
}
if !page_token.is_empty() {
query_args.push(("page_token".to_string(), page_token.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/marketing/singlesends?{}", query_);
self.client.get(&url, None).await
}
/**
* Create Single Send.
*
* This function performs a `POST` to the `/marketing/singlesends` endpoint.
*
* **This endpoint allows you to create a new Single Send.**
*
* Please note that if you are migrating from the previous version of Single Sends, you no longer need to pass a template ID with your request to this endpoint. Instead, you will pass all template data in the `email_config` object.
*/
pub async fn post_marketing_singlesend(
&self,
body: &crate::types::SinglesendRequest,
) -> Result<crate::types::SinglesendResponseAllOf> {
let url = "/marketing/singlesends".to_string();
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* Bulk Delete Single Sends.
*
* This function performs a `DELETE` to the `/marketing/singlesends` endpoint.
*
* **This endpoint allows you to delete multiple Single Sends using an array of Single Sends IDs.**
*
* To first retrieve all your Single Sends' IDs, you can make a GET request to the `/marketing/singlensends` endpoint.
*
* Please note that a DELETE request is permanent, and your Single Sends will not be recoverable after deletion.
*
* **Parameters:**
*
* * `ids: &[String]` -- The recipient IDs of the recipients that already existed from this request.
*/
pub async fn delete_marketing_singlesends(&self, ids: &[String]) -> Result<()> {
let mut query_args: Vec<(String, String)> = Default::default();
if !ids.is_empty() {
query_args.push(("ids".to_string(), ids.join(" ")));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/marketing/singlesends?{}", query_);
self.client.delete(&url, None).await
}
/**
* Get Single Send by ID.
*
* This function performs a `GET` to the `/marketing/singlesends/{id}` endpoint.
*
* **This endpoint allows you to retrieve details about one Single Send using a Single Send ID.**
*
* You can retrieve all of your Single Sends by making a GET request to the `/marketing/singlesends` endpoint.
*/
pub async fn get_marketing_singlesend(
&self,
id: &str,
) -> Result<crate::types::SinglesendResponseAllOf> {
let url = format!(
"/marketing/singlesends/{}",
crate::progenitor_support::encode_path(id),
);
self.client.get(&url, None).await
}
/**
* Duplicate Single Send.
*
* This function performs a `POST` to the `/marketing/singlesends/{id}` endpoint.
*
* **This endpoint allows you to duplicate an existing Single Send using its Single Send ID.**
*
* Duplicating a Single Send is useful when you want to create a Single Send but don't want to start from scratch. Once duplicated, you can update or edit the Single Send by making a PATCH request to the `/marketing/singlesends/{id}` endpoint.
*
* If you leave the `name` field blank, your duplicate will be assigned the name of the Single Send it was copied from with the text “Copy of ” prepended to it. The `name` field length is limited to 100 characters, so the end of the new Single Send name, including “Copy of ”, will be trimmed if the name exceeds this limit.
*/
pub async fn post_marketing_singlesend_single_sends(
&self,
id: &str,
body: &crate::types::PostMarketingSinglesendsRequest,
) -> Result<crate::types::SinglesendResponseAllOf> {
let url = format!(
"/marketing/singlesends/{}",
crate::progenitor_support::encode_path(id),
);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* Delete Single Send by ID.
*
* This function performs a `DELETE` to the `/marketing/singlesends/{id}` endpoint.
*
* **This endpoint allows you to delete one Single Send using a Single Send ID.**
*
* To first retrieve all your Single Sends' IDs, you can make a GET request to the `/marketing/singlensends` endpoint.
*
* Please note that a `DELETE` request is permanent, and your Single Send will not be recoverable after deletion.
*/
pub async fn delete_marketing_singlesends_single_sends(&self, id: &str) -> Result<()> {
let url = format!(
"/marketing/singlesends/{}",
crate::progenitor_support::encode_path(id),
);
self.client.delete(&url, None).await
}
/**
* Update Single Send.
*
* This function performs a `PATCH` to the `/marketing/singlesends/{id}` endpoint.
*
* **This endpoint allows you to update a Single Send using a Single Send ID.**
*
* You only need to pass the fields you want to update. Any blank/missing fields will remain unaltered.
*/
pub async fn patch_marketing_singlesends(
&self,
id: &str,
body: &crate::types::SinglesendRequest,
) -> Result<crate::types::SinglesendResponseAllOf> {
let url = format!(
"/marketing/singlesends/{}",
crate::progenitor_support::encode_path(id),
);
self.client
.patch(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* Get Single Sends Search.
*
* This function performs a `POST` to the `/marketing/singlesends/search` endpoint.
*
* **This endpoint allows you to search for Single Sends based on specified criteria.**
*
* You can search for Single Sends by passing a combination of values using the `name`, `status`, and `categories` request body fields.
*
* For example, if you want to search for all Single Sends that are "drafts" or "scheduled" and also associated with the category "shoes," your request body may look like the example below.
*
* ```javascript
* {
* "status": [
* "draft",
* "scheduled"
* ],
* "categories": [
* "shoes"
* ],
* }
* ```
*
* **Parameters:**
*
* * `page_size: i64`
* * `page_token: &str` -- The license key provided with your New Relic account.
*/
pub async fn post_marketing_singlesends_search(
&self,
page_size: i64,
page_token: &str,
body: &crate::types::SinglesendSearch,
) -> Result<crate::types::GetMarketingSinglesendsResponse> {
let mut query_args: Vec<(String, String)> = Default::default();
if page_size > 0 {
query_args.push(("page_size".to_string(), page_size.to_string()));
}
if !page_token.is_empty() {
query_args.push(("page_token".to_string(), page_token.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/marketing/singlesends/search?{}", query_);
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* Schedule Single Send.
*
* This function performs a `PUT` to the `/marketing/singlesends/{id}/schedule` endpoint.
*
* **This endpoint allows you to schedule a Single Send for future delivery using a Single Send ID.**
*
* To schedule a Single Send, you must pass a date string in ISO 8601 time format (yyyy-MM-ddTHH:mm:ssZ) using the required `send_at` field. For example, the ISO 8601 format for 9:00 AM UTC on May 6, 2020 would be `2020-05-06T09:00:00Z`. You may also pass the string `"now"` to send the Single Send immediately.
*/
pub async fn put_marketing_singlesends_schedule(
&self,
id: &str,
body: &crate::types::PutMarketingSinglesendsScheduleRequest,
) -> Result<crate::types::PutMarketingSinglesendsScheduleResponse> {
let url = format!(
"/marketing/singlesends/{}/schedule",
crate::progenitor_support::encode_path(id),
);
self.client
.put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* Delete Single Send Schedule.
*
* This function performs a `DELETE` to the `/marketing/singlesends/{id}/schedule` endpoint.
*
* **This endpoint allows you to cancel a scheduled Single Send using a Single Send ID.**
*
* Making a DELETE request to this endpoint will cancel the scheduled sending of a Single Send. The request will not delete the Single Send itself. Deleting a Single Send can be done by passing a DELETE request to `/marketing/singlesends/{id}`.
*/
pub async fn delete_marketing_singlesends_schedule(
&self,
id: &str,
) -> Result<crate::types::SinglesendSchedule> {
let url = format!(
"/marketing/singlesends/{}/schedule",
crate::progenitor_support::encode_path(id),
);
self.client.delete(&url, None).await
}
/**
* Get All Categories.
*
* This function performs a `GET` to the `/marketing/singlesends/categories` endpoint.
*
* **This endpoint allows you to retrieve all the categories associated with your Single Sends.**
*
* This endpoint will return your latest 1,000 categories.
*/
pub async fn get_marketing_singlesends_categories(
&self,
) -> Result<crate::types::GetMarketingSinglesendsCategoriesResponse> {
let url = "/marketing/singlesends/categories".to_string();
self.client.get(&url, None).await
}
}