Skip to content

Commit

Permalink
add message listici version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
MatijaPrsaMinus5 committed Mar 30, 2023
1 parent 7582fdd commit a7138d2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
33 changes: 32 additions & 1 deletion pkg/msgs/listici.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package msgs

import (
"encoding/json"
"log"

"github.com/minus5/svckit/log"
)

//Vrste uplate
Expand All @@ -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{}
Expand All @@ -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
}
1 change: 1 addition & 0 deletions pkg/msgs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a7138d2

Please sign in to comment.