improvements

master
Paulo Simão 2021-11-25 16:49:24 -03:00
parent ccae321dc9
commit aee712a88a
5 changed files with 28 additions and 4 deletions

View File

@ -0,0 +1,22 @@
package apiproxy
import (
"log"
"os"
"testing"
)
func TestCli_Do(t *testing.T) {
os.Setenv("REPLAY_APIKEY", "DONTBOTHER")
os.Setenv("REPLAY_ADDR", "https://localhost:8443")
c := NewCli()
res, err := c.Do(&APIProxyRequest{
Method: "GET",
Url: "https://www.slashdot.org",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}

View File

@ -41,14 +41,12 @@ func (c *Cli) Eval(id string, s string) (map[string]interface{}, error) {
json.Unmarshal(bs, &ret) json.Unmarshal(bs, &ret)
return ret, err return ret, err
} }
func (c *Cli) Wait(id string, s string, to int) (string, error) { func (c *Cli) Wait(id string, s string, to int) (string, error) {
ret := "" ret := ""
bs, err := c.HttpCli().RawPost(fmt.Sprintf("/ipc/chrome/wait/%s?to=%d", id, to), []byte(s)) bs, err := c.HttpCli().RawPost(fmt.Sprintf("/ipc/chrome/wait/%s?to=%d", id, to), []byte(s))
json.Unmarshal(bs, &ret) json.Unmarshal(bs, &ret)
return ret, err return ret, err
} }
func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, error) { func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, error) {
ret := "" ret := ""
in := map[string]interface{}{ in := map[string]interface{}{

View File

@ -1,6 +1,7 @@
package dataapi package dataapi
import ( import (
"go.digitalcircle.com.br/open/replaycli-go/api/replay"
"strconv" "strconv"
"time" "time"
@ -63,6 +64,8 @@ func LCR_Create() {
} }
func RegistrarExec(table string, check bool) { func RegistrarExec(table string, check bool) {
rp := replay.NewCli()
rp.ConfigGet("API_KEY")
//Para robôs, age como contador e registra cada repetição no mês //Para robôs, age como contador e registra cada repetição no mês
c := NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") c := NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
var registros int var registros int

View File

@ -2,6 +2,7 @@ package dataapi_test
import ( import (
"log" "log"
"os"
"strconv" "strconv"
"testing" "testing"
"time" "time"
@ -10,7 +11,8 @@ import (
) )
func TestAPIRetrieve(t *testing.T) { func TestAPIRetrieve(t *testing.T) {
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") apikey := os.Getenv("DATAAPI_APIKEY")
c := dataapi.NewCli(apikey)
res, err := c.Do(&dataapi.DataAPIRequest{ res, err := c.Do(&dataapi.DataAPIRequest{
Col: "teste3", Col: "teste3",
Op: dataapi.RETRIEVE, Op: dataapi.RETRIEVE,

View File

@ -43,7 +43,6 @@ func (c *Cli) Write(fname string, sheet string, cell string, val string, celtype
err := c.HttpCli().JsonPost("/ipc/excel/write", req, &res) err := c.HttpCli().JsonPost("/ipc/excel/write", req, &res)
return err return err
} }
func (c *Cli) New(fname string, sheet string) (string, error) { func (c *Cli) New(fname string, sheet string) (string, error) {
req := &Req{ req := &Req{
File: fname, File: fname,