|
1 | 1 | // import OpenApi from '../dist/index'; |
| 2 | +const fs = require('fs'); |
2 | 3 | let OpenApi = require('../dist/index').default; |
3 | 4 |
|
4 | 5 | const scopes = [ |
@@ -129,18 +130,35 @@ const scopes = [ |
129 | 130 | // const piva = await client.pa.findPa('00559720982') |
130 | 131 | // expect(piva).toBeDefined(); |
131 | 132 | // }) |
132 | | -// test('testFD', async function() { |
133 | | -// let client = await OpenApi.init('test', process.env.OPENAPI_USERNAME, process.env.API_KEY, process.env.TOKEN); |
134 | | -// const prodotti = await client.firmaDigitale.getProducts(); |
135 | | -// expect(prodotti).toBeDefined(); |
136 | 133 |
|
137 | | -// const richiesta = await client.firmaDigitale.requestProduct('RINFIR', {}) |
138 | | -// expect(richiesta.id).toBeDefined() |
| 134 | +test('testFD', async function() { |
| 135 | + let client = await OpenApi.init('test', process.env.OPENAPI_USERNAME, process.env.API_KEY, process.env.TOKEN); |
| 136 | + // const prodotti = await client.firmaDigitale.getProducts(); |
| 137 | + // expect(prodotti).toBeDefined(); |
139 | 138 |
|
140 | | -// const infoRichiesta = await client.firmaDigitale.getRequest(richiesta.id) |
141 | | -// expect(infoRichiesta).toBeDefined() |
142 | | -// console.log(infoRichiesta); |
143 | | -// }) |
| 139 | + // const richiesta = await client.firmaDigitale.requestProduct('RINFIR', {}) |
| 140 | + // expect(richiesta.id).toBeDefined() |
| 141 | + |
| 142 | + // const infoRichiesta = await client.firmaDigitale.getRequest(richiesta.id) |
| 143 | + // expect(infoRichiesta).toBeDefined() |
| 144 | + // console.log(infoRichiesta); |
| 145 | + |
| 146 | + const listaFirmaElettroniche = await client.firmaDigitale.listFirmaElettronica(); |
| 147 | + expect(listaFirmaElettroniche).toBeDefined(); |
| 148 | + console.log(listaFirmaElettroniche); |
| 149 | + |
| 150 | + const pdf = await fs.promises.readFile(__dirname + '/resources/testosemplice.pdf') |
| 151 | + const newFirmaElettronica = await client.firmaDigitale.createFirmaElettronica('test.pdf', pdf.toString('base64'), [ |
| 152 | + { |
| 153 | + 'firstname': 'test', |
| 154 | + 'lastname': 'test', |
| 155 | + 'email': 'test@altravia.com', |
| 156 | + 'phone': '+39321321321', |
| 157 | + } |
| 158 | + ]).catch(e => console.log(e)) |
| 159 | + |
| 160 | + expect(newFirmaElettronica).toBeDefined(); |
| 161 | +}) |
144 | 162 |
|
145 | 163 | // test('testMT', async function() { |
146 | 164 | // let client = await OpenApi.init('test', process.env.OPENAPI_USERNAME, process.env.API_KEY, process.env.TOKEN); |
@@ -189,58 +207,58 @@ const scopes = [ |
189 | 207 | // console.log(JSON.stringify(sms, null, 2)); |
190 | 208 | // }) |
191 | 209 |
|
192 | | -test('testUP', async function() { |
193 | | - let client = await OpenApi.init('test', process.env.OPENAPI_USERNAME, process.env.API_KEY, process.env.TOKEN); |
194 | | - // const list = await client.ufficioPostale.listRaccomandate('NEW') |
195 | | - // expect(list).toBeDefined() |
196 | | - const mitt = { |
197 | | - "titolo": "mr", |
198 | | - "nome": "Simone", |
199 | | - "dug": "SST", |
200 | | - "indirizzo": "Valnerina", |
201 | | - "civico": "1", |
202 | | - "comune": "montefranco", |
203 | | - "cap": "05030", |
204 | | - "provincia": "tr", |
205 | | - "nazione": "Italia", |
206 | | - "email": "s.desantis@altravia.com", |
207 | | - "ragione_sociale": "privato", |
208 | | - "cognome": "xxx" |
209 | | - } |
210 | | - |
211 | | - const dest = { |
212 | | - "nome": "Simone", |
213 | | - "cognome": "Desantis", |
214 | | - "co": "Altravia Servizi SRL", |
215 | | - "dug": "piazza", |
216 | | - "indirizzo": "San Giovanni Decollato", |
217 | | - "civico": "6", |
218 | | - "comune": "Terni", |
219 | | - "cap": "05100", |
220 | | - "provincia": "TR", |
221 | | - "nazione": "Italia" |
222 | | - } |
223 | | - |
224 | | - // const comuni = await client.ufficioPostale.comuni('00143') |
225 | | - // expect(comuni).toBeDefined() |
226 | | - // console.log(comuni); |
227 | | - |
228 | | - // const r = await client.ufficioPostale.createRaccomandata(mitt, [dest], ['Test'], false).catch(e => console.log(e)) |
229 | | - // const result = await client.ufficioPostale.confirmRaccomandata(r[0].id).catch(e => console.log(e)) |
230 | | - // expect(result).toBeDefined() |
231 | | - // console.log(result); |
232 | | - |
233 | | - // const t = await client.ufficioPostale.createTelegramma(mitt, [dest], 'Test', false) |
234 | | - // const resultTelegramma = await client.ufficioPostale.confirmTelegramma(t[0].id).catch(e => console.log(e)) |
235 | | - // expect(resultTelegramma).toBeDefined() |
236 | | - // console.log(resultTelegramma); |
237 | | - |
238 | | - // const pricing = await client.ufficioPostale.pricing().catch(e => console.log(e)) |
239 | | - // expect(pricing).toBeDefined() |
240 | | - // console.log(pricing); |
241 | | - |
242 | | - // const dugs = await client.ufficioPostale.listDug().catch(e => console.log(e)) |
243 | | - // expect(dugs).toBeDefined() |
244 | | - // console.log(dugs) |
245 | | -}) |
| 210 | +// test('testUP', async function() { |
| 211 | +// let client = await OpenApi.init('test', process.env.OPENAPI_USERNAME, process.env.API_KEY, process.env.TOKEN); |
| 212 | +// // const list = await client.ufficioPostale.listRaccomandate('NEW') |
| 213 | +// // expect(list).toBeDefined() |
| 214 | +// const mitt = { |
| 215 | +// "titolo": "mr", |
| 216 | +// "nome": "Simone", |
| 217 | +// "dug": "SST", |
| 218 | +// "indirizzo": "Valnerina", |
| 219 | +// "civico": "1", |
| 220 | +// "comune": "montefranco", |
| 221 | +// "cap": "05030", |
| 222 | +// "provincia": "tr", |
| 223 | +// "nazione": "Italia", |
| 224 | +// "email": "s.desantis@altravia.com", |
| 225 | +// "ragione_sociale": "privato", |
| 226 | +// "cognome": "xxx" |
| 227 | +// } |
| 228 | + |
| 229 | +// const dest = { |
| 230 | +// "nome": "Simone", |
| 231 | +// "cognome": "Desantis", |
| 232 | +// "co": "Altravia Servizi SRL", |
| 233 | +// "dug": "piazza", |
| 234 | +// "indirizzo": "San Giovanni Decollato", |
| 235 | +// "civico": "6", |
| 236 | +// "comune": "Terni", |
| 237 | +// "cap": "05100", |
| 238 | +// "provincia": "TR", |
| 239 | +// "nazione": "Italia" |
| 240 | +// } |
| 241 | + |
| 242 | +// // const comuni = await client.ufficioPostale.comuni('00143') |
| 243 | +// // expect(comuni).toBeDefined() |
| 244 | +// // console.log(comuni); |
| 245 | + |
| 246 | +// // const r = await client.ufficioPostale.createRaccomandata(mitt, [dest], ['Test'], false).catch(e => console.log(e)) |
| 247 | +// // const result = await client.ufficioPostale.confirmRaccomandata(r[0].id).catch(e => console.log(e)) |
| 248 | +// // expect(result).toBeDefined() |
| 249 | +// // console.log(result); |
| 250 | + |
| 251 | +// // const t = await client.ufficioPostale.createTelegramma(mitt, [dest], 'Test', false) |
| 252 | +// // const resultTelegramma = await client.ufficioPostale.confirmTelegramma(t[0].id).catch(e => console.log(e)) |
| 253 | +// // expect(resultTelegramma).toBeDefined() |
| 254 | +// // console.log(resultTelegramma); |
| 255 | + |
| 256 | +// // const pricing = await client.ufficioPostale.pricing().catch(e => console.log(e)) |
| 257 | +// // expect(pricing).toBeDefined() |
| 258 | +// // console.log(pricing); |
| 259 | + |
| 260 | +// // const dugs = await client.ufficioPostale.listDug().catch(e => console.log(e)) |
| 261 | +// // expect(dugs).toBeDefined() |
| 262 | +// // console.log(dugs) |
| 263 | +// }) |
246 | 264 |
|
0 commit comments