nordlet 0.5.6

Official Rust SDK for the Nordlet Accounting API
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, RequestOptions};
use reqwest::Method;

pub struct CatalogClient {
    pub http_client: HttpClient,
}

impl CatalogClient {
    pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
        Ok(Self {
            http_client: HttpClient::new(config.clone())?,
        })
    }

    /// Create a catalog item: a product, a service or a set of other items. `unit` must be `vnt`, a global measurement unit or one of the company's own units (`catalog/units/options`), the sale, purchase and expense account codes must be postable accounts of the chart, and `priceFrom`/`priceTo` and `validFrom`/`validTo` must be in order; otherwise 422. A `set` needs at least one component and none of them may be a set; `components` on any other type is refused with 422. 409 when an active item already carries the `code`. `documentRef` is the storage key of a file uploaded with `files/upload`, which is attached to the item. Emits `item.created`.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_create(
        &self,
        request: &ItemsCreateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsCreateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/create",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Return one item; a set comes with its components.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_get(
        &self,
        request: &ItemsGetCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsGetCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/get",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Change the fields of an item; the fields that are nullable in the request can be set to null to clear them. The checks of `catalog/items/create` apply. `components` replaces the whole component list and is accepted only when the item is or becomes a set (422); turning an item into a set needs components and is refused with 409 while the item is itself a component of another set. Turning a set into another type removes its components. 409 when an active item already carries the new `code`. Emits `item.updated`.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_update(
        &self,
        request: &ItemsUpdateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsUpdateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/update",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Soft-delete an item. Refused with 409 while the item is a component of an active set. Emits `item.deleted`.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_delete(
        &self,
        request: &ItemsDeleteCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsDeleteCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/delete",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the active items. Filterable: name, code, barcode, type, vatClassifierCode, groupId, kindId, externalId, manufacturer, department. Sortable: name, code, createdAt, updatedAt, salePriceExclVat; default name ascending. Rows carry no components; `catalog/items/get` returns them.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_list(
        &self,
        request: &ItemsListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the files attached to an item, newest first.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_files_list(
        &self,
        request: &ItemsFilesListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsFilesListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/files/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create an item kind: a code, a name, the SAF-T item type, whether quantities are accounted for, and a sort order. 409 when the code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_kinds_create(
        &self,
        request: &ItemsKindsCreateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsKindsCreateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/kinds/create",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Change an item kind. 409 when the new code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_kinds_update(
        &self,
        request: &ItemsKindsUpdateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsKindsUpdateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/kinds/update",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Delete an item kind. Refused with 409 while an active item uses it; soft-deleted items that still carry it are detached.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_kinds_delete(
        &self,
        request: &ItemsKindsDeleteCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsKindsDeleteCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/kinds/delete",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the company's item kinds in sort order, then by code.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_kinds_list(
        &self,
        request: &ItemsKindsListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsKindsListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/kinds/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create a unit of measure of the company's own, in addition to the global measurement units (`reference/units/list`). 409 when the code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn units_create(
        &self,
        request: &UnitsCreateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<UnitsCreateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/units/create",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Change the code, name or active flag of a company unit. 409 when the new code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn units_update(
        &self,
        request: &UnitsUpdateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<UnitsUpdateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/units/update",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Delete a company unit of measure.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn units_delete(
        &self,
        request: &UnitsDeleteCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<UnitsDeleteCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/units/delete",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the company's own units of measure, ordered by code.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn units_list(
        &self,
        request: &UnitsListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<UnitsListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/units/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Return the unit codes an item can use: the company's active own units first, then the global measurement units, named in the requested `locale` (Lithuanian for `lt`, English otherwise). A company unit hides a global unit with the same code.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn units_options(
        &self,
        request: &UnitsOptionsCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<UnitsOptionsCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/units/options",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create an item group, optionally under `parentId`. 409 when the code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn item_groups_create(
        &self,
        request: &ItemGroupsCreateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemGroupsCreateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/item-groups/create",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Change the code, name or parent of an item group; `parentId` null moves it to the top level. 422 when the new parent is the group itself or one of its descendants. 409 when the new code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn item_groups_update(
        &self,
        request: &ItemGroupsUpdateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemGroupsUpdateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/item-groups/update",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Delete an item group. Refused with 409 while it has child groups or active items assigned.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn item_groups_delete(
        &self,
        request: &ItemGroupsDeleteCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemGroupsDeleteCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/item-groups/delete",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the company's item groups, ordered by code.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn item_groups_list(
        &self,
        request: &ItemGroupsListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemGroupsListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/item-groups/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create or replace the supplier record of an item for a partner (one per item and partner): supplier code, purchase price excluding VAT, currency (EUR when omitted) and notes. Fields omitted from the request are cleared on an existing record.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_suppliers_upsert(
        &self,
        request: &ItemsSuppliersUpsertCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsSuppliersUpsertCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/suppliers/upsert",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the supplier records, optionally for one `itemId` and/or `partnerId`, ordered by partner name.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_suppliers_list(
        &self,
        request: &ItemsSuppliersListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsSuppliersListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/suppliers/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Delete the supplier record of an item.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn items_suppliers_delete(
        &self,
        request: &ItemsSuppliersDeleteCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<ItemsSuppliersDeleteCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/items/suppliers/delete",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Create a price list (currency EUR and active when omitted). 409 when the code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn price_lists_create(
        &self,
        request: &PriceListsCreateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<PriceListsCreateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/price-lists/create",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Change a price list. 409 when the new code already exists.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn price_lists_update(
        &self,
        request: &PriceListsUpdateCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<PriceListsUpdateCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/price-lists/update",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the company's price lists, ordered by code.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn price_lists_list(
        &self,
        request: &PriceListsListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<PriceListsListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/price-lists/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Set the unit price excluding VAT of up to 500 items on a price list; a price already on the list is replaced and the other items on the list are kept. 422 when an item appears twice in the request. Emits `price_list.updated` with the item ids.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn price_lists_items_set(
        &self,
        request: &PriceListsItemsSetCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<PriceListsItemsSetCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/price-lists/items/set",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// List the prices of a price list with the item name and code, ordered by item name.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn price_lists_items_list(
        &self,
        request: &PriceListsItemsListCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<PriceListsItemsListCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/price-lists/items/list",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }

    /// Remove one item from a price list.
    ///
    /// # Arguments
    ///
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    pub async fn price_lists_items_delete(
        &self,
        request: &PriceListsItemsDeleteCatalogRequest,
        options: Option<RequestOptions>,
    ) -> Result<PriceListsItemsDeleteCatalogResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::POST,
                "v1/catalog/price-lists/items/delete",
                Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
                None,
                options,
            )
            .await
    }
}