summary refs log tree commit diff stats
path: root/cmd/cetus-nasa
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/cetus-nasa')
-rw-r--r--cmd/cetus-nasa/cetus-nasa.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/cmd/cetus-nasa/cetus-nasa.go b/cmd/cetus-nasa/cetus-nasa.go
index 5f018cb..39b22c0 100644
--- a/cmd/cetus-nasa/cetus-nasa.go
+++ b/cmd/cetus-nasa/cetus-nasa.go
@@ -58,15 +58,10 @@ func main() {
 		picturePath string
 		apodRes     nasa.APOD
 		err         error
-		apodInfo    map[string]string
 	)
 
-	apodInfo = make(map[string]string)
-	apodInfo["api"] = api
-	apodInfo["apiKey"] = apiKey
-	apodInfo["date"] = date
-
-	apodRes, err = nasa.APODPath(apodInfo, timeout)
+	// get response from api
+	apodRes, err = getAPODRes()
 	if err != nil {
 		if len(apodRes.Msg) != 0 {
 			log.Println("Message: ", apodRes.Msg)
@@ -126,3 +121,19 @@ func printDetails(apodRes nasa.APOD) {
 	}
 	fmt.Printf("Explanation: %s\n", apodRes.Explanation)
 }
+
+func getAPODRes() (nasa.APOD, error) {
+	var (
+		apodRes  nasa.APOD
+		err      error
+		apodInfo map[string]string
+	)
+	apodInfo = make(map[string]string)
+	apodInfo["api"] = api
+	apodInfo["apiKey"] = apiKey
+	apodInfo["date"] = date
+
+	apodRes, err = nasa.APODPath(apodInfo, timeout)
+
+	return apodRes, err
+}