Skip to content

Commit 0bf7f87

Browse files
added new endpoints for ws.ufficiopostale.com
1 parent 6d87e16 commit 0bf7f87

File tree

2 files changed

+263
-177
lines changed

2 files changed

+263
-177
lines changed

src/Services/UfficioPostale.ts

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ interface OpzioniRaccomandata {
4747
ar?: boolean;
4848
}
4949

50+
interface OpzioniLOL {
51+
fronteretro?: boolean;
52+
colori?: boolean;
53+
autoconfirm?: boolean;
54+
}
55+
5056
interface OpzioniTelegramma {
5157
fronteretro?: boolean;
5258
colori?: boolean;
@@ -154,9 +160,12 @@ export class UfficioPostale implements Service {
154160
return await (await this.client.get(this.url + '/comuni/' + postalCode)).data.data;
155161
}
156162

157-
// Raccomandate
163+
/**
164+
* Raccomandate
165+
*/
166+
158167
async listRaccomandate(): Promise<SigleRaccomandata[]> {
159-
return await (await this.client.get(this.url + '/raccomandate')).data.data;
168+
return await (await this.client.get(this.url + '/raccomandate/')).data.data;
160169
}
161170

162171
async getRaccomandata(id: string) {
@@ -172,9 +181,11 @@ export class UfficioPostale implements Service {
172181
return await (await this.client.patch(this.url + '/raccomandate/' + id, JSON.stringify({ confirmed: true }))).data.data;
173182
}
174183

175-
// Telegrammi
184+
/**
185+
* Telegrammi
186+
*/
176187
async listTelegrammi(): Promise<SingleTelegramma[]> {
177-
return await (await this.client.get(this.url + '/telegrammi')).data.data;
188+
return await (await this.client.get(this.url + '/telegrammi/')).data.data;
178189
}
179190

180191
async getTelegramma(id: string) {
@@ -190,6 +201,47 @@ export class UfficioPostale implements Service {
190201
return await (await this.client.patch(this.url + '/telegrammi/' + id, JSON.stringify({ confirmed: true }))).data.data;
191202
}
192203

204+
/**
205+
* Posta ordinaria
206+
*/
207+
async listOrdinarie() {
208+
return await (await this.client.get(this.url + '/ordinarie/')).data.data;
209+
}
210+
211+
async getOrdinaria(id: string) {
212+
return await (await this.client.get(this.url + '/ordinarie/' + id)).data.data;
213+
}
214+
215+
async createOrdinaria(mittente: Mittente, destinatari: Destinatario[], documento: string, autoconfirm = true, options: OpzioniLOL = {}): Promise<any[]> {
216+
if (!Array.isArray(destinatari)) destinatari = [destinatari];
217+
return await (await this.client.post(this.url + '/ordinarie/', JSON.stringify({ mittente, destinatari, documento, opzioni: { autoconfirm, ...options } }))).data.data;
218+
}
219+
220+
async confirmOrdinaria(id: string) {
221+
return await (await this.client.patch(this.url + '/ordinarie/' + id, JSON.stringify({ confirmed: true }))).data.data;
222+
}
223+
224+
/**
225+
* Posta prioritaria
226+
*/
227+
228+
async listPrioritarie() {
229+
return await (await this.client.get(this.url + '/prioritarie/')).data.data;
230+
}
231+
232+
async getPrioritaria(id: string) {
233+
return await (await this.client.get(this.url + '/prioritarie/' + id)).data.data;
234+
}
235+
236+
async createPrioritaria(mittente: Mittente, destinatari: Destinatario[], documento: string, autoconfirm = true, options: OpzioniLOL = {}): Promise<any[]> {
237+
if (!Array.isArray(destinatari)) destinatari = [destinatari];
238+
return await (await this.client.post(this.url + '/prioritarie/', JSON.stringify({ mittente, destinatari, documento, opzioni: { autoconfirm, ...options } }))).data.data;
239+
}
240+
241+
async confirmPrioritaria(id: string) {
242+
return await (await this.client.patch(this.url + '/prioritarie/' + id, JSON.stringify({ confirmed: true }))).data.data;
243+
}
244+
193245
get url() {
194246
return getBaseUrl(this.environment, this.baseUrl)
195247
}

0 commit comments

Comments
 (0)