-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
70 lines (58 loc) · 1.55 KB
/
example.js
File metadata and controls
70 lines (58 loc) · 1.55 KB
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
import fs from 'fs'
import open from 'open'
import Carteiro from './app.js'
const main = async () => {
try {
const store = {
logo: './logo.png',
contractId: '9992157880',
postCardId: '0067599079',
user: 'sigep',
password: 'n5f9t8',
cnpj: '34028316000103'
}
const service = '04669'
console.log('Store Config')
console.log(store)
const carteiro = await Carteiro(store, true)
const cep = '85.601-610'
const cepInfo = await carteiro.fetchCep(cep)
console.log(`Cep Info(${ cep }):`)
console.log(cepInfo)
const trackingCode = await carteiro.getTrackingCode(service)
const input = {
service,
orderCode: '123456',
weight: 500,
trackingCode,
value: 300,
recipient: {
name: 'Júlio Michél Guadagnim',
address: 'Rua Tenente Camargo',
complement: 'Sala 73',
cep: '85.601-610',
number: '1777',
city: 'Francisco Beltrão',
uf: 'PR',
phone: '046988058291'
},
sender: {
name: 'Selfless',
address: 'Rua Tenente Camargo',
complement: 'Sala 73',
cep: '85.601-610',
city: 'Francisco Beltrão',
uf: 'PR'
}
}
console.log('Service(PAC):', service)
console.log('Tag Input:')
console.log(input)
const tag = await carteiro.getTag(input)
fs.writeFileSync('example.pdf', tag)
await open('example.pdf')
} catch (err) {
console.log(err)
}
}
main()