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.

60 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"
)
const (
ApiEndpoint = "https://hodlhodl.com/api/v1"
TestApiEndpoint = "https://hhtestnet.com/api/v1"
ApiKey = "***REMOVED***"
)
4 years ago
type Notification struct {
Id int `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
Link string `json:"link"`
}
4 years ago
type response struct {
Status string `json:"status"`
ExchangeRateProviders []struct {
Name string `json:"name"`
CurrencyCodes []string `json:"currency_codes"`
} `json:"exchange_rate_providers"`
}
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)
}
fmt.Println(string(body))
4 years ago
defer resp.Body.Close()
4 years ago
}