You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4 KiB
Go

4 years ago
// test account (avicious.406+test@gmail.com) API key
// eZbV6TDcl2qUmtEAMLllN8qOHeb1hQiS8sVEoG2OmfqLym4UqihiFL83xgM2SLGPtz8HS2DeX45sk89B
// test offer id: https://hhtestnet.com/offers/F8W2srPJK2JKwYdh
// TODO: unmarshal json (encoding/json)
4 years ago
package main
import (
"fmt"
"net/http"
// "strings"
"io/ioutil"
"encoding/json"
4 years ago
)
const (
// APIEndpoint = "https://hodlhodl.com/api/v1"
TestAPIEndpoint = "https://hhtestnet.com/api/v1"
APIKEY = "***REMOVED***"
4 years ago
)
// Notification export
4 years ago
type Notification struct {
Status string `json:"status"`
Notifications []struct {
ID string `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
Link string `json:"link"`
} `json:"notifications"`
4 years ago
}
func main() {
//body:= strings.NewReader(' -X POST -H "Authorization: Bearer ***REMOVED***" -H "Content-Type: application/json"`)
req, err := http.NewRequest("POST", TestAPIEndpoint + "/notifications/read", nil)
4 years ago
if err != nil {
fmt.Println(err)
}
req.Header.Add("Authorization", "Bearer " + APIKEY)
4 years ago
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err!= nil {
fmt.Println(err)
}
fmt.Println(resp.Status)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
} else {
res:= Notification{}
json.Unmarshal([]byte(body), &res)
fmt.Println("RESULT", res)
fmt.Println("RESULTAT", string(body))
4 years ago
}
4 years ago
defer resp.Body.Close()
4 years ago
}