mlblive/internal/statsapi/patch.go

35 lines
535 B
Go
Raw Normal View History

2024-07-02 04:16:44 +00:00
package statsapi
import (
"errors"
)
type DiffPatchParams struct {
GamePk string
StartTimecode string
PushUpdateId string
}
type DiffPatchResponse []Patch
type Patch struct {
Diff []instruction
}
type instruction struct {
Op string
Path string
Value any
From string
}
func (p *Patch) Timestamp() (string, error) {
for _, d := range p.Diff {
if d.Op == "replace" && d.Path == "/metaData/timeStamp" {
return d.Value.(string), nil
}
}
return "", errors.New("could not find replacement timestamp")
}