44 lines
915 B
Go
44 lines
915 B
Go
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
|
|
}
|