package heliumapi import ( "encoding/json" "fmt" "time" ) // query https://docs.helium.com/api/blockchain/hotspots#hotspots-activity-counts func GetHotspotActivityCounts(hotspot string) (*ActivityCounts, error) { path := "/v1/hotspots/" + hotspot + "/activity/count" // query the api respBody, err := getHeliumApi(path, nil) if err != nil { return nil, err } // unmarshal the response respobject := ActivityCountsResp{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } return &respobject.Data, nil } // query https://docs.helium.com/api/blockchain/hotspots#reward-total-for-a-hotspot func GetRewardsTotalForHotspot(hotspot string, minTime *time.Time, maxTime *time.Time) (*RewardTotal, error) { path := "/v1/hotspots/" + hotspot + "/rewards/sum" params := map[string]string{} if minTime != nil { params["min_time"] = minTime.UTC().Format(time.RFC3339) } if maxTime != nil { params["max_time"] = maxTime.UTC().Format(time.RFC3339) } // query the api respBody, err := getHeliumApi(path, ¶ms) if err != nil { return nil, err } // unmarshal the response respobject := RewardTotalResp{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } return &respobject.Data, nil } // query https://docs.helium.com/api/blockchain/hotspots#witnesses-for-a-hotspot func GetWitnessesForHotspot(hotspot string) ([]Hotspot, error) { path := "/v1/hotspots/" + hotspot + "/witnesses" // query the api respBody, err := getHeliumApi(path, nil) if err != nil { return nil, err } // unmarshal the response respobject := WitnessesResp{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } return respobject.Data, nil } // query https://docs.helium.com/api/blockchain/hotspots#witnessed-for-a-hotspot func GetWitnessedForHotspot(hotspot string) ([]Hotspot, error) { path := "/v1/hotspots/" + hotspot + "/witnessed" // query the api respBody, err := getHeliumApi(path, nil) if err != nil { return nil, err } // unmarshal the response respobject := WitnessedResp{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } return respobject.Data, nil }