Spaces:
Paused
Paused
use apps script webhook for sheets
Browse files- internal/handler/sheets.go +4 -12
internal/handler/sheets.go
CHANGED
|
@@ -3,22 +3,14 @@ package handler
|
|
| 3 |
import (
|
| 4 |
"bytes"
|
| 5 |
"encoding/json"
|
| 6 |
-
"fmt"
|
| 7 |
"net/http"
|
| 8 |
"os"
|
| 9 |
-
"time"
|
| 10 |
)
|
| 11 |
|
| 12 |
-
var
|
| 13 |
-
var sheetKey = os.Getenv("GOOGLE_API_KEY")
|
| 14 |
|
| 15 |
func BackupKeyToSheet(name, key string) {
|
| 16 |
-
if
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
sheetID, sheetKey)
|
| 20 |
-
body, _ := json.Marshal(map[string]interface{}{
|
| 21 |
-
"values": [][]interface{}{{name, key, time.Now().Format("2006-01-02")}},
|
| 22 |
-
})
|
| 23 |
-
http.Post(url, "application/json", bytes.NewReader(body))
|
| 24 |
}
|
|
|
|
| 3 |
import (
|
| 4 |
"bytes"
|
| 5 |
"encoding/json"
|
|
|
|
| 6 |
"net/http"
|
| 7 |
"os"
|
|
|
|
| 8 |
)
|
| 9 |
|
| 10 |
+
var sheetsWebhook = os.Getenv("SHEETS_WEBHOOK")
|
|
|
|
| 11 |
|
| 12 |
func BackupKeyToSheet(name, key string) {
|
| 13 |
+
if sheetsWebhook == "" { return }
|
| 14 |
+
body, _ := json.Marshal(map[string]string{"name": name, "key": key})
|
| 15 |
+
http.Post(sheetsWebhook, "application/json", bytes.NewReader(body))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|