Skip to content

Commit 950f77d

Browse files
committed
[ADD] module, structure, files
1 parent 3cc4719 commit 950f77d

File tree

22 files changed

+73
-0
lines changed

22 files changed

+73
-0
lines changed

api/article.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/article_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/article_status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/authenticate.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package api
2+
3+
import (
4+
"bytes"
5+
"encoding/json"
6+
"io/ioutil"
7+
"net/http"
8+
)
9+
10+
const (
11+
URL = "https://api.booklooker.de/2.0/authenticate"
12+
)
13+
14+
type response struct {
15+
Status string `json:"status"`
16+
Message string `json:"message,omitempty"`
17+
}
18+
19+
func authenticate(apiKey string) (response, error) {
20+
var res response
21+
22+
jsonData, err := json.Marshal(map[string]string{"apiKey": apiKey})
23+
if err != nil {
24+
return res, err
25+
}
26+
27+
req, err := http.NewRequest(http.MethodPost, URL, bytes.NewBuffer(jsonData))
28+
if err != nil {
29+
return res, err
30+
}
31+
32+
client := &http.Client{}
33+
resp, err := client.Do(req)
34+
if err != nil {
35+
return res, err
36+
}
37+
defer resp.Body.Close()
38+
39+
body, err := ioutil.ReadAll(resp.Body)
40+
if err != nil {
41+
return res, err
42+
}
43+
44+
err = json.Unmarshal(body, &res)
45+
if err != nil {
46+
return res, err
47+
}
48+
49+
return res, nil
50+
}

api/file_import.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/file_status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/order.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/order_cancel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/order_item_cancel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

api/order_message.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package api

0 commit comments

Comments
 (0)