Skip to main content

thunkmetrc_client/services/
processing_job.rs

1use 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    /// POST CreateAdjustProcessingJob
11    /// Adjusts the details of existing processing jobs at a Facility, including units of measure and associated packages.
12    /// Permissions Required:
13    /// - Manage Processing Job
14    /// Parameters:
15    /// - body (Option<&Value>): Request body
16    /// - license_number (Option<String>): Filter by licenseNumber
17    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    /// POST CreateJobTypes
31    /// Creates new processing job types for a Facility, including name, category, description, steps, and attributes.
32    /// Permissions Required:
33    /// - Manage Processing Job
34    /// Parameters:
35    /// - body (Option<&Value>): Request body
36    /// - license_number (Option<String>): Filter by licenseNumber
37    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    /// POST CreateProcessingJobPackages
51    /// Creates packages from processing jobs at a Facility, including optional location and note assignments.
52    /// Permissions Required:
53    /// - Manage Processing Job
54    /// Parameters:
55    /// - body (Option<&Value>): Request body
56    /// - license_number (Option<String>): Filter by licenseNumber
57    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    /// DELETE DeleteJobTypeById
71    /// Archives a Processing Job Type at a Facility, making it inactive for future use.
72    /// Permissions Required:
73    /// - Manage Processing Job
74    /// Parameters:
75    /// - id (str): Path parameter id
76    /// - license_number (Option<String>): Filter by licenseNumber
77    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    /// DELETE DeleteProcessingJobById
91    /// Archives a Processing Job at a Facility by marking it as inactive and removing it from active use.
92    /// Permissions Required:
93    /// - Manage Processing Job
94    /// Parameters:
95    /// - id (str): Path parameter id
96    /// - license_number (Option<String>): Filter by licenseNumber
97    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    /// PUT FinishProcessingJob
111    /// Completes processing jobs at a Facility by recording final notes and waste measurements.
112    /// Permissions Required:
113    /// - Manage Processing Job
114    /// Parameters:
115    /// - body (Option<&Value>): Request body
116    /// - license_number (Option<String>): Filter by licenseNumber
117    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    /// GET GetActiveJobTypes
131    /// Retrieves a list of all active processing job types defined within a Facility.
132    /// Permissions Required:
133    /// - Manage Processing Job
134    /// Parameters:
135    /// - last_modified_end (Option<String>): Filter by lastModifiedEnd
136    /// - last_modified_start (Option<String>): Filter by lastModifiedStart
137    /// - license_number (Option<String>): Filter by licenseNumber
138    /// - page_number (Option<String>): Filter by pageNumber
139    /// - page_size (Option<String>): Filter by pageSize
140    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    /// GET GetActiveProcessingJob
166    /// Retrieves active processing jobs at a specified Facility.
167    /// Permissions Required:
168    /// - Manage Processing Job
169    /// Parameters:
170    /// - last_modified_end (Option<String>): Filter by lastModifiedEnd
171    /// - last_modified_start (Option<String>): Filter by lastModifiedStart
172    /// - license_number (Option<String>): Filter by licenseNumber
173    /// - page_number (Option<String>): Filter by pageNumber
174    /// - page_size (Option<String>): Filter by pageSize
175    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    /// GET GetInactiveJobTypes
201    /// Retrieves a list of all inactive processing job types defined within a Facility.
202    /// Permissions Required:
203    /// - Manage Processing Job
204    /// Parameters:
205    /// - last_modified_end (Option<String>): Filter by lastModifiedEnd
206    /// - last_modified_start (Option<String>): Filter by lastModifiedStart
207    /// - license_number (Option<String>): Filter by licenseNumber
208    /// - page_number (Option<String>): Filter by pageNumber
209    /// - page_size (Option<String>): Filter by pageSize
210    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    /// GET GetInactiveProcessingJob
236    /// Retrieves inactive processing jobs at a specified Facility.
237    /// Permissions Required:
238    /// - Manage Processing Job
239    /// Parameters:
240    /// - last_modified_end (Option<String>): Filter by lastModifiedEnd
241    /// - last_modified_start (Option<String>): Filter by lastModifiedStart
242    /// - license_number (Option<String>): Filter by licenseNumber
243    /// - page_number (Option<String>): Filter by pageNumber
244    /// - page_size (Option<String>): Filter by pageSize
245    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    /// GET GetJobTypesAttributes
271    /// Retrieves all processing job attributes available for a Facility.
272    /// Permissions Required:
273    /// - Manage Processing Job
274    /// Parameters:
275    /// - license_number (Option<String>): Filter by licenseNumber
276    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    /// GET GetJobTypesCategories
290    /// Retrieves all processing job categories available for a specified Facility.
291    /// Permissions Required:
292    /// - Manage Processing Job
293    /// Parameters:
294    /// - license_number (Option<String>): Filter by licenseNumber
295    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    /// GET GetProcessingJobById
309    /// Retrieves a ProcessingJob by Id.
310    /// Permissions Required:
311    /// - Manage Processing Job
312    /// Parameters:
313    /// - id (str): Path parameter id
314    /// - license_number (Option<String>): Filter by licenseNumber
315    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    /// POST StartProcessingJob
329    /// Initiates new processing jobs at a Facility, including job details and associated packages.
330    /// Permissions Required:
331    /// - Manage Processing Job
332    /// Parameters:
333    /// - body (Option<&Value>): Request body
334    /// - license_number (Option<String>): Filter by licenseNumber
335    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    /// PUT UnfinishProcessingJob
349    /// Reopens previously completed processing jobs at a Facility to allow further updates or corrections.
350    /// Permissions Required:
351    /// - Manage Processing Job
352    /// Parameters:
353    /// - body (Option<&Value>): Request body
354    /// - license_number (Option<String>): Filter by licenseNumber
355    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    /// PUT UpdateJobTypes
369    /// Updates existing processing job types at a Facility, including their name, category, description, steps, and attributes.
370    /// Permissions Required:
371    /// - Manage Processing Job
372    /// Parameters:
373    /// - body (Option<&Value>): Request body
374    /// - license_number (Option<String>): Filter by licenseNumber
375    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