Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlettc22 committed Jul 3, 2019
1 parent 0bcce17 commit 949bf60
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ type Client struct {
}

// NewClient creates a new API client
func NewClient(apiKey string) (*Client, error) {
func NewClient(apiKey string) *Client {
client := &Client{
httpClient: &http.Client{},
apiBaseURL: fmt.Sprintf("%s/%s", apiEndpoint, apiVersion),
apiKey: apiKey,
}

return client, nil
return client
}
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ErrorResponse struct {
Validations []Validation `json:"validations"`
}

// Validation contains the detials of a API field validation error
// Validation contains the details of a API field validation error
type Validation struct {
Attribute string `json:"attribute"`
Message string `json:"message"`
Expand Down
3 changes: 3 additions & 0 deletions snitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (c *Client) CheckIn(token string) error {
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("Error reading the API check-in response: %v", err)
}

if resp.StatusCode == http.StatusAccepted {
return nil
Expand Down
7 changes: 1 addition & 6 deletions snitch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@ var updatedSnitch deadmanssnitch.Snitch
var updatedTags []string

func init() {
var err error

flag.StringVar(&apiKey, "apikey", "", "Dead Man's Snitch API key")
flag.IntVar(&wait, "wait", 0, "Number of seconds to sleep before deleting snitch (so it can be manually verified)")
flag.Parse()

dmsClient, err = deadmanssnitch.NewClient(apiKey)
if err != nil {
panic(err)
}
dmsClient = deadmanssnitch.NewClient(apiKey)

rand.Seed(time.Now().UTC().UnixNano())
randomTag = RandomString(10)
Expand Down

0 comments on commit 949bf60

Please sign in to comment.