26 lines
498 B
Go
26 lines
498 B
Go
|
package heliumapi
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func GetCurrentOraclePrice() (*CurrentOraclePrice, error) {
|
||
|
const path = "/v1/oracle/prices/current"
|
||
|
|
||
|
// query the api
|
||
|
respBody, err := getHeliumApi(path, nil)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
// unmarshal the response
|
||
|
respobject := CurrentOraclePrice{}
|
||
|
err = json.Unmarshal(respBody, &respobject)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("failed to unmarshal response from path %v: %v", path, err)
|
||
|
}
|
||
|
|
||
|
return &respobject, nil
|
||
|
}
|