diff options
author | Andinus <andinus@nand.sh> | 2020-03-24 17:41:57 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-24 17:41:57 +0530 |
commit | 813b37d0cf7e6e371418feac56d40f48176105ba (patch) | |
tree | 2e4efd2224ff84700cbf354ea0ff75775d79a8a0 /pkg/bpod | |
parent | 532c060fd97c31c28f20f6f823472247edc0c30f (diff) | |
download | cetus-813b37d0cf7e6e371418feac56d40f48176105ba.tar.gz |
Reinitialize project and change module url
Diffstat (limited to 'pkg/bpod')
-rw-r--r-- | pkg/bpod/json.go | 55 | ||||
-rw-r--r-- | pkg/bpod/print.go | 14 |
2 files changed, 0 insertions, 69 deletions
diff --git a/pkg/bpod/json.go b/pkg/bpod/json.go deleted file mode 100644 index d895bcf..0000000 --- a/pkg/bpod/json.go +++ /dev/null @@ -1,55 +0,0 @@ -package bpod - -import ( - "encoding/json" - "fmt" - "math/rand" - - "framagit.org/andinus/cetus/pkg/request" -) - -type Res struct { - StartDate string `json:"startdate"` - FullStartDate string `json:"fullstartdate"` - EndDate string `json:"enddate"` - Url string `json:"url"` - UrlBase string `json:"urlbase"` - Copyright string `json:"copyright"` - CopyrightLink string `json:"copyrightlink"` - Title string `json:"title"` - Hsh string `json:"hsh"` -} - -type List struct { - Photos []Res `json:"images"` -} - -// UnmarshalJson will take body as input & unmarshal it to res -func UnmarshalJson(body string) (Res, error) { - list := List{} - res := Res{} - - err := json.Unmarshal([]byte(body), &list) - if err != nil { - return res, fmt.Errorf("UnmarshalJson failed\n%s", err.Error()) - } - - res = list.Photos[rand.Intn(len(list.Photos))] - return res, nil -} - -// GetJson returns json response received from the api -func GetJson(reqInfo map[string]string) (string, error) { - params := make(map[string]string) - params["format"] = "js" - params["n"] = "1" - - // if random is true then fetch 7 photos - if reqInfo["random"] == "true" { - params["n"] = "7" - - } - - body, err := request.GetRes(reqInfo["api"], params) - return string(body), err -} diff --git a/pkg/bpod/print.go b/pkg/bpod/print.go deleted file mode 100644 index 75bf948..0000000 --- a/pkg/bpod/print.go +++ /dev/null @@ -1,14 +0,0 @@ -package bpod - -import ( - "fmt" -) - -// Print will print the json output -func Print(res Res) { - fmt.Printf("Title: %s\n\n", res.Title) - fmt.Printf("Copyright: %s\n", res.Copyright) - fmt.Printf("Copyright Link: %s\n", res.CopyrightLink) - fmt.Printf("Date: %s\n\n", res.StartDate) - fmt.Printf("URL: %s\n", res.Url) -} |