From 68e2f0725350d1fc2f63fcdc29d72b461f0209f0 Mon Sep 17 00:00:00 2001 From: MatijaPrsaMinus5 Date: Thu, 30 Mar 2023 10:46:09 +0200 Subject: [PATCH 1/2] add message listici version 2 --- pkg/msgs/listici.go | 30 ++++++++++++++++++++++++++++++ pkg/msgs/main.go | 1 + 2 files changed, 31 insertions(+) diff --git a/pkg/msgs/listici.go b/pkg/msgs/listici.go index 0b5dce0..362ec35 100644 --- a/pkg/msgs/listici.go +++ b/pkg/msgs/listici.go @@ -20,6 +20,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 +50,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" From 936cca8f425c9d82a74719a4700d61adf51b4e9e Mon Sep 17 00:00:00 2001 From: MatijaPrsaMinus5 Date: Tue, 4 Apr 2023 11:07:06 +0200 Subject: [PATCH 2/2] renaming listici message --- pkg/msgs/listici.go | 6 +++--- pkg/msgs/main.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/msgs/listici.go b/pkg/msgs/listici.go index 362ec35..8ba87c3 100644 --- a/pkg/msgs/listici.go +++ b/pkg/msgs/listici.go @@ -20,7 +20,7 @@ type Listici struct { Tip string `json:"tip"` } -type ListiciV2 struct { +type ListiciSeek struct { VrstaUplate string `json:"vrsta_uplate"` Tip string `json:"tip"` Status int64 `json:"status"` @@ -51,8 +51,8 @@ func ParseListici(body string, isTestIgrac bool) (*Listici, error) { return l, nil } -func ParseListiciV2(body string, isTestIgrac bool) (*ListiciV2, error) { - l := &ListiciV2{} +func ParseListiciSeek(body string, isTestIgrac bool) (*ListiciSeek, error) { + l := &ListiciSeek{} if err := json.Unmarshal([]byte(body), l); err != nil { log.Printf("[ERROR] %s while parsing %s", err, body) return nil, err diff --git a/pkg/msgs/main.go b/pkg/msgs/main.go index bedf8fb..97ad3e2 100644 --- a/pkg/msgs/main.go +++ b/pkg/msgs/main.go @@ -5,7 +5,7 @@ const ( TypeAppVersion = "app_version" TypeMojiListici = "moji_listici" TypeMojiListiciTip = "moji_listici_tip" - TypeMojiListici2 = "moji_listici2" + TypeMojiListiciSeek = "moji_listici_seek" TypeSync = "sync" TypeListic = "listic" TypeDodajListic = "dodaj_listic"