Skip to content

Commit b0be334

Browse files
aggiunti endpoints raccomandata e telegramma
1 parent fd60e48 commit b0be334

2 files changed

Lines changed: 38 additions & 10 deletions

File tree

src/Services/UfficioPostale.ts

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,30 @@ interface Mittente {
3131
nome: string;
3232
cognome: string;
3333
email?: string;
34+
dug: string;
35+
indirizzo?: string;
36+
civico?: string;
37+
comune?: string;
38+
cap?: string;
39+
provincia?: string;
40+
nazione?: string;
41+
}
42+
43+
interface OpzioniRaccomandata {
44+
fronteretro?: boolean;
45+
colori?: boolean;
46+
autoconfirm?: boolean;
47+
ar?: boolean;
3448
}
3549

36-
interface Opzioni {
50+
interface OpzioniTelegramma {
3751
fronteretro?: boolean;
3852
colori?: boolean;
3953
autoconfirm?: boolean;
4054
ar?: boolean;
41-
timestamp_invio?: any;
42-
callback_url?: any;
43-
callback_field?: any;
44-
custom?: any;
4555
}
4656

47-
interface Destinatari {
57+
interface Destinatario {
4858
nome?: string;
4959
cognome?: string;
5060
comune?: string;
@@ -63,7 +73,7 @@ interface Destinatari {
6373

6474
interface RaccomandataResponse {
6575
mittente?: Mittente;
66-
destinatari?: Destinatari[];
76+
destinatari?: Destinatario[];
6777
documento?: string[];
6878
opzioni?: Opzioni;
6979
prodotto?: string;
@@ -144,7 +154,7 @@ export class UfficioPostale implements Service {
144154
return await (await this.client.get(this.url + '/comuni/' + postalCode)).data.data;
145155
}
146156

147-
// @todo Raccomandate
157+
// Raccomandate
148158
async listRaccomandate(): Promise<SigleRaccomandata[]> {
149159
return await (await this.client.get(this.url + '/raccomandate')).data.data;
150160
}
@@ -153,7 +163,15 @@ export class UfficioPostale implements Service {
153163
return await (await this.client.get(this.url + '/raccomandate/' + id)).data.data;
154164
}
155165

156-
// @todo Telegrammi
166+
async createRaccomandata(mittente: Mittente, destinatari: Destinatario[], documento: string[], autoconfirm = true, options: OpzioniRaccomandata = {}) {
167+
return await (await this.client.post(this.url + '/raccomandate/', JSON.stringify({ mittente, destinatari, documento, options: { autoconfirm, ...options } }))).data.data;
168+
}
169+
170+
async confirmRaccomandata(id: string) {
171+
return await (await this.client.patch(this.url + '/raccomandate/' + id, JSON.stringify({ confirmed: true }))).data.data;
172+
}
173+
174+
// Telegrammi
157175
async listTelegrammi(): Promise<SingleTelegramma[]> {
158176
return await (await this.client.get(this.url + '/telegrammi')).data.data;
159177
}
@@ -162,6 +180,14 @@ export class UfficioPostale implements Service {
162180
return await (await this.client.get(this.url + '/telegrammi/' + id)).data.data;
163181
}
164182

183+
async createTelegramma(mittente: Mittente, destinatari: Destinatario[], documento: string, autoconfirm = true, options: OpzioniTelegramma = {}) {
184+
return await (await this.client.post(this.url + '/telegrammi/', JSON.stringify({ mittente, destinatari, documento, options: { autoconfirm, ...options } }))).data.data;
185+
}
186+
187+
async confirmTelegramma(id: string) {
188+
return await (await this.client.patch(this.url + '/telegrammi/' + id, JSON.stringify({ confirmed: true }))).data.data;
189+
}
190+
165191
get url() {
166192
return getBaseUrl(this.environment, this.baseUrl)
167193
}

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ export interface Callback {
55
method?: 'JSON' | 'POST';
66
field?: string;
77
data?: any
8-
}
8+
}
9+
10+
export type Transaction = 'open' | 'close';

0 commit comments

Comments
 (0)