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
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, RequestOptions};
use reqwest::Method;
pub struct TransportClient {
pub http_client: HttpClient,
}
impl TransportClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// Create a draft waybill to the consignee. The cargo lines are `lines` or, when none are given and `saleInvoiceId` is set, the product lines of that sale invoice (422 when it has none); a line without `description`, `unit` or `productCode` takes them from its item. `documentDate` defaults to the company's today and `series` to `VAZ`.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn waybills_create(
&self,
request: &WaybillsCreateTransportRequest,
options: Option<RequestOptions>,
) -> Result<WaybillsCreateTransportResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v1/transport/waybills/create",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Change a draft waybill; omitted fields keep their value, the optional ones can be cleared with null, and `lines`, when given, replace all existing lines. A waybill that is already issued or cancelled is refused with 409.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn waybills_update(
&self,
request: &WaybillsUpdateTransportRequest,
options: Option<RequestOptions>,
) -> Result<WaybillsUpdateTransportResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v1/transport/waybills/update",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Issue a draft waybill: it takes the next number of its `series` for the year of `documentDate` and becomes `issued`. Without a vehicle plate or without lines the call is refused with 422, a waybill that is not a draft with 409. Only issued waybills can go into the Lithuanian i.VAZ file (`declarations/lt/ivaz/generate`) and the Romanian e-Transport declaration (`declarations/ro/etransport/build`).
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn waybills_issue(
&self,
request: &WaybillsIssueTransportRequest,
options: Option<RequestOptions>,
) -> Result<WaybillsIssueTransportResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v1/transport/waybills/issue",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Cancel a draft or issued waybill. An already cancelled one is refused with 409.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn waybills_cancel(
&self,
request: &WaybillsCancelTransportRequest,
options: Option<RequestOptions>,
) -> Result<WaybillsCancelTransportResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v1/transport/waybills/cancel",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Read one waybill with its lines.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn waybills_get(
&self,
request: &WaybillsGetTransportRequest,
options: Option<RequestOptions>,
) -> Result<WaybillsGetTransportResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v1/transport/waybills/get",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// List waybills with the consignee's name. Filterable by `status`, `consigneePartnerId`, `documentDate`, `fullNumber` and `dispatchAt`; sortable by `createdAt`, `dispatchAt` and `fullNumber`.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn waybills_list(
&self,
request: &WaybillsListTransportRequest,
options: Option<RequestOptions>,
) -> Result<WaybillsListTransportResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v1/transport/waybills/list",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
}