sendinblue_v3/apis/
reseller_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_credits`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddCreditsError {
22    Status400(crate::models::ErrorModel),
23    Status404(crate::models::ErrorModel),
24    Status403(crate::models::ErrorModel),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`associate_ip_to_child`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum AssociateIpToChildError {
32    Status400(crate::models::ErrorModel),
33    Status404(crate::models::ErrorModel),
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`create_child_domain`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum CreateChildDomainError {
41    Status400(crate::models::ErrorModel),
42    Status404(crate::models::ErrorModel),
43    Status403(crate::models::ErrorModel),
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`create_reseller_child`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum CreateResellerChildError {
51    Status400(crate::models::ErrorModel),
52    Status403(crate::models::ErrorModel),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`delete_child_domain`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum DeleteChildDomainError {
60    Status404(crate::models::ErrorModel),
61    Status403(crate::models::ErrorModel),
62    Status400(crate::models::ErrorModel),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`delete_reseller_child`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum DeleteResellerChildError {
70    Status404(crate::models::ErrorModel),
71    Status403(crate::models::ErrorModel),
72    Status400(crate::models::ErrorModel),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`dissociate_ip_from_child`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum DissociateIpFromChildError {
80    Status400(crate::models::ErrorModel),
81    Status404(crate::models::ErrorModel),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`get_child_account_creation_status`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum GetChildAccountCreationStatusError {
89    Status400(crate::models::ErrorModel),
90    Status404(crate::models::ErrorModel),
91    Status403(crate::models::ErrorModel),
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`get_child_domains`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetChildDomainsError {
99    Status403(crate::models::ErrorModel),
100    Status404(crate::models::ErrorModel),
101    Status400(crate::models::ErrorModel),
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`get_child_info`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum GetChildInfoError {
109    Status403(crate::models::ErrorModel),
110    Status404(crate::models::ErrorModel),
111    Status400(crate::models::ErrorModel),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`get_reseller_childs`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum GetResellerChildsError {
119    Status403(crate::models::ErrorModel),
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`get_sso_token`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum GetSsoTokenError {
127    Status403(crate::models::ErrorModel),
128    Status404(crate::models::ErrorModel),
129    Status400(crate::models::ErrorModel),
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`remove_credits`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum RemoveCreditsError {
137    Status400(crate::models::ErrorModel),
138    Status404(crate::models::ErrorModel),
139    Status403(crate::models::ErrorModel),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`update_child_account_status`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum UpdateChildAccountStatusError {
147    Status404(crate::models::ErrorModel),
148    Status400(crate::models::ErrorModel),
149    Status403(crate::models::ErrorModel),
150    UnknownValue(serde_json::Value),
151}
152
153/// struct for typed errors of method [`update_child_domain`]
154#[derive(Debug, Clone, Serialize, Deserialize)]
155#[serde(untagged)]
156pub enum UpdateChildDomainError {
157    Status404(crate::models::ErrorModel),
158    Status400(crate::models::ErrorModel),
159    Status403(crate::models::ErrorModel),
160    UnknownValue(serde_json::Value),
161}
162
163/// struct for typed errors of method [`update_reseller_child`]
164#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum UpdateResellerChildError {
167    Status404(crate::models::ErrorModel),
168    Status400(crate::models::ErrorModel),
169    Status403(crate::models::ErrorModel),
170    UnknownValue(serde_json::Value),
171}
172
173
174pub async fn add_credits(configuration: &configuration::Configuration, child_identifier: &str, add_credits: crate::models::AddCredits) -> Result<crate::models::RemainingCreditModel, Error<AddCreditsError>> {
175    let local_var_configuration = configuration;
176
177    let local_var_client = &local_var_configuration.client;
178
179    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/credits/add", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
180    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
181
182    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
183        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
184    }
185    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
186        let local_var_key = local_var_apikey.key.clone();
187        let local_var_value = match local_var_apikey.prefix {
188            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
189            None => local_var_key,
190        };
191        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
192    };
193    local_var_req_builder = local_var_req_builder.json(&add_credits);
194
195    let local_var_req = local_var_req_builder.build()?;
196    let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198    let local_var_status = local_var_resp.status();
199    let local_var_content = local_var_resp.text().await?;
200
201    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202        serde_json::from_str(&local_var_content).map_err(Error::from)
203    } else {
204        let local_var_entity: Option<AddCreditsError> = serde_json::from_str(&local_var_content).ok();
205        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
206        Err(Error::ResponseError(local_var_error))
207    }
208}
209
210pub async fn associate_ip_to_child(configuration: &configuration::Configuration, child_identifier: &str, ip: crate::models::ManageIp) -> Result<(), Error<AssociateIpToChildError>> {
211    let local_var_configuration = configuration;
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/ips/associate", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
219        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
220    }
221    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
222        let local_var_key = local_var_apikey.key.clone();
223        let local_var_value = match local_var_apikey.prefix {
224            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
225            None => local_var_key,
226        };
227        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
228    };
229    local_var_req_builder = local_var_req_builder.json(&ip);
230
231    let local_var_req = local_var_req_builder.build()?;
232    let local_var_resp = local_var_client.execute(local_var_req).await?;
233
234    let local_var_status = local_var_resp.status();
235    let local_var_content = local_var_resp.text().await?;
236
237    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
238        Ok(())
239    } else {
240        let local_var_entity: Option<AssociateIpToChildError> = serde_json::from_str(&local_var_content).ok();
241        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
242        Err(Error::ResponseError(local_var_error))
243    }
244}
245
246pub async fn create_child_domain(configuration: &configuration::Configuration, child_identifier: &str, add_child_domain: crate::models::AddChildDomain) -> Result<(), Error<CreateChildDomainError>> {
247    let local_var_configuration = configuration;
248
249    let local_var_client = &local_var_configuration.client;
250
251    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/domains", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
252    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
253
254    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
255        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
256    }
257    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
258        let local_var_key = local_var_apikey.key.clone();
259        let local_var_value = match local_var_apikey.prefix {
260            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
261            None => local_var_key,
262        };
263        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
264    };
265    local_var_req_builder = local_var_req_builder.json(&add_child_domain);
266
267    let local_var_req = local_var_req_builder.build()?;
268    let local_var_resp = local_var_client.execute(local_var_req).await?;
269
270    let local_var_status = local_var_resp.status();
271    let local_var_content = local_var_resp.text().await?;
272
273    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
274        Ok(())
275    } else {
276        let local_var_entity: Option<CreateChildDomainError> = serde_json::from_str(&local_var_content).ok();
277        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
278        Err(Error::ResponseError(local_var_error))
279    }
280}
281
282pub async fn create_reseller_child(configuration: &configuration::Configuration, reseller_child: Option<crate::models::CreateChild>) -> Result<crate::models::CreateReseller, Error<CreateResellerChildError>> {
283    let local_var_configuration = configuration;
284
285    let local_var_client = &local_var_configuration.client;
286
287    let local_var_uri_str = format!("{}/reseller/children", local_var_configuration.base_path);
288    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
289
290    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
291        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
292    }
293    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
294        let local_var_key = local_var_apikey.key.clone();
295        let local_var_value = match local_var_apikey.prefix {
296            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
297            None => local_var_key,
298        };
299        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
300    };
301    local_var_req_builder = local_var_req_builder.json(&reseller_child);
302
303    let local_var_req = local_var_req_builder.build()?;
304    let local_var_resp = local_var_client.execute(local_var_req).await?;
305
306    let local_var_status = local_var_resp.status();
307    let local_var_content = local_var_resp.text().await?;
308
309    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
310        serde_json::from_str(&local_var_content).map_err(Error::from)
311    } else {
312        let local_var_entity: Option<CreateResellerChildError> = serde_json::from_str(&local_var_content).ok();
313        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
314        Err(Error::ResponseError(local_var_error))
315    }
316}
317
318pub async fn delete_child_domain(configuration: &configuration::Configuration, child_identifier: &str, domain_name: &str) -> Result<(), Error<DeleteChildDomainError>> {
319    let local_var_configuration = configuration;
320
321    let local_var_client = &local_var_configuration.client;
322
323    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/domains/{domainName}", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier), domainName=crate::apis::urlencode(domain_name));
324    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
325
326    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
327        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
328    }
329    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
330        let local_var_key = local_var_apikey.key.clone();
331        let local_var_value = match local_var_apikey.prefix {
332            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
333            None => local_var_key,
334        };
335        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
336    };
337
338    let local_var_req = local_var_req_builder.build()?;
339    let local_var_resp = local_var_client.execute(local_var_req).await?;
340
341    let local_var_status = local_var_resp.status();
342    let local_var_content = local_var_resp.text().await?;
343
344    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
345        Ok(())
346    } else {
347        let local_var_entity: Option<DeleteChildDomainError> = serde_json::from_str(&local_var_content).ok();
348        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
349        Err(Error::ResponseError(local_var_error))
350    }
351}
352
353pub async fn delete_reseller_child(configuration: &configuration::Configuration, child_identifier: &str) -> Result<(), Error<DeleteResellerChildError>> {
354    let local_var_configuration = configuration;
355
356    let local_var_client = &local_var_configuration.client;
357
358    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
359    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
360
361    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
362        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
363    }
364    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
365        let local_var_key = local_var_apikey.key.clone();
366        let local_var_value = match local_var_apikey.prefix {
367            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
368            None => local_var_key,
369        };
370        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
371    };
372
373    let local_var_req = local_var_req_builder.build()?;
374    let local_var_resp = local_var_client.execute(local_var_req).await?;
375
376    let local_var_status = local_var_resp.status();
377    let local_var_content = local_var_resp.text().await?;
378
379    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
380        Ok(())
381    } else {
382        let local_var_entity: Option<DeleteResellerChildError> = serde_json::from_str(&local_var_content).ok();
383        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
384        Err(Error::ResponseError(local_var_error))
385    }
386}
387
388pub async fn dissociate_ip_from_child(configuration: &configuration::Configuration, child_identifier: &str, ip: crate::models::ManageIp) -> Result<(), Error<DissociateIpFromChildError>> {
389    let local_var_configuration = configuration;
390
391    let local_var_client = &local_var_configuration.client;
392
393    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/ips/dissociate", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
394    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
395
396    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
397        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
398    }
399    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
400        let local_var_key = local_var_apikey.key.clone();
401        let local_var_value = match local_var_apikey.prefix {
402            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
403            None => local_var_key,
404        };
405        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
406    };
407    local_var_req_builder = local_var_req_builder.json(&ip);
408
409    let local_var_req = local_var_req_builder.build()?;
410    let local_var_resp = local_var_client.execute(local_var_req).await?;
411
412    let local_var_status = local_var_resp.status();
413    let local_var_content = local_var_resp.text().await?;
414
415    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
416        Ok(())
417    } else {
418        let local_var_entity: Option<DissociateIpFromChildError> = serde_json::from_str(&local_var_content).ok();
419        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
420        Err(Error::ResponseError(local_var_error))
421    }
422}
423
424pub async fn get_child_account_creation_status(configuration: &configuration::Configuration, child_identifier: &str) -> Result<crate::models::GetChildAccountCreationStatus, Error<GetChildAccountCreationStatusError>> {
425    let local_var_configuration = configuration;
426
427    let local_var_client = &local_var_configuration.client;
428
429    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/accountCreationStatus", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
430    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
431
432    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
433        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
434    }
435    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
436        let local_var_key = local_var_apikey.key.clone();
437        let local_var_value = match local_var_apikey.prefix {
438            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
439            None => local_var_key,
440        };
441        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
442    };
443
444    let local_var_req = local_var_req_builder.build()?;
445    let local_var_resp = local_var_client.execute(local_var_req).await?;
446
447    let local_var_status = local_var_resp.status();
448    let local_var_content = local_var_resp.text().await?;
449
450    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
451        serde_json::from_str(&local_var_content).map_err(Error::from)
452    } else {
453        let local_var_entity: Option<GetChildAccountCreationStatusError> = serde_json::from_str(&local_var_content).ok();
454        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
455        Err(Error::ResponseError(local_var_error))
456    }
457}
458
459pub async fn get_child_domains(configuration: &configuration::Configuration, child_identifier: &str) -> Result<Vec<crate::models::GetChildDomainsInner>, Error<GetChildDomainsError>> {
460    let local_var_configuration = configuration;
461
462    let local_var_client = &local_var_configuration.client;
463
464    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/domains", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
465    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
466
467    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
468        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
469    }
470    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
471        let local_var_key = local_var_apikey.key.clone();
472        let local_var_value = match local_var_apikey.prefix {
473            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
474            None => local_var_key,
475        };
476        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
477    };
478
479    let local_var_req = local_var_req_builder.build()?;
480    let local_var_resp = local_var_client.execute(local_var_req).await?;
481
482    let local_var_status = local_var_resp.status();
483    let local_var_content = local_var_resp.text().await?;
484
485    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
486        serde_json::from_str(&local_var_content).map_err(Error::from)
487    } else {
488        let local_var_entity: Option<GetChildDomainsError> = serde_json::from_str(&local_var_content).ok();
489        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
490        Err(Error::ResponseError(local_var_error))
491    }
492}
493
494pub async fn get_child_info(configuration: &configuration::Configuration, child_identifier: &str) -> Result<crate::models::GetChildInfo, Error<GetChildInfoError>> {
495    let local_var_configuration = configuration;
496
497    let local_var_client = &local_var_configuration.client;
498
499    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
500    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
501
502    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
503        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
504    }
505    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
506        let local_var_key = local_var_apikey.key.clone();
507        let local_var_value = match local_var_apikey.prefix {
508            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
509            None => local_var_key,
510        };
511        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
512    };
513
514    let local_var_req = local_var_req_builder.build()?;
515    let local_var_resp = local_var_client.execute(local_var_req).await?;
516
517    let local_var_status = local_var_resp.status();
518    let local_var_content = local_var_resp.text().await?;
519
520    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
521        serde_json::from_str(&local_var_content).map_err(Error::from)
522    } else {
523        let local_var_entity: Option<GetChildInfoError> = serde_json::from_str(&local_var_content).ok();
524        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
525        Err(Error::ResponseError(local_var_error))
526    }
527}
528
529pub async fn get_reseller_childs(configuration: &configuration::Configuration, limit: Option<i64>, offset: Option<i64>) -> Result<crate::models::GetChildrenList, Error<GetResellerChildsError>> {
530    let local_var_configuration = configuration;
531
532    let local_var_client = &local_var_configuration.client;
533
534    let local_var_uri_str = format!("{}/reseller/children", local_var_configuration.base_path);
535    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
536
537    if let Some(ref local_var_str) = limit {
538        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
539    }
540    if let Some(ref local_var_str) = offset {
541        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
542    }
543    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
544        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
545    }
546    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
547        let local_var_key = local_var_apikey.key.clone();
548        let local_var_value = match local_var_apikey.prefix {
549            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
550            None => local_var_key,
551        };
552        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
553    };
554
555    let local_var_req = local_var_req_builder.build()?;
556    let local_var_resp = local_var_client.execute(local_var_req).await?;
557
558    let local_var_status = local_var_resp.status();
559    let local_var_content = local_var_resp.text().await?;
560
561    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
562        serde_json::from_str(&local_var_content).map_err(Error::from)
563    } else {
564        let local_var_entity: Option<GetResellerChildsError> = serde_json::from_str(&local_var_content).ok();
565        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
566        Err(Error::ResponseError(local_var_error))
567    }
568}
569
570/// It returns a session [token] which will remain valid for a short period of time. A child account will be able to access a white-labeled section by using the following url pattern => https:/email.mydomain.com/login/sso?token=[token]
571pub async fn get_sso_token(configuration: &configuration::Configuration, child_identifier: &str) -> Result<crate::models::GetSsoToken, Error<GetSsoTokenError>> {
572    let local_var_configuration = configuration;
573
574    let local_var_client = &local_var_configuration.client;
575
576    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/auth", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
577    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
578
579    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
580        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
581    }
582    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
583        let local_var_key = local_var_apikey.key.clone();
584        let local_var_value = match local_var_apikey.prefix {
585            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
586            None => local_var_key,
587        };
588        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
589    };
590
591    let local_var_req = local_var_req_builder.build()?;
592    let local_var_resp = local_var_client.execute(local_var_req).await?;
593
594    let local_var_status = local_var_resp.status();
595    let local_var_content = local_var_resp.text().await?;
596
597    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
598        serde_json::from_str(&local_var_content).map_err(Error::from)
599    } else {
600        let local_var_entity: Option<GetSsoTokenError> = serde_json::from_str(&local_var_content).ok();
601        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
602        Err(Error::ResponseError(local_var_error))
603    }
604}
605
606pub async fn remove_credits(configuration: &configuration::Configuration, child_identifier: &str, remove_credits: crate::models::RemoveCredits) -> Result<crate::models::RemainingCreditModel, Error<RemoveCreditsError>> {
607    let local_var_configuration = configuration;
608
609    let local_var_client = &local_var_configuration.client;
610
611    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/credits/remove", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
612    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
613
614    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
615        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
616    }
617    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
618        let local_var_key = local_var_apikey.key.clone();
619        let local_var_value = match local_var_apikey.prefix {
620            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
621            None => local_var_key,
622        };
623        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
624    };
625    local_var_req_builder = local_var_req_builder.json(&remove_credits);
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<RemoveCreditsError> = 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 update_child_account_status(configuration: &configuration::Configuration, child_identifier: &str, update_child_account_status: crate::models::UpdateChildAccountStatus) -> Result<(), Error<UpdateChildAccountStatusError>> {
643    let local_var_configuration = configuration;
644
645    let local_var_client = &local_var_configuration.client;
646
647    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/accountStatus", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
648    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, 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    local_var_req_builder = local_var_req_builder.json(&update_child_account_status);
662
663    let local_var_req = local_var_req_builder.build()?;
664    let local_var_resp = local_var_client.execute(local_var_req).await?;
665
666    let local_var_status = local_var_resp.status();
667    let local_var_content = local_var_resp.text().await?;
668
669    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
670        Ok(())
671    } else {
672        let local_var_entity: Option<UpdateChildAccountStatusError> = serde_json::from_str(&local_var_content).ok();
673        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
674        Err(Error::ResponseError(local_var_error))
675    }
676}
677
678pub async fn update_child_domain(configuration: &configuration::Configuration, child_identifier: &str, domain_name: &str, update_child_domain: crate::models::UpdateChildDomain) -> Result<(), Error<UpdateChildDomainError>> {
679    let local_var_configuration = configuration;
680
681    let local_var_client = &local_var_configuration.client;
682
683    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}/domains/{domainName}", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier), domainName=crate::apis::urlencode(domain_name));
684    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
685
686    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
687        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
688    }
689    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
690        let local_var_key = local_var_apikey.key.clone();
691        let local_var_value = match local_var_apikey.prefix {
692            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
693            None => local_var_key,
694        };
695        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
696    };
697    local_var_req_builder = local_var_req_builder.json(&update_child_domain);
698
699    let local_var_req = local_var_req_builder.build()?;
700    let local_var_resp = local_var_client.execute(local_var_req).await?;
701
702    let local_var_status = local_var_resp.status();
703    let local_var_content = local_var_resp.text().await?;
704
705    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
706        Ok(())
707    } else {
708        let local_var_entity: Option<UpdateChildDomainError> = serde_json::from_str(&local_var_content).ok();
709        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
710        Err(Error::ResponseError(local_var_error))
711    }
712}
713
714pub async fn update_reseller_child(configuration: &configuration::Configuration, child_identifier: &str, reseller_child: crate::models::UpdateChild) -> Result<(), Error<UpdateResellerChildError>> {
715    let local_var_configuration = configuration;
716
717    let local_var_client = &local_var_configuration.client;
718
719    let local_var_uri_str = format!("{}/reseller/children/{childIdentifier}", local_var_configuration.base_path, childIdentifier=crate::apis::urlencode(child_identifier));
720    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
721
722    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
723        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
724    }
725    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
726        let local_var_key = local_var_apikey.key.clone();
727        let local_var_value = match local_var_apikey.prefix {
728            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
729            None => local_var_key,
730        };
731        local_var_req_builder = local_var_req_builder.header("api-key", local_var_value);
732    };
733    local_var_req_builder = local_var_req_builder.json(&reseller_child);
734
735    let local_var_req = local_var_req_builder.build()?;
736    let local_var_resp = local_var_client.execute(local_var_req).await?;
737
738    let local_var_status = local_var_resp.status();
739    let local_var_content = local_var_resp.text().await?;
740
741    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
742        Ok(())
743    } else {
744        let local_var_entity: Option<UpdateResellerChildError> = serde_json::from_str(&local_var_content).ok();
745        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
746        Err(Error::ResponseError(local_var_error))
747    }
748}
749