35 lines
670 B
Go
35 lines
670 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"io/ioutil"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
// CheckStatusCoinGecko needs a comment
|
||
|
func CheckStatusCoinGecko() bool {
|
||
|
// needed answer for Coingecko API
|
||
|
type statusResponse struct {
|
||
|
GeckoSays string `json:"gecko_says"`
|
||
|
}
|
||
|
|
||
|
// see if API is available
|
||
|
url := "https://api.coingecko.com/api/v3/ping"
|
||
|
response, err := http.Get(url)
|
||
|
if err == nil {
|
||
|
// API is available, let's read the response
|
||
|
data, _ := ioutil.ReadAll(response.Body)
|
||
|
var status statusResponse
|
||
|
json.Unmarshal(data, &status)
|
||
|
if status.GeckoSays == "(V3) To the Moon!" {
|
||
|
// API is working as expected
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func GetCoinInfo() {
|
||
|
|
||
|
}
|