Skip to content

Commit

Permalink
Merge pull request #3 from doneill/improvement/jdo-20-add-api-package
Browse files Browse the repository at this point in the history
Refactor api source to api package
  • Loading branch information
doneill committed Nov 21, 2023
2 parents 002508d + f8c8a2f commit eb23d4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/api.go → api/earthranger_service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package api

import (
"encoding/json"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"

"github.com/doneill/er-cli-go/api"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit eb23d4a

Please sign in to comment.