1
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
helium-blockchain-exporter/heliumapi/activity/activities.go

44 lines
915 B
Go
Raw Normal View History

2021-09-25 01:30:22 +00:00
package activity
import (
"encoding/json"
"fmt"
)
type ActivityResp struct {
Data []json.RawMessage `json:"data"`
}
type Activities struct{}
func NewActivities(resp ActivityResp) (*Activities, error) {
type ActivityType struct {
Type string `json:"type"`
}
activityType := ActivityType{}
activities := Activities{}
for _, activityRaw := range resp.Data {
if err := json.Unmarshal(activityRaw, &activityType); err != nil {
return nil, fmt.Errorf("failed to unmarshal activity: %v", err)
}
fmt.Println(activityType.Type)
switch activityType.Type {
case "add_gateway_v1":
case "assert_location_v1":
case "assert_location_v2":
case "payment_v1":
case "payment_v2":
case "rewards_v1":
case "stake_validator_v1":
case "token_burn_v1":
case "unstake_validator_v1":
default:
fmt.Printf("unimplemented activy type: %v", activityType.Type)
}
}
return &activities, nil
}