Skip to main content

linkbreakers/apis/
qr_code_designs_api.rs

1/*
2 * Linkbreakers API
3 *
4 * This is a documentation of all the APIs of Linkbreakers
5 *
6 * The version of the OpenAPI document: 1.131.8
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`qrcode_design_service_apply_template`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum QrcodeDesignServiceApplyTemplateError {
22    DefaultResponse(models::ErrorResponse),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`qrcode_design_service_delete`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum QrcodeDesignServiceDeleteError {
30    DefaultResponse(models::ErrorResponse),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`qrcode_design_service_get`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum QrcodeDesignServiceGetError {
38    DefaultResponse(models::ErrorResponse),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`qrcode_design_service_public_create`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum QrcodeDesignServicePublicCreateError {
46    DefaultResponse(models::ErrorResponse),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`qrcode_design_service_update`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum QrcodeDesignServiceUpdateError {
54    DefaultResponse(models::ErrorResponse),
55    UnknownValue(serde_json::Value),
56}
57
58
59/// Copy all design settings from a community QR code template to an existing link's QR code design. This replaces the current design with the template's styling.
60pub async fn qrcode_design_service_apply_template(configuration: &configuration::Configuration, apply_qrcode_template_request: models::ApplyQrcodeTemplateRequest) -> Result<models::ApplyQrcodeTemplateResponse, Error<QrcodeDesignServiceApplyTemplateError>> {
61    // add a prefix to parameters to efficiently prevent name collisions
62    let p_body_apply_qrcode_template_request = apply_qrcode_template_request;
63
64    let uri_str = format!("{}/v1/qrcode-designs/apply-template", configuration.base_path);
65    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
66
67    if let Some(ref user_agent) = configuration.user_agent {
68        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
69    }
70    if let Some(ref token) = configuration.bearer_access_token {
71        req_builder = req_builder.bearer_auth(token.to_owned());
72    };
73    req_builder = req_builder.json(&p_body_apply_qrcode_template_request);
74
75    let req = req_builder.build()?;
76    let resp = configuration.client.execute(req).await?;
77
78    let status = resp.status();
79    let content_type = resp
80        .headers()
81        .get("content-type")
82        .and_then(|v| v.to_str().ok())
83        .unwrap_or("application/octet-stream");
84    let content_type = super::ContentType::from(content_type);
85
86    if !status.is_client_error() && !status.is_server_error() {
87        let content = resp.text().await?;
88        match content_type {
89            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
90            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplyQrcodeTemplateResponse`"))),
91            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApplyQrcodeTemplateResponse`")))),
92        }
93    } else {
94        let content = resp.text().await?;
95        let entity: Option<QrcodeDesignServiceApplyTemplateError> = serde_json::from_str(&content).ok();
96        Err(Error::ResponseError(ResponseContent { status, content, entity }))
97    }
98}
99
100/// Remove a QR code design that is no longer in use by any assets.
101pub async fn qrcode_design_service_delete(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<QrcodeDesignServiceDeleteError>> {
102    // add a prefix to parameters to efficiently prevent name collisions
103    let p_path_id = id;
104
105    let uri_str = format!("{}/v1/qrcode-designs/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
106    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
107
108    if let Some(ref user_agent) = configuration.user_agent {
109        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
110    }
111    if let Some(ref token) = configuration.bearer_access_token {
112        req_builder = req_builder.bearer_auth(token.to_owned());
113    };
114
115    let req = req_builder.build()?;
116    let resp = configuration.client.execute(req).await?;
117
118    let status = resp.status();
119    let content_type = resp
120        .headers()
121        .get("content-type")
122        .and_then(|v| v.to_str().ok())
123        .unwrap_or("application/octet-stream");
124    let content_type = super::ContentType::from(content_type);
125
126    if !status.is_client_error() && !status.is_server_error() {
127        let content = resp.text().await?;
128        match content_type {
129            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
130            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
131            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
132        }
133    } else {
134        let content = resp.text().await?;
135        let entity: Option<QrcodeDesignServiceDeleteError> = serde_json::from_str(&content).ok();
136        Err(Error::ResponseError(ResponseContent { status, content, entity }))
137    }
138}
139
140/// Fetch a QR code design by its identifier including computed metadata.
141pub async fn qrcode_design_service_get(configuration: &configuration::Configuration, id: &str) -> Result<models::GetQrcodeDesignResponse, Error<QrcodeDesignServiceGetError>> {
142    // add a prefix to parameters to efficiently prevent name collisions
143    let p_path_id = id;
144
145    let uri_str = format!("{}/v1/qrcode-designs/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
146    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
147
148    if let Some(ref user_agent) = configuration.user_agent {
149        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
150    }
151    if let Some(ref token) = configuration.bearer_access_token {
152        req_builder = req_builder.bearer_auth(token.to_owned());
153    };
154
155    let req = req_builder.build()?;
156    let resp = configuration.client.execute(req).await?;
157
158    let status = resp.status();
159    let content_type = resp
160        .headers()
161        .get("content-type")
162        .and_then(|v| v.to_str().ok())
163        .unwrap_or("application/octet-stream");
164    let content_type = super::ContentType::from(content_type);
165
166    if !status.is_client_error() && !status.is_server_error() {
167        let content = resp.text().await?;
168        match content_type {
169            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
170            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetQrcodeDesignResponse`"))),
171            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetQrcodeDesignResponse`")))),
172        }
173    } else {
174        let content = resp.text().await?;
175        let entity: Option<QrcodeDesignServiceGetError> = serde_json::from_str(&content).ok();
176        Err(Error::ResponseError(ResponseContent { status, content, entity }))
177    }
178}
179
180/// Provision a QR code styling preset that can be reused across links or templates.
181pub async fn qrcode_design_service_public_create(configuration: &configuration::Configuration, public_create_qrcode_design_request: models::PublicCreateQrcodeDesignRequest) -> Result<models::PublicCreateQrcodeDesignResponse, Error<QrcodeDesignServicePublicCreateError>> {
182    // add a prefix to parameters to efficiently prevent name collisions
183    let p_body_public_create_qrcode_design_request = public_create_qrcode_design_request;
184
185    let uri_str = format!("{}/v1/public/qrcode-designs", configuration.base_path);
186    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
187
188    if let Some(ref user_agent) = configuration.user_agent {
189        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
190    }
191    if let Some(ref token) = configuration.bearer_access_token {
192        req_builder = req_builder.bearer_auth(token.to_owned());
193    };
194    req_builder = req_builder.json(&p_body_public_create_qrcode_design_request);
195
196    let req = req_builder.build()?;
197    let resp = configuration.client.execute(req).await?;
198
199    let status = resp.status();
200    let content_type = resp
201        .headers()
202        .get("content-type")
203        .and_then(|v| v.to_str().ok())
204        .unwrap_or("application/octet-stream");
205    let content_type = super::ContentType::from(content_type);
206
207    if !status.is_client_error() && !status.is_server_error() {
208        let content = resp.text().await?;
209        match content_type {
210            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
211            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PublicCreateQrcodeDesignResponse`"))),
212            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PublicCreateQrcodeDesignResponse`")))),
213        }
214    } else {
215        let content = resp.text().await?;
216        let entity: Option<QrcodeDesignServicePublicCreateError> = serde_json::from_str(&content).ok();
217        Err(Error::ResponseError(ResponseContent { status, content, entity }))
218    }
219}
220
221/// Apply styling tweaks or media changes to an existing QR code design.
222pub async fn qrcode_design_service_update(configuration: &configuration::Configuration, id: &str, qrcode_design_service_update_body: models::QrcodeDesignServiceUpdateBody) -> Result<models::UpdateQrcodeDesignResponse, Error<QrcodeDesignServiceUpdateError>> {
223    // add a prefix to parameters to efficiently prevent name collisions
224    let p_path_id = id;
225    let p_body_qrcode_design_service_update_body = qrcode_design_service_update_body;
226
227    let uri_str = format!("{}/v1/qrcode-designs/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
228    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
229
230    if let Some(ref user_agent) = configuration.user_agent {
231        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
232    }
233    if let Some(ref token) = configuration.bearer_access_token {
234        req_builder = req_builder.bearer_auth(token.to_owned());
235    };
236    req_builder = req_builder.json(&p_body_qrcode_design_service_update_body);
237
238    let req = req_builder.build()?;
239    let resp = configuration.client.execute(req).await?;
240
241    let status = resp.status();
242    let content_type = resp
243        .headers()
244        .get("content-type")
245        .and_then(|v| v.to_str().ok())
246        .unwrap_or("application/octet-stream");
247    let content_type = super::ContentType::from(content_type);
248
249    if !status.is_client_error() && !status.is_server_error() {
250        let content = resp.text().await?;
251        match content_type {
252            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
253            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateQrcodeDesignResponse`"))),
254            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateQrcodeDesignResponse`")))),
255        }
256    } else {
257        let content = resp.text().await?;
258        let entity: Option<QrcodeDesignServiceUpdateError> = serde_json::from_str(&content).ok();
259        Err(Error::ResponseError(ResponseContent { status, content, entity }))
260    }
261}
262