forked from padmoney/enotas-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enotas.go
52 lines (42 loc) · 1.2 KB
/
enotas.go
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
package enotas
import (
"github.com/padmoney/enotas-go/config"
"github.com/padmoney/enotas-go/empresa"
"github.com/padmoney/enotas-go/entity"
"github.com/padmoney/enotas-go/internal/rest"
"github.com/padmoney/enotas-go/nfse"
"github.com/padmoney/enotas-go/servico"
)
type ENotas struct {
credentials config.Credentials
}
func Configure(apiKey string) config.Credentials {
return config.Configure(apiKey)
}
func NewENotas(c config.Credentials) ENotas {
return ENotas{
credentials: c,
}
}
func (e ENotas) Cidades(pageNumber, pageSize int) ([]entity.Cidade, error) {
c := e.getClient()
return servico.NewCidadeServico(c).Consulta(pageNumber, pageSize)
}
func (e ENotas) Credentials() config.Credentials {
return e.credentials
}
func (e ENotas) Empresa() empresa.Empresa {
c := e.getClient()
return empresa.NewEmpresa(c)
}
func (e ENotas) NFSe() nfse.NFSe {
c := e.getClient()
return nfse.NewNFSe(c)
}
func (e ENotas) ServicosMunicipais(uf, city string, pageNumber, pageSize int) ([]entity.ServicoMunicipio, error) {
c := e.getClient()
return servico.NewServicoMunicipio(c).Consulta(uf, city, pageNumber, pageSize)
}
func (e ENotas) getClient() rest.Client {
return rest.NewClient(e.credentials)
}