thunkmetrc_client/services/
processing_job.rs1use crate::client::MetrcClient;
2use serde_json::Value;
3use std::error::Error;
4
5pub struct ProcessingJobClient<'a> {
6 pub(crate) client: &'a MetrcClient,
7}
8
9impl<'a> ProcessingJobClient<'a> {
10 pub async fn create_adjust_processing_job(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
18 let mut path = format!("/processing/v2/adjust");
19 let mut query_params = Vec::new();
20 if let Some(p) = license_number {
21 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
22 }
23 if !query_params.is_empty() {
24 path.push_str("?");
25 path.push_str(&query_params.join("&"));
26 }
27
28 self.client.send(reqwest::Method::POST, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
29 }
30 pub async fn create_processing_job_job_types(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
38 let mut path = format!("/processing/v2/jobtypes");
39 let mut query_params = Vec::new();
40 if let Some(p) = license_number {
41 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
42 }
43 if !query_params.is_empty() {
44 path.push_str("?");
45 path.push_str(&query_params.join("&"));
46 }
47
48 self.client.send(reqwest::Method::POST, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
49 }
50 pub async fn create_processing_job_packages(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
58 let mut path = format!("/processing/v2/createpackages");
59 let mut query_params = Vec::new();
60 if let Some(p) = license_number {
61 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
62 }
63 if !query_params.is_empty() {
64 path.push_str("?");
65 path.push_str(&query_params.join("&"));
66 }
67
68 self.client.send(reqwest::Method::POST, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
69 }
70 pub async fn delete_processing_job_job_type_by_id(&self, id: &str, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
78 let mut path = format!("/processing/v2/jobtypes/{}", urlencoding::encode(id).as_ref());
79 let mut query_params = Vec::new();
80 if let Some(p) = license_number {
81 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
82 }
83 if !query_params.is_empty() {
84 path.push_str("?");
85 path.push_str(&query_params.join("&"));
86 }
87
88 self.client.send(reqwest::Method::DELETE, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
89 }
90 pub async fn delete_processing_job_by_id(&self, id: &str, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
98 let mut path = format!("/processing/v2/{}", urlencoding::encode(id).as_ref());
99 let mut query_params = Vec::new();
100 if let Some(p) = license_number {
101 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
102 }
103 if !query_params.is_empty() {
104 path.push_str("?");
105 path.push_str(&query_params.join("&"));
106 }
107
108 self.client.send(reqwest::Method::DELETE, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
109 }
110 pub async fn finish_processing_job_processing_job(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
118 let mut path = format!("/processing/v2/finish");
119 let mut query_params = Vec::new();
120 if let Some(p) = license_number {
121 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
122 }
123 if !query_params.is_empty() {
124 path.push_str("?");
125 path.push_str(&query_params.join("&"));
126 }
127
128 self.client.send(reqwest::Method::PUT, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
129 }
130 pub async fn get_processing_job_active_job_types(&self, last_modified_end: Option<String>, last_modified_start: Option<String>, license_number: Option<String>, page_number: Option<String>, page_size: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
141 let mut path = format!("/processing/v2/jobtypes/active");
142 let mut query_params = Vec::new();
143 if let Some(p) = last_modified_end {
144 query_params.push(format!("lastModifiedEnd={}", urlencoding::encode(&p)));
145 }
146 if let Some(p) = last_modified_start {
147 query_params.push(format!("lastModifiedStart={}", urlencoding::encode(&p)));
148 }
149 if let Some(p) = license_number {
150 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
151 }
152 if let Some(p) = page_number {
153 query_params.push(format!("pageNumber={}", urlencoding::encode(&p)));
154 }
155 if let Some(p) = page_size {
156 query_params.push(format!("pageSize={}", urlencoding::encode(&p)));
157 }
158 if !query_params.is_empty() {
159 path.push_str("?");
160 path.push_str(&query_params.join("&"));
161 }
162
163 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
164 }
165 pub async fn get_active_processing_job(&self, last_modified_end: Option<String>, last_modified_start: Option<String>, license_number: Option<String>, page_number: Option<String>, page_size: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
176 let mut path = format!("/processing/v2/active");
177 let mut query_params = Vec::new();
178 if let Some(p) = last_modified_end {
179 query_params.push(format!("lastModifiedEnd={}", urlencoding::encode(&p)));
180 }
181 if let Some(p) = last_modified_start {
182 query_params.push(format!("lastModifiedStart={}", urlencoding::encode(&p)));
183 }
184 if let Some(p) = license_number {
185 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
186 }
187 if let Some(p) = page_number {
188 query_params.push(format!("pageNumber={}", urlencoding::encode(&p)));
189 }
190 if let Some(p) = page_size {
191 query_params.push(format!("pageSize={}", urlencoding::encode(&p)));
192 }
193 if !query_params.is_empty() {
194 path.push_str("?");
195 path.push_str(&query_params.join("&"));
196 }
197
198 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
199 }
200 pub async fn get_processing_job_inactive_job_types(&self, last_modified_end: Option<String>, last_modified_start: Option<String>, license_number: Option<String>, page_number: Option<String>, page_size: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
211 let mut path = format!("/processing/v2/jobtypes/inactive");
212 let mut query_params = Vec::new();
213 if let Some(p) = last_modified_end {
214 query_params.push(format!("lastModifiedEnd={}", urlencoding::encode(&p)));
215 }
216 if let Some(p) = last_modified_start {
217 query_params.push(format!("lastModifiedStart={}", urlencoding::encode(&p)));
218 }
219 if let Some(p) = license_number {
220 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
221 }
222 if let Some(p) = page_number {
223 query_params.push(format!("pageNumber={}", urlencoding::encode(&p)));
224 }
225 if let Some(p) = page_size {
226 query_params.push(format!("pageSize={}", urlencoding::encode(&p)));
227 }
228 if !query_params.is_empty() {
229 path.push_str("?");
230 path.push_str(&query_params.join("&"));
231 }
232
233 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
234 }
235 pub async fn get_inactive_processing_job(&self, last_modified_end: Option<String>, last_modified_start: Option<String>, license_number: Option<String>, page_number: Option<String>, page_size: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
246 let mut path = format!("/processing/v2/inactive");
247 let mut query_params = Vec::new();
248 if let Some(p) = last_modified_end {
249 query_params.push(format!("lastModifiedEnd={}", urlencoding::encode(&p)));
250 }
251 if let Some(p) = last_modified_start {
252 query_params.push(format!("lastModifiedStart={}", urlencoding::encode(&p)));
253 }
254 if let Some(p) = license_number {
255 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
256 }
257 if let Some(p) = page_number {
258 query_params.push(format!("pageNumber={}", urlencoding::encode(&p)));
259 }
260 if let Some(p) = page_size {
261 query_params.push(format!("pageSize={}", urlencoding::encode(&p)));
262 }
263 if !query_params.is_empty() {
264 path.push_str("?");
265 path.push_str(&query_params.join("&"));
266 }
267
268 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
269 }
270 pub async fn get_processing_job_job_types_attributes(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
277 let mut path = format!("/processing/v2/jobtypes/attributes");
278 let mut query_params = Vec::new();
279 if let Some(p) = license_number {
280 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
281 }
282 if !query_params.is_empty() {
283 path.push_str("?");
284 path.push_str(&query_params.join("&"));
285 }
286
287 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
288 }
289 pub async fn get_processing_job_job_types_categories(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
296 let mut path = format!("/processing/v2/jobtypes/categories");
297 let mut query_params = Vec::new();
298 if let Some(p) = license_number {
299 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
300 }
301 if !query_params.is_empty() {
302 path.push_str("?");
303 path.push_str(&query_params.join("&"));
304 }
305
306 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
307 }
308 pub async fn get_processing_job_by_id(&self, id: &str, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
316 let mut path = format!("/processing/v2/{}", urlencoding::encode(id).as_ref());
317 let mut query_params = Vec::new();
318 if let Some(p) = license_number {
319 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
320 }
321 if !query_params.is_empty() {
322 path.push_str("?");
323 path.push_str(&query_params.join("&"));
324 }
325
326 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
327 }
328 pub async fn start_processing_job_processing_job(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
336 let mut path = format!("/processing/v2/start");
337 let mut query_params = Vec::new();
338 if let Some(p) = license_number {
339 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
340 }
341 if !query_params.is_empty() {
342 path.push_str("?");
343 path.push_str(&query_params.join("&"));
344 }
345
346 self.client.send(reqwest::Method::POST, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
347 }
348 pub async fn unfinish_processing_job_processing_job(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
356 let mut path = format!("/processing/v2/unfinish");
357 let mut query_params = Vec::new();
358 if let Some(p) = license_number {
359 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
360 }
361 if !query_params.is_empty() {
362 path.push_str("?");
363 path.push_str(&query_params.join("&"));
364 }
365
366 self.client.send(reqwest::Method::PUT, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
367 }
368 pub async fn update_processing_job_job_types(&self, license_number: Option<String>, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
376 let mut path = format!("/processing/v2/jobtypes");
377 let mut query_params = Vec::new();
378 if let Some(p) = license_number {
379 query_params.push(format!("licenseNumber={}", urlencoding::encode(&p)));
380 }
381 if !query_params.is_empty() {
382 path.push_str("?");
383 path.push_str(&query_params.join("&"));
384 }
385
386 self.client.send(reqwest::Method::PUT, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
387 }
388}
389