diff --git a/pkg/msgs/listici.go b/pkg/msgs/listici.go index 0b5dce0..808a36b 100644 --- a/pkg/msgs/listici.go +++ b/pkg/msgs/listici.go @@ -2,7 +2,8 @@ package msgs import ( "encoding/json" - "log" + + "github.com/minus5/svckit/log" ) //Vrste uplate @@ -20,6 +21,15 @@ type Listici struct { Tip string `json:"tip"` } +type ListiciV2 struct { + VrstaUplate string `json:"vrsta_uplate"` + Tip string `json:"tip"` + Status int64 `json:"status"` + StatusUpdatedAt string `json:"status_updated_at"` + Time string `json:"time"` + Limit int64 `json:"limit"` +} + //ParseListici parsiraj json func ParseListici(body string, isTestIgrac bool) (*Listici, error) { l := &Listici{} @@ -41,3 +51,24 @@ func ParseListici(body string, isTestIgrac bool) (*Listici, error) { } return l, nil } + +func ParseListiciV2(body string, isTestIgrac bool) (*ListiciV2, error) { + l := &ListiciV2{} + if err := json.Unmarshal([]byte(body), l); err != nil { + log.Printf("[ERROR] %s while parsing %s", err, body) + return nil, err + } + if l.VrstaUplate == "" { + l.VrstaUplate = vrstaUplateInternet + } + if l.VrstaUplate == vrstaUplateInternet && isTestIgrac { + l.VrstaUplate = vrstaUplateTest + } + if l.Limit > 100 { + l.Limit = 100 + } + if l.Tip == "" { + l.Tip = tipSportski + } + return l, nil +} diff --git a/pkg/msgs/main.go b/pkg/msgs/main.go index 72cc7b7..bedf8fb 100644 --- a/pkg/msgs/main.go +++ b/pkg/msgs/main.go @@ -5,6 +5,7 @@ const ( TypeAppVersion = "app_version" TypeMojiListici = "moji_listici" TypeMojiListiciTip = "moji_listici_tip" + TypeMojiListici2 = "moji_listici2" TypeSync = "sync" TypeListic = "listic" TypeDodajListic = "dodaj_listic"