added dataapi

nats
Paulo Simão 2021-11-05 10:13:48 -03:00
parent 56927666ef
commit 9fcc1cccd7
2 changed files with 7 additions and 11 deletions

View File

@ -37,8 +37,9 @@ func (c *Cli) Do(request *DataAPIRequest) (response *DataAPIResponse, err error)
return
}
func NewCli() *Cli {
func NewCli(apikey string) *Cli {
ret := &Cli{Httpcli: httpcli.NewCli()}
ret.Httpcli.AddHeader("X-API-KEY", apikey)
ret.Httpcli.SetBasePath("https://dataapi.digitalcircle.com.br")
return ret
}

View File

@ -7,8 +7,7 @@ import (
)
func TestAPIRetrieve(t *testing.T) {
c := dataapi.NewCli()
c.Httpcli.AddHeader("X-API-KEY", "RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.RETRIEVE,
@ -21,8 +20,7 @@ func TestAPIRetrieve(t *testing.T) {
}
func TestAPIRetrieveWQuery(t *testing.T) {
c := dataapi.NewCli()
c.Httpcli.AddHeader("X-API-KEY", "RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.RETRIEVE,
@ -36,8 +34,7 @@ func TestAPIRetrieveWQuery(t *testing.T) {
}
func TestAPIUpdate(t *testing.T) {
c := dataapi.NewCli()
c.Httpcli.AddHeader("X-API-KEY", "RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.UPDATE,
@ -54,8 +51,7 @@ func TestAPIUpdate(t *testing.T) {
}
func TestAPIDelete(t *testing.T) {
c := dataapi.NewCli()
c.Httpcli.AddHeader("X-API-KEY", "RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.DELETE,
@ -69,8 +65,7 @@ func TestAPIDelete(t *testing.T) {
}
func TestAPICreate(t *testing.T) {
c := dataapi.NewCli()
c.Httpcli.AddHeader("X-API-KEY", "RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",