diff --git a/cmd/api.go b/api/earthranger_service.go similarity index 96% rename from cmd/api.go rename to api/earthranger_service.go index 2b965f1..85b5e1e 100644 --- a/cmd/api.go +++ b/api/earthranger_service.go @@ -1,4 +1,4 @@ -package cmd +package api import ( "encoding/json" @@ -32,7 +32,7 @@ type Response struct { // package funtions // ---------------------------------------------- -func authenticate(sitename, username, password string) (*Response, error) { +func Authenticate(sitename, username, password string) (*Response, error) { // Create a new HTTP client and make a POST request to the authentication endpoint client := &http.Client{} req, err := http.NewRequest("POST", fmt.Sprintf("https://%s%s%s", sitename, DOMAIN, API_AUTH), nil) diff --git a/cmd/auth.go b/cmd/auth.go index 180f570..c09352a 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/doneill/er-cli-go/api" "github.com/spf13/cobra" ) @@ -41,7 +42,7 @@ func auth() { } // Call the authenticate function to get the access token and expires in - response, err := authenticate(SITENAME, USERNAME, password) + response, err := api.Authenticate(SITENAME, USERNAME, password) if err != nil { fmt.Println("Error authenticating:", err) os.Exit(1)