|
|
|
// test account (avicious.406+test@gmail.com) API key
|
|
|
|
// eZbV6TDcl2qUmtEAMLllN8qOHeb1hQiS8sVEoG2OmfqLym4UqihiFL83xgM2SLGPtz8HS2DeX45sk89B
|
|
|
|
// test offer id: https://hhtestnet.com/offers/F8W2srPJK2JKwYdh
|
|
|
|
// TODO: unmarshal json (encoding/json)
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
// "strings"
|
|
|
|
"io/ioutil"
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// APIEndpoint = "https://hodlhodl.com/api/v1"
|
|
|
|
TestAPIEndpoint = "https://hhtestnet.com/api/v1"
|
|
|
|
APIKEY = "***REMOVED***"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Notification export
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
req.Header.Add("Authorization", "Bearer " + APIKEY)
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
|
|
|
defer resp.Body.Close()
|
|
|
|
}
|