sendinblue_v3/apis/
contacts_api.rs

1/*
2 * SendinBlue API
3 *
4 * SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to :   - Manage your campaigns and get the statistics   - Manage your contacts   - Send transactional Emails and SMS   - and much more...  You can download our wrappers at https://github.com/orgs/sendinblue  **Possible responses**   | Code | Message |   | :-------------: | ------------- |   | 200  | OK. Successful Request  |   | 201  | OK. Successful Creation |   | 202  | OK. Request accepted |   | 204  | OK. Successful Update/Deletion  |   | 400  | Error. Bad Request  |   | 401  | Error. Authentication Needed  |   | 402  | Error. Not enough credit, plan upgrade needed  |   | 403  | Error. Permission denied  |   | 404  | Error. Object does not exist |   | 405  | Error. Method not allowed  |   | 406  | Error. Not Acceptable  | 
5 *
6 * The version of the OpenAPI document: 3.0.0
7 * Contact: contact@sendinblue.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`add_contact_to_list`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddContactToListError {
22    Status400(crate::models::ErrorModel),
23    Status404(crate::models::ErrorModel),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`create_attribute`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum CreateAttributeError {
31    Status400(crate::models::ErrorModel),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`create_contact`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum CreateContactError {
39    Status400(crate::models::ErrorModel),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`create_doi_contact`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum CreateDoiContactError {
47    Status400(crate::models::ErrorModel),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`create_folder`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum CreateFolderError {
55    Status400(crate::models::ErrorModel),
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`create_list`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum CreateListError {
63    Status400(crate::models::ErrorModel),
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`delete_attribute`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum DeleteAttributeError {
71    Status404(crate::models::ErrorModel),
72    Status400(crate::models::ErrorModel),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`delete_contact`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum DeleteContactError {
80    Status404(crate::models::ErrorModel),
81    Status400(crate::models::ErrorModel),
82    Status405(crate::models::ErrorModel),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`delete_folder`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum DeleteFolderError {
90    Status404(crate::models::ErrorModel),
91    Status400(crate::models::ErrorModel),
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`delete_list`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum DeleteListError {
99    Status404(crate::models::ErrorModel),
100    Status400(crate::models::ErrorModel),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`get_attributes`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum GetAttributesError {
108    UnknownValue(serde_json::Value),
109}
110
111/// struct for typed errors of method [`get_contact_info`]
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum GetContactInfoError {
115    Status404(crate::models::ErrorModel),
116    Status400(crate::models::ErrorModel),
117    UnknownValue(serde_json::Value),
118}
119
120/// struct for typed errors of method [`get_contact_stats`]
121#[derive(Debug, Clone, Serialize, Deserialize)]
122#[serde(untagged)]
123pub enum GetContactStatsError {
124    Status404(crate::models::ErrorModel),
125    Status400(crate::models::ErrorModel),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`get_contacts`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum GetContactsError {
133    Status400(crate::models::ErrorModel),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`get_contacts_from_list`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetContactsFromListError {
141    Status400(crate::models::ErrorModel),
142    Status404(crate::models::ErrorModel),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`get_folder`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum GetFolderError {
150    Status404(crate::models::ErrorModel),
151    Status400(crate::models::ErrorModel),
152    UnknownValue(serde_json::Value),
153}
154
155/// struct for typed errors of method [`get_folder_lists`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum GetFolderListsError {
159    Status404(crate::models::ErrorModel),
160    Status400(crate::models::ErrorModel),
161    UnknownValue(serde_json::Value),
162}
163
164/// struct for typed errors of method [`get_folders`]
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum GetFoldersError {
168    Status400(crate::models::ErrorModel),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`get_list`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum GetListError {
176    Status404(crate::models::ErrorModel),
177    Status400(crate::models::ErrorModel),
178    UnknownValue(serde_json::Value),
179}
180
181/// struct for typed errors of method [`get_lists`]
182#[derive(Debug, Clone, Serialize, Deserialize)]
183#[serde(untagged)]
184pub enum GetListsError {
185    Status400(crate::models::ErrorModel),
186    UnknownValue(serde_json::Value),
187}
188
189/// struct for typed errors of method [`import_contacts`]
190#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum ImportContactsError {
193    Status400(crate::models::ErrorModel),
194    UnknownValue(serde_json::Value),
195}
196
197/// struct for typed errors of method [`remove_contact_from_list`]
198#[derive(Debug, Clone, Serialize, Deserialize)]
199#[serde(untagged)]
200pub enum RemoveContactFromListError {
201    Status400(crate::models::ErrorModel),
202    Status404(crate::models::ErrorModel),
203    UnknownValue(serde_json::Value),
204}
205
206/// struct for typed errors of method [`request_contact_export`]
207#[derive(Debug, Clone, Serialize, Deserialize)]
208#[serde(untagged)]
209pub enum RequestContactExportError {
210    Status400(crate::models::ErrorModel),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`update_attribute`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum UpdateAttributeError {
218    Status400(crate::models::ErrorModel),
219    Status404(crate::models::ErrorModel),
220    UnknownValue(serde_json::Value),
221}
222
223/// struct for typed errors of method [`update_contact`]
224#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum UpdateContactError {
227    Status400(crate::models::ErrorModel),
228    Status404(crate::models::ErrorModel),
229    UnknownValue(serde_json::Value),
230}
231
232/// struct for typed errors of method [`update_folder`]
233#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum UpdateFolderError {
236    Status400(crate::models::ErrorModel),
237    Status404(crate::models::ErrorModel),
238    UnknownValue(serde_json::Value),
239}
240
241/// struct for typed errors of method [`update_list`]
242#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum UpdateListError {
245    Status400(crate::models::ErrorModel),
246    Status404(crate::models::ErrorModel),
247    UnknownValue(serde_json::Value),
248}
249
250
251pub async fn add_contact_to_list(configuration: &configuration::Configuration, list_id: i64, contact_emails: crate::models::AddContactToList) -> Result<crate::models::PostContactInfo, Error<AddContactToListError>> {
252    let local_var_configuration = configuration;
253
254    let local_var_client = &local_var_configuration.client;
255
256    let local_var_uri_str = format!("{}/contacts/lists/{listId}/contacts/add", local_var_configuration.base_path, listId=list_id);
257    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
258
259    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
260        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
261    }
262    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
263        let local_var_key = local_var_apikey.key.clone();
264        let local_var_value = match local_var_apikey.prefix {
265            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
266            None => local_var_key,
267        };
268        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
269    };
270    local_var_req_builder = local_var_req_builder.json(&contact_emails);
271
272    let local_var_req = local_var_req_builder.build()?;
273    let local_var_resp = local_var_client.execute(local_var_req).await?;
274
275    let local_var_status = local_var_resp.status();
276    let local_var_content = local_var_resp.text().await?;
277
278    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
279        serde_json::from_str(&local_var_content).map_err(Error::from)
280    } else {
281        let local_var_entity: Option<AddContactToListError> = serde_json::from_str(&local_var_content).ok();
282        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
283        Err(Error::ResponseError(local_var_error))
284    }
285}
286
287pub async fn create_attribute(configuration: &configuration::Configuration, attribute_category: &str, attribute_name: &str, create_attribute: crate::models::CreateAttribute) -> Result<(), Error<CreateAttributeError>> {
288    let local_var_configuration = configuration;
289
290    let local_var_client = &local_var_configuration.client;
291
292    let local_var_uri_str = format!("{}/contacts/attributes/{attributeCategory}/{attributeName}", local_var_configuration.base_path, attributeCategory=crate::apis::urlencode(attribute_category), attributeName=crate::apis::urlencode(attribute_name));
293    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
294
295    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
296        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
297    }
298    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
299        let local_var_key = local_var_apikey.key.clone();
300        let local_var_value = match local_var_apikey.prefix {
301            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
302            None => local_var_key,
303        };
304        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
305    };
306    local_var_req_builder = local_var_req_builder.json(&create_attribute);
307
308    let local_var_req = local_var_req_builder.build()?;
309    let local_var_resp = local_var_client.execute(local_var_req).await?;
310
311    let local_var_status = local_var_resp.status();
312    let local_var_content = local_var_resp.text().await?;
313
314    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
315        Ok(())
316    } else {
317        let local_var_entity: Option<CreateAttributeError> = serde_json::from_str(&local_var_content).ok();
318        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
319        Err(Error::ResponseError(local_var_error))
320    }
321}
322
323pub async fn create_contact(configuration: &configuration::Configuration, create_contact: crate::models::CreateContact) -> Result<crate::models::CreateUpdateContactModel, Error<CreateContactError>> {
324    let local_var_configuration = configuration;
325
326    let local_var_client = &local_var_configuration.client;
327
328    let local_var_uri_str = format!("{}/contacts", local_var_configuration.base_path);
329    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
330
331    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
332        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
333    }
334    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
335        let local_var_key = local_var_apikey.key.clone();
336        let local_var_value = match local_var_apikey.prefix {
337            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
338            None => local_var_key,
339        };
340        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
341    };
342    local_var_req_builder = local_var_req_builder.json(&create_contact);
343
344    let local_var_req = local_var_req_builder.build()?;
345    let local_var_resp = local_var_client.execute(local_var_req).await?;
346
347    let local_var_status = local_var_resp.status();
348    let local_var_content = local_var_resp.text().await?;
349
350    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
351        serde_json::from_str(&local_var_content).map_err(Error::from)
352    } else {
353        let local_var_entity: Option<CreateContactError> = serde_json::from_str(&local_var_content).ok();
354        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
355        Err(Error::ResponseError(local_var_error))
356    }
357}
358
359pub async fn create_doi_contact(configuration: &configuration::Configuration, create_doi_contact: crate::models::CreateDoiContact) -> Result<(), Error<CreateDoiContactError>> {
360    let local_var_configuration = configuration;
361
362    let local_var_client = &local_var_configuration.client;
363
364    let local_var_uri_str = format!("{}/contacts/doubleOptinConfirmation", local_var_configuration.base_path);
365    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
366
367    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
368        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
369    }
370    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
371        let local_var_key = local_var_apikey.key.clone();
372        let local_var_value = match local_var_apikey.prefix {
373            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
374            None => local_var_key,
375        };
376        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
377    };
378    local_var_req_builder = local_var_req_builder.json(&create_doi_contact);
379
380    let local_var_req = local_var_req_builder.build()?;
381    let local_var_resp = local_var_client.execute(local_var_req).await?;
382
383    let local_var_status = local_var_resp.status();
384    let local_var_content = local_var_resp.text().await?;
385
386    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
387        Ok(())
388    } else {
389        let local_var_entity: Option<CreateDoiContactError> = serde_json::from_str(&local_var_content).ok();
390        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
391        Err(Error::ResponseError(local_var_error))
392    }
393}
394
395pub async fn create_folder(configuration: &configuration::Configuration, create_folder: crate::models::CreateUpdateFolder) -> Result<crate::models::CreateModel, Error<CreateFolderError>> {
396    let local_var_configuration = configuration;
397
398    let local_var_client = &local_var_configuration.client;
399
400    let local_var_uri_str = format!("{}/contacts/folders", local_var_configuration.base_path);
401    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
402
403    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
404        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
405    }
406    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
407        let local_var_key = local_var_apikey.key.clone();
408        let local_var_value = match local_var_apikey.prefix {
409            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
410            None => local_var_key,
411        };
412        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
413    };
414    local_var_req_builder = local_var_req_builder.json(&create_folder);
415
416    let local_var_req = local_var_req_builder.build()?;
417    let local_var_resp = local_var_client.execute(local_var_req).await?;
418
419    let local_var_status = local_var_resp.status();
420    let local_var_content = local_var_resp.text().await?;
421
422    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
423        serde_json::from_str(&local_var_content).map_err(Error::from)
424    } else {
425        let local_var_entity: Option<CreateFolderError> = serde_json::from_str(&local_var_content).ok();
426        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
427        Err(Error::ResponseError(local_var_error))
428    }
429}
430
431pub async fn create_list(configuration: &configuration::Configuration, create_list: crate::models::CreateList) -> Result<crate::models::CreateModel, Error<CreateListError>> {
432    let local_var_configuration = configuration;
433
434    let local_var_client = &local_var_configuration.client;
435
436    let local_var_uri_str = format!("{}/contacts/lists", local_var_configuration.base_path);
437    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
438
439    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
440        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
441    }
442    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
443        let local_var_key = local_var_apikey.key.clone();
444        let local_var_value = match local_var_apikey.prefix {
445            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
446            None => local_var_key,
447        };
448        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
449    };
450    local_var_req_builder = local_var_req_builder.json(&create_list);
451
452    let local_var_req = local_var_req_builder.build()?;
453    let local_var_resp = local_var_client.execute(local_var_req).await?;
454
455    let local_var_status = local_var_resp.status();
456    let local_var_content = local_var_resp.text().await?;
457
458    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
459        serde_json::from_str(&local_var_content).map_err(Error::from)
460    } else {
461        let local_var_entity: Option<CreateListError> = serde_json::from_str(&local_var_content).ok();
462        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
463        Err(Error::ResponseError(local_var_error))
464    }
465}
466
467pub async fn delete_attribute(configuration: &configuration::Configuration, attribute_category: &str, attribute_name: &str) -> Result<(), Error<DeleteAttributeError>> {
468    let local_var_configuration = configuration;
469
470    let local_var_client = &local_var_configuration.client;
471
472    let local_var_uri_str = format!("{}/contacts/attributes/{attributeCategory}/{attributeName}", local_var_configuration.base_path, attributeCategory=crate::apis::urlencode(attribute_category), attributeName=crate::apis::urlencode(attribute_name));
473    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
474
475    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
476        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
477    }
478    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
479        let local_var_key = local_var_apikey.key.clone();
480        let local_var_value = match local_var_apikey.prefix {
481            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
482            None => local_var_key,
483        };
484        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
485    };
486
487    let local_var_req = local_var_req_builder.build()?;
488    let local_var_resp = local_var_client.execute(local_var_req).await?;
489
490    let local_var_status = local_var_resp.status();
491    let local_var_content = local_var_resp.text().await?;
492
493    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
494        Ok(())
495    } else {
496        let local_var_entity: Option<DeleteAttributeError> = serde_json::from_str(&local_var_content).ok();
497        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
498        Err(Error::ResponseError(local_var_error))
499    }
500}
501
502pub async fn delete_contact(configuration: &configuration::Configuration, email: &str) -> Result<(), Error<DeleteContactError>> {
503    let local_var_configuration = configuration;
504
505    let local_var_client = &local_var_configuration.client;
506
507    let local_var_uri_str = format!("{}/contacts/{email}", local_var_configuration.base_path, email=crate::apis::urlencode(email));
508    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
509
510    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
511        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
512    }
513    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
514        let local_var_key = local_var_apikey.key.clone();
515        let local_var_value = match local_var_apikey.prefix {
516            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
517            None => local_var_key,
518        };
519        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
520    };
521
522    let local_var_req = local_var_req_builder.build()?;
523    let local_var_resp = local_var_client.execute(local_var_req).await?;
524
525    let local_var_status = local_var_resp.status();
526    let local_var_content = local_var_resp.text().await?;
527
528    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
529        Ok(())
530    } else {
531        let local_var_entity: Option<DeleteContactError> = serde_json::from_str(&local_var_content).ok();
532        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
533        Err(Error::ResponseError(local_var_error))
534    }
535}
536
537pub async fn delete_folder(configuration: &configuration::Configuration, folder_id: i64) -> Result<(), Error<DeleteFolderError>> {
538    let local_var_configuration = configuration;
539
540    let local_var_client = &local_var_configuration.client;
541
542    let local_var_uri_str = format!("{}/contacts/folders/{folderId}", local_var_configuration.base_path, folderId=folder_id);
543    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
544
545    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
546        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
547    }
548    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
549        let local_var_key = local_var_apikey.key.clone();
550        let local_var_value = match local_var_apikey.prefix {
551            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
552            None => local_var_key,
553        };
554        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
555    };
556
557    let local_var_req = local_var_req_builder.build()?;
558    let local_var_resp = local_var_client.execute(local_var_req).await?;
559
560    let local_var_status = local_var_resp.status();
561    let local_var_content = local_var_resp.text().await?;
562
563    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
564        Ok(())
565    } else {
566        let local_var_entity: Option<DeleteFolderError> = serde_json::from_str(&local_var_content).ok();
567        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
568        Err(Error::ResponseError(local_var_error))
569    }
570}
571
572pub async fn delete_list(configuration: &configuration::Configuration, list_id: i64) -> Result<(), Error<DeleteListError>> {
573    let local_var_configuration = configuration;
574
575    let local_var_client = &local_var_configuration.client;
576
577    let local_var_uri_str = format!("{}/contacts/lists/{listId}", local_var_configuration.base_path, listId=list_id);
578    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
579
580    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
581        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
582    }
583    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
584        let local_var_key = local_var_apikey.key.clone();
585        let local_var_value = match local_var_apikey.prefix {
586            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
587            None => local_var_key,
588        };
589        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
590    };
591
592    let local_var_req = local_var_req_builder.build()?;
593    let local_var_resp = local_var_client.execute(local_var_req).await?;
594
595    let local_var_status = local_var_resp.status();
596    let local_var_content = local_var_resp.text().await?;
597
598    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
599        Ok(())
600    } else {
601        let local_var_entity: Option<DeleteListError> = serde_json::from_str(&local_var_content).ok();
602        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
603        Err(Error::ResponseError(local_var_error))
604    }
605}
606
607pub async fn get_attributes(configuration: &configuration::Configuration, ) -> Result<crate::models::GetAttributes, Error<GetAttributesError>> {
608    let local_var_configuration = configuration;
609
610    let local_var_client = &local_var_configuration.client;
611
612    let local_var_uri_str = format!("{}/contacts/attributes", local_var_configuration.base_path);
613    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
614
615    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
616        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
617    }
618    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
619        let local_var_key = local_var_apikey.key.clone();
620        let local_var_value = match local_var_apikey.prefix {
621            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
622            None => local_var_key,
623        };
624        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
625    };
626
627    let local_var_req = local_var_req_builder.build()?;
628    let local_var_resp = local_var_client.execute(local_var_req).await?;
629
630    let local_var_status = local_var_resp.status();
631    let local_var_content = local_var_resp.text().await?;
632
633    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
634        serde_json::from_str(&local_var_content).map_err(Error::from)
635    } else {
636        let local_var_entity: Option<GetAttributesError> = serde_json::from_str(&local_var_content).ok();
637        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
638        Err(Error::ResponseError(local_var_error))
639    }
640}
641
642pub async fn get_contact_info(configuration: &configuration::Configuration, email: &str) -> Result<crate::models::GetExtendedContactDetails, Error<GetContactInfoError>> {
643    let local_var_configuration = configuration;
644
645    let local_var_client = &local_var_configuration.client;
646
647    let local_var_uri_str = format!("{}/contacts/{email}", local_var_configuration.base_path, email=crate::apis::urlencode(email));
648    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
649
650    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
651        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
652    }
653    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
654        let local_var_key = local_var_apikey.key.clone();
655        let local_var_value = match local_var_apikey.prefix {
656            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
657            None => local_var_key,
658        };
659        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
660    };
661
662    let local_var_req = local_var_req_builder.build()?;
663    let local_var_resp = local_var_client.execute(local_var_req).await?;
664
665    let local_var_status = local_var_resp.status();
666    let local_var_content = local_var_resp.text().await?;
667
668    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
669        serde_json::from_str(&local_var_content).map_err(Error::from)
670    } else {
671        let local_var_entity: Option<GetContactInfoError> = serde_json::from_str(&local_var_content).ok();
672        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
673        Err(Error::ResponseError(local_var_error))
674    }
675}
676
677pub async fn get_contact_stats(configuration: &configuration::Configuration, email: &str, start_date: Option<String>, end_date: Option<String>) -> Result<crate::models::GetContactCampaignStats, Error<GetContactStatsError>> {
678    let local_var_configuration = configuration;
679
680    let local_var_client = &local_var_configuration.client;
681
682    let local_var_uri_str = format!("{}/contacts/{email}/campaignStats", local_var_configuration.base_path, email=crate::apis::urlencode(email));
683    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
684
685    if let Some(ref local_var_str) = start_date {
686        local_var_req_builder = local_var_req_builder.query(&[("startDate", &local_var_str.to_string())]);
687    }
688    if let Some(ref local_var_str) = end_date {
689        local_var_req_builder = local_var_req_builder.query(&[("endDate", &local_var_str.to_string())]);
690    }
691    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
692        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
693    }
694    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
695        let local_var_key = local_var_apikey.key.clone();
696        let local_var_value = match local_var_apikey.prefix {
697            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
698            None => local_var_key,
699        };
700        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
701    };
702
703    let local_var_req = local_var_req_builder.build()?;
704    let local_var_resp = local_var_client.execute(local_var_req).await?;
705
706    let local_var_status = local_var_resp.status();
707    let local_var_content = local_var_resp.text().await?;
708
709    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
710        serde_json::from_str(&local_var_content).map_err(Error::from)
711    } else {
712        let local_var_entity: Option<GetContactStatsError> = serde_json::from_str(&local_var_content).ok();
713        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
714        Err(Error::ResponseError(local_var_error))
715    }
716}
717
718pub async fn get_contacts(configuration: &configuration::Configuration, limit: Option<i64>, offset: Option<i64>, modified_since: Option<String>, sort: Option<&str>) -> Result<crate::models::GetContacts, Error<GetContactsError>> {
719    let local_var_configuration = configuration;
720
721    let local_var_client = &local_var_configuration.client;
722
723    let local_var_uri_str = format!("{}/contacts", local_var_configuration.base_path);
724    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
725
726    if let Some(ref local_var_str) = limit {
727        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
728    }
729    if let Some(ref local_var_str) = offset {
730        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
731    }
732    if let Some(ref local_var_str) = modified_since {
733        local_var_req_builder = local_var_req_builder.query(&[("modifiedSince", &local_var_str.to_string())]);
734    }
735    if let Some(ref local_var_str) = sort {
736        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
737    }
738    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
739        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
740    }
741    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
742        let local_var_key = local_var_apikey.key.clone();
743        let local_var_value = match local_var_apikey.prefix {
744            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
745            None => local_var_key,
746        };
747        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
748    };
749
750    let local_var_req = local_var_req_builder.build()?;
751    let local_var_resp = local_var_client.execute(local_var_req).await?;
752
753    let local_var_status = local_var_resp.status();
754    let local_var_content = local_var_resp.text().await?;
755
756    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
757        serde_json::from_str(&local_var_content).map_err(Error::from)
758    } else {
759        let local_var_entity: Option<GetContactsError> = serde_json::from_str(&local_var_content).ok();
760        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
761        Err(Error::ResponseError(local_var_error))
762    }
763}
764
765pub async fn get_contacts_from_list(configuration: &configuration::Configuration, list_id: i64, modified_since: Option<String>, limit: Option<i64>, offset: Option<i64>, sort: Option<&str>) -> Result<crate::models::GetContacts, Error<GetContactsFromListError>> {
766    let local_var_configuration = configuration;
767
768    let local_var_client = &local_var_configuration.client;
769
770    let local_var_uri_str = format!("{}/contacts/lists/{listId}/contacts", local_var_configuration.base_path, listId=list_id);
771    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
772
773    if let Some(ref local_var_str) = modified_since {
774        local_var_req_builder = local_var_req_builder.query(&[("modifiedSince", &local_var_str.to_string())]);
775    }
776    if let Some(ref local_var_str) = limit {
777        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
778    }
779    if let Some(ref local_var_str) = offset {
780        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
781    }
782    if let Some(ref local_var_str) = sort {
783        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
784    }
785    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
786        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
787    }
788    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
789        let local_var_key = local_var_apikey.key.clone();
790        let local_var_value = match local_var_apikey.prefix {
791            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
792            None => local_var_key,
793        };
794        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
795    };
796
797    let local_var_req = local_var_req_builder.build()?;
798    let local_var_resp = local_var_client.execute(local_var_req).await?;
799
800    let local_var_status = local_var_resp.status();
801    let local_var_content = local_var_resp.text().await?;
802
803    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
804        serde_json::from_str(&local_var_content).map_err(Error::from)
805    } else {
806        let local_var_entity: Option<GetContactsFromListError> = serde_json::from_str(&local_var_content).ok();
807        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
808        Err(Error::ResponseError(local_var_error))
809    }
810}
811
812pub async fn get_folder(configuration: &configuration::Configuration, folder_id: i64) -> Result<crate::models::GetFolder, Error<GetFolderError>> {
813    let local_var_configuration = configuration;
814
815    let local_var_client = &local_var_configuration.client;
816
817    let local_var_uri_str = format!("{}/contacts/folders/{folderId}", local_var_configuration.base_path, folderId=folder_id);
818    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
819
820    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
821        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
822    }
823    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
824        let local_var_key = local_var_apikey.key.clone();
825        let local_var_value = match local_var_apikey.prefix {
826            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
827            None => local_var_key,
828        };
829        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
830    };
831
832    let local_var_req = local_var_req_builder.build()?;
833    let local_var_resp = local_var_client.execute(local_var_req).await?;
834
835    let local_var_status = local_var_resp.status();
836    let local_var_content = local_var_resp.text().await?;
837
838    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
839        serde_json::from_str(&local_var_content).map_err(Error::from)
840    } else {
841        let local_var_entity: Option<GetFolderError> = serde_json::from_str(&local_var_content).ok();
842        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
843        Err(Error::ResponseError(local_var_error))
844    }
845}
846
847pub async fn get_folder_lists(configuration: &configuration::Configuration, folder_id: i64, limit: Option<i64>, offset: Option<i64>, sort: Option<&str>) -> Result<crate::models::GetFolderLists, Error<GetFolderListsError>> {
848    let local_var_configuration = configuration;
849
850    let local_var_client = &local_var_configuration.client;
851
852    let local_var_uri_str = format!("{}/contacts/folders/{folderId}/lists", local_var_configuration.base_path, folderId=folder_id);
853    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
854
855    if let Some(ref local_var_str) = limit {
856        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
857    }
858    if let Some(ref local_var_str) = offset {
859        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
860    }
861    if let Some(ref local_var_str) = sort {
862        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
863    }
864    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
865        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
866    }
867    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
868        let local_var_key = local_var_apikey.key.clone();
869        let local_var_value = match local_var_apikey.prefix {
870            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
871            None => local_var_key,
872        };
873        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
874    };
875
876    let local_var_req = local_var_req_builder.build()?;
877    let local_var_resp = local_var_client.execute(local_var_req).await?;
878
879    let local_var_status = local_var_resp.status();
880    let local_var_content = local_var_resp.text().await?;
881
882    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
883        serde_json::from_str(&local_var_content).map_err(Error::from)
884    } else {
885        let local_var_entity: Option<GetFolderListsError> = serde_json::from_str(&local_var_content).ok();
886        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
887        Err(Error::ResponseError(local_var_error))
888    }
889}
890
891pub async fn get_folders(configuration: &configuration::Configuration, limit: i64, offset: i64, sort: Option<&str>) -> Result<crate::models::GetFolders, Error<GetFoldersError>> {
892    let local_var_configuration = configuration;
893
894    let local_var_client = &local_var_configuration.client;
895
896    let local_var_uri_str = format!("{}/contacts/folders", local_var_configuration.base_path);
897    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
898
899    local_var_req_builder = local_var_req_builder.query(&[("limit", &limit.to_string())]);
900    local_var_req_builder = local_var_req_builder.query(&[("offset", &offset.to_string())]);
901    if let Some(ref local_var_str) = sort {
902        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
903    }
904    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
905        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
906    }
907    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
908        let local_var_key = local_var_apikey.key.clone();
909        let local_var_value = match local_var_apikey.prefix {
910            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
911            None => local_var_key,
912        };
913        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
914    };
915
916    let local_var_req = local_var_req_builder.build()?;
917    let local_var_resp = local_var_client.execute(local_var_req).await?;
918
919    let local_var_status = local_var_resp.status();
920    let local_var_content = local_var_resp.text().await?;
921
922    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
923        serde_json::from_str(&local_var_content).map_err(Error::from)
924    } else {
925        let local_var_entity: Option<GetFoldersError> = serde_json::from_str(&local_var_content).ok();
926        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
927        Err(Error::ResponseError(local_var_error))
928    }
929}
930
931pub async fn get_list(configuration: &configuration::Configuration, list_id: i64) -> Result<crate::models::GetExtendedList, Error<GetListError>> {
932    let local_var_configuration = configuration;
933
934    let local_var_client = &local_var_configuration.client;
935
936    let local_var_uri_str = format!("{}/contacts/lists/{listId}", local_var_configuration.base_path, listId=list_id);
937    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
938
939    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
940        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
941    }
942    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
943        let local_var_key = local_var_apikey.key.clone();
944        let local_var_value = match local_var_apikey.prefix {
945            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
946            None => local_var_key,
947        };
948        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
949    };
950
951    let local_var_req = local_var_req_builder.build()?;
952    let local_var_resp = local_var_client.execute(local_var_req).await?;
953
954    let local_var_status = local_var_resp.status();
955    let local_var_content = local_var_resp.text().await?;
956
957    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
958        serde_json::from_str(&local_var_content).map_err(Error::from)
959    } else {
960        let local_var_entity: Option<GetListError> = serde_json::from_str(&local_var_content).ok();
961        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
962        Err(Error::ResponseError(local_var_error))
963    }
964}
965
966pub async fn get_lists(configuration: &configuration::Configuration, limit: Option<i64>, offset: Option<i64>, sort: Option<&str>) -> Result<crate::models::GetLists, Error<GetListsError>> {
967    let local_var_configuration = configuration;
968
969    let local_var_client = &local_var_configuration.client;
970
971    let local_var_uri_str = format!("{}/contacts/lists", local_var_configuration.base_path);
972    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
973
974    if let Some(ref local_var_str) = limit {
975        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
976    }
977    if let Some(ref local_var_str) = offset {
978        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
979    }
980    if let Some(ref local_var_str) = sort {
981        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
982    }
983    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
984        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
985    }
986    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
987        let local_var_key = local_var_apikey.key.clone();
988        let local_var_value = match local_var_apikey.prefix {
989            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
990            None => local_var_key,
991        };
992        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
993    };
994
995    let local_var_req = local_var_req_builder.build()?;
996    let local_var_resp = local_var_client.execute(local_var_req).await?;
997
998    let local_var_status = local_var_resp.status();
999    let local_var_content = local_var_resp.text().await?;
1000
1001    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1002        serde_json::from_str(&local_var_content).map_err(Error::from)
1003    } else {
1004        let local_var_entity: Option<GetListsError> = serde_json::from_str(&local_var_content).ok();
1005        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1006        Err(Error::ResponseError(local_var_error))
1007    }
1008}
1009
1010/// It returns the background process ID which on completion calls the notify URL that you have set in the input.
1011pub async fn import_contacts(configuration: &configuration::Configuration, request_contact_import: crate::models::RequestContactImport) -> Result<crate::models::CreatedProcessId, Error<ImportContactsError>> {
1012    let local_var_configuration = configuration;
1013
1014    let local_var_client = &local_var_configuration.client;
1015
1016    let local_var_uri_str = format!("{}/contacts/import", local_var_configuration.base_path);
1017    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1018
1019    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1020        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1021    }
1022    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1023        let local_var_key = local_var_apikey.key.clone();
1024        let local_var_value = match local_var_apikey.prefix {
1025            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1026            None => local_var_key,
1027        };
1028        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1029    };
1030    local_var_req_builder = local_var_req_builder.json(&request_contact_import);
1031
1032    let local_var_req = local_var_req_builder.build()?;
1033    let local_var_resp = local_var_client.execute(local_var_req).await?;
1034
1035    let local_var_status = local_var_resp.status();
1036    let local_var_content = local_var_resp.text().await?;
1037
1038    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1039        serde_json::from_str(&local_var_content).map_err(Error::from)
1040    } else {
1041        let local_var_entity: Option<ImportContactsError> = serde_json::from_str(&local_var_content).ok();
1042        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1043        Err(Error::ResponseError(local_var_error))
1044    }
1045}
1046
1047pub async fn remove_contact_from_list(configuration: &configuration::Configuration, list_id: i64, contact_emails: crate::models::RemoveContactFromList) -> Result<crate::models::PostContactInfo, Error<RemoveContactFromListError>> {
1048    let local_var_configuration = configuration;
1049
1050    let local_var_client = &local_var_configuration.client;
1051
1052    let local_var_uri_str = format!("{}/contacts/lists/{listId}/contacts/remove", local_var_configuration.base_path, listId=list_id);
1053    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1054
1055    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1056        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1057    }
1058    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1059        let local_var_key = local_var_apikey.key.clone();
1060        let local_var_value = match local_var_apikey.prefix {
1061            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1062            None => local_var_key,
1063        };
1064        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1065    };
1066    local_var_req_builder = local_var_req_builder.json(&contact_emails);
1067
1068    let local_var_req = local_var_req_builder.build()?;
1069    let local_var_resp = local_var_client.execute(local_var_req).await?;
1070
1071    let local_var_status = local_var_resp.status();
1072    let local_var_content = local_var_resp.text().await?;
1073
1074    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1075        serde_json::from_str(&local_var_content).map_err(Error::from)
1076    } else {
1077        let local_var_entity: Option<RemoveContactFromListError> = serde_json::from_str(&local_var_content).ok();
1078        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1079        Err(Error::ResponseError(local_var_error))
1080    }
1081}
1082
1083/// It returns the background process ID which on completion calls the notify URL that you have set in the input. File will be available in csv.
1084pub async fn request_contact_export(configuration: &configuration::Configuration, request_contact_export: crate::models::RequestContactExport) -> Result<crate::models::CreatedProcessId, Error<RequestContactExportError>> {
1085    let local_var_configuration = configuration;
1086
1087    let local_var_client = &local_var_configuration.client;
1088
1089    let local_var_uri_str = format!("{}/contacts/export", local_var_configuration.base_path);
1090    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1091
1092    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1093        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1094    }
1095    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1096        let local_var_key = local_var_apikey.key.clone();
1097        let local_var_value = match local_var_apikey.prefix {
1098            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1099            None => local_var_key,
1100        };
1101        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1102    };
1103    local_var_req_builder = local_var_req_builder.json(&request_contact_export);
1104
1105    let local_var_req = local_var_req_builder.build()?;
1106    let local_var_resp = local_var_client.execute(local_var_req).await?;
1107
1108    let local_var_status = local_var_resp.status();
1109    let local_var_content = local_var_resp.text().await?;
1110
1111    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1112        serde_json::from_str(&local_var_content).map_err(Error::from)
1113    } else {
1114        let local_var_entity: Option<RequestContactExportError> = serde_json::from_str(&local_var_content).ok();
1115        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1116        Err(Error::ResponseError(local_var_error))
1117    }
1118}
1119
1120pub async fn update_attribute(configuration: &configuration::Configuration, attribute_category: &str, attribute_name: &str, update_attribute: crate::models::UpdateAttribute) -> Result<(), Error<UpdateAttributeError>> {
1121    let local_var_configuration = configuration;
1122
1123    let local_var_client = &local_var_configuration.client;
1124
1125    let local_var_uri_str = format!("{}/contacts/attributes/{attributeCategory}/{attributeName}", local_var_configuration.base_path, attributeCategory=crate::apis::urlencode(attribute_category), attributeName=crate::apis::urlencode(attribute_name));
1126    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1127
1128    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1129        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1130    }
1131    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1132        let local_var_key = local_var_apikey.key.clone();
1133        let local_var_value = match local_var_apikey.prefix {
1134            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1135            None => local_var_key,
1136        };
1137        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1138    };
1139    local_var_req_builder = local_var_req_builder.json(&update_attribute);
1140
1141    let local_var_req = local_var_req_builder.build()?;
1142    let local_var_resp = local_var_client.execute(local_var_req).await?;
1143
1144    let local_var_status = local_var_resp.status();
1145    let local_var_content = local_var_resp.text().await?;
1146
1147    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1148        Ok(())
1149    } else {
1150        let local_var_entity: Option<UpdateAttributeError> = serde_json::from_str(&local_var_content).ok();
1151        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1152        Err(Error::ResponseError(local_var_error))
1153    }
1154}
1155
1156pub async fn update_contact(configuration: &configuration::Configuration, email: &str, update_contact: crate::models::UpdateContact) -> Result<(), Error<UpdateContactError>> {
1157    let local_var_configuration = configuration;
1158
1159    let local_var_client = &local_var_configuration.client;
1160
1161    let local_var_uri_str = format!("{}/contacts/{email}", local_var_configuration.base_path, email=crate::apis::urlencode(email));
1162    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1163
1164    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1165        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1166    }
1167    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1168        let local_var_key = local_var_apikey.key.clone();
1169        let local_var_value = match local_var_apikey.prefix {
1170            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1171            None => local_var_key,
1172        };
1173        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1174    };
1175    local_var_req_builder = local_var_req_builder.json(&update_contact);
1176
1177    let local_var_req = local_var_req_builder.build()?;
1178    let local_var_resp = local_var_client.execute(local_var_req).await?;
1179
1180    let local_var_status = local_var_resp.status();
1181    let local_var_content = local_var_resp.text().await?;
1182
1183    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1184        Ok(())
1185    } else {
1186        let local_var_entity: Option<UpdateContactError> = serde_json::from_str(&local_var_content).ok();
1187        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1188        Err(Error::ResponseError(local_var_error))
1189    }
1190}
1191
1192pub async fn update_folder(configuration: &configuration::Configuration, folder_id: i64, update_folder: crate::models::CreateUpdateFolder) -> Result<(), Error<UpdateFolderError>> {
1193    let local_var_configuration = configuration;
1194
1195    let local_var_client = &local_var_configuration.client;
1196
1197    let local_var_uri_str = format!("{}/contacts/folders/{folderId}", local_var_configuration.base_path, folderId=folder_id);
1198    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1199
1200    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1201        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1202    }
1203    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1204        let local_var_key = local_var_apikey.key.clone();
1205        let local_var_value = match local_var_apikey.prefix {
1206            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1207            None => local_var_key,
1208        };
1209        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1210    };
1211    local_var_req_builder = local_var_req_builder.json(&update_folder);
1212
1213    let local_var_req = local_var_req_builder.build()?;
1214    let local_var_resp = local_var_client.execute(local_var_req).await?;
1215
1216    let local_var_status = local_var_resp.status();
1217    let local_var_content = local_var_resp.text().await?;
1218
1219    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1220        Ok(())
1221    } else {
1222        let local_var_entity: Option<UpdateFolderError> = serde_json::from_str(&local_var_content).ok();
1223        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1224        Err(Error::ResponseError(local_var_error))
1225    }
1226}
1227
1228pub async fn update_list(configuration: &configuration::Configuration, list_id: i64, update_list: crate::models::UpdateList) -> Result<(), Error<UpdateListError>> {
1229    let local_var_configuration = configuration;
1230
1231    let local_var_client = &local_var_configuration.client;
1232
1233    let local_var_uri_str = format!("{}/contacts/lists/{listId}", local_var_configuration.base_path, listId=list_id);
1234    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
1235
1236    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
1237        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
1238    }
1239    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
1240        let local_var_key = local_var_apikey.key.clone();
1241        let local_var_value = match local_var_apikey.prefix {
1242            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
1243            None => local_var_key,
1244        };
1245        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
1246    };
1247    local_var_req_builder = local_var_req_builder.json(&update_list);
1248
1249    let local_var_req = local_var_req_builder.build()?;
1250    let local_var_resp = local_var_client.execute(local_var_req).await?;
1251
1252    let local_var_status = local_var_resp.status();
1253    let local_var_content = local_var_resp.text().await?;
1254
1255    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1256        Ok(())
1257    } else {
1258        let local_var_entity: Option<UpdateListError> = serde_json::from_str(&local_var_content).ok();
1259        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
1260        Err(Error::ResponseError(local_var_error))
1261    }
1262}
1263