Skip to content

Commit 098def3

Browse files
committed
Per new api
Signed-off-by: Vishal Rana <[email protected]>
1 parent 10d2bbf commit 098def3

File tree

8 files changed

+120
-411
lines changed

8 files changed

+120
-411
lines changed

Gopkg.lock

Lines changed: 24 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323

2424
[[constraint]]
25-
name = "github.com/dghubble/sling"
26-
version = "1.1.0"
25+
name = "github.com/labstack/gommon"
26+
version = "0.2.3"
2727

2828
[[constraint]]
29-
name = "github.com/stretchr/testify"
30-
version = "1.1.4"
29+
name = "github.com/go-resty/resty"
30+
version = "1.0.0"

client.go

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
package labstack
22

33
import (
4-
"sync"
4+
"fmt"
55

6-
"github.com/dghubble/sling"
7-
glog "github.com/labstack/gommon/log"
6+
"github.com/go-resty/resty"
7+
"github.com/labstack/gommon/log"
88
)
99

1010
type (
1111
Client struct {
12-
accountID string
13-
apiKey string
14-
sling *sling.Sling
15-
logger *glog.Logger
12+
apiKey string
13+
resty *resty.Client
14+
logger *log.Logger
1615
}
1716

18-
Fields map[string]interface{}
19-
20-
SearchParameters struct {
21-
Query string `json:"query"`
22-
QueryString string `json:"query_string"`
23-
Since string `json:"since"`
24-
Sort []string `json:"sort"`
25-
Size int `json:"size"`
26-
From int `json:"from"`
17+
APIError struct {
18+
Code int `json:"code"`
19+
Message string `json:"message"`
2720
}
2821
)
2922

@@ -32,34 +25,25 @@ const (
3225
)
3326

3427
// NewClient creates a new client for the LabStack API.
35-
func NewClient(accountID, apiKey string) *Client {
28+
func NewClient(apiKey string) *Client {
3629
return &Client{
37-
accountID: accountID,
38-
apiKey: apiKey,
39-
sling: sling.New().Base(apiURL).Add("Authorization", "Bearer "+apiKey),
40-
logger: glog.New("labstack"),
30+
apiKey: apiKey,
31+
resty: resty.New().SetHostURL(apiURL).SetAuthToken(apiKey),
32+
logger: log.New("labstack"),
4133
}
4234
}
4335

44-
// Cube returns the cube service.
45-
func (c *Client) Cube() (cube *Cube) {
46-
cube = &Cube{
47-
sling: c.sling.Path("/cube"),
48-
mutex: new(sync.RWMutex),
49-
logger: c.logger,
50-
AccountID: c.accountID,
51-
APIKey: c.apiKey,
52-
BatchSize: 60,
53-
DispatchInterval: 60,
36+
func (c *Client) Download(id string, path string) (err *APIError) {
37+
err = new(APIError)
38+
_, e := c.resty.R().
39+
SetOutput(path).
40+
Get(fmt.Sprintf("%s/%s", apiURL, id))
41+
if e != nil {
42+
err.Message = e.Error()
5443
}
55-
cube.resetRequests()
5644
return
5745
}
5846

59-
// Jet returns the jet service.
60-
func (c *Client) Jet() *Jet {
61-
return &Jet{
62-
sling: c.sling.Path("/jet"),
63-
logger: c.logger,
64-
}
47+
func (e *APIError) Error() string {
48+
return e.Message
6549
}

cube.go

Lines changed: 0 additions & 199 deletions
This file was deleted.

0 commit comments

Comments
 (0)