Skip to content

Commit 0dd5ebb

Browse files
committed
Bumped v0.10.0
Signed-off-by: Vishal Rana <[email protected]>
1 parent 098def3 commit 0dd5ebb

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ import (
2222
)
2323

2424
func main() {
25-
client := labstack.NewClient("<ACCOUNT_ID>", "<API_KEY>")
26-
store := client.Store()
27-
doc, err := store.Insert("users", labstack.Document{
28-
"name": "Jack",
29-
"location": "Disney",
25+
client := labstack.NewClient("<API_KEY>")
26+
res, err := client.BarcodeGenerate(&labstack.BarcodeGenerateRequest{
27+
Format: "qr_code",
28+
Content: "https://labstack.com",
3029
})
3130
if err != nil {
32-
panic(err)
31+
fmt.Println(err)
32+
} else {
33+
client.Download(res.ID, "/tmp/"+res.Name)
3334
}
34-
fmt.Printf("%+v", doc)
3535
}
3636
```
3737

@@ -41,4 +41,4 @@ From terminal run your app:
4141
go run app.go
4242
```
4343

44-
## [Documentation](https://labstack.com/docs) | [Forum](https://forum.labstack.com)
44+
## [API](https://labstack.com/api) | [Forum](https://forum.labstack.com)

barcode.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package labstack
2+
3+
type (
4+
BarcodeGenerateRequest struct {
5+
Format string `json:"format"`
6+
Content string `json:"content"`
7+
Size string `json:"size"`
8+
}
9+
10+
BarcodeGenerateResponse struct {
11+
*Download
12+
}
13+
14+
BarcodeScanRequest struct {
15+
File string
16+
}
17+
18+
BarcodeScanResponse struct {
19+
Format string `json:"format"`
20+
Content string `json:"content"`
21+
ContentType string `json:"content_type"`
22+
}
23+
)
24+
25+
func (c *Client) BarcodeGenerate(req *BarcodeGenerateRequest) (res *BarcodeGenerateResponse, err *APIError) {
26+
res = new(BarcodeGenerateResponse)
27+
_, e := c.resty.R().
28+
SetBody(req).
29+
SetResult(res).
30+
SetError(err).
31+
Post("/barcode/generate")
32+
if e != nil {
33+
err = new(APIError)
34+
err.Message = e.Error()
35+
}
36+
return
37+
}

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func NewClient(apiKey string) *Client {
3434
}
3535

3636
func (c *Client) Download(id string, path string) (err *APIError) {
37-
err = new(APIError)
3837
_, e := c.resty.R().
3938
SetOutput(path).
40-
Get(fmt.Sprintf("%s/%s", apiURL, id))
39+
Get(fmt.Sprintf("%s/download/%s", apiURL, id))
4140
if e != nil {
41+
err = new(APIError)
4242
err.Message = e.Error()
4343
}
4444
return

image.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,20 @@ type (
3232

3333
func (c *Client) ImageCompress(req *ImageCompressRequest) (res *ImageCompressResponse, err *APIError) {
3434
res = new(ImageCompressResponse)
35-
err = new(APIError)
36-
37-
// Request
3835
_, e := c.resty.R().
3936
SetFile("file", req.File).
4037
SetResult(res).
4138
SetError(err).
4239
Post("/image/compress")
4340
if e != nil {
41+
err = new(APIError)
4442
err.Message = e.Error()
4543
}
46-
4744
return
4845
}
4946

5047
func (c *Client) ImageResize(req *ImageResizeRequest) (res *ImageResizeResponse, err *APIError) {
5148
res = new(ImageResizeResponse)
52-
err = new(APIError)
53-
54-
// Request
5549
_, e := c.resty.R().
5650
SetFile("file", req.File).
5751
SetFormData(map[string]string{
@@ -63,8 +57,8 @@ func (c *Client) ImageResize(req *ImageResizeRequest) (res *ImageResizeResponse,
6357
SetError(err).
6458
Post("/image/resize")
6559
if e != nil {
60+
err = new(APIError)
6661
err.Message = e.Error()
6762
}
68-
6963
return
7064
}

0 commit comments

Comments
 (0)