Skip to content

Commit

Permalink
Added new PauseUser request
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jan 11, 2020
1 parent 671b95a commit f26a564
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ func main() {
// log.Fatalf("activate user failed - api error: %s", TonicPowAPI.LastRequest.Error.Message)
//}

//
// Example: Pause User
//
//if err = TonicPowAPI.PauseUser(user.ID,"reviewing account"); err != nil {
// log.Fatalf("pause user failed - api error: %s", TonicPowAPI.LastRequest.Error.Message)
//}

//
// Example: Create a Visitor Session
//
Expand Down
27 changes: 26 additions & 1 deletion users.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (c *Client) ActivateUser(userID uint64) (err error) {
}

// Start the post data
data := map[string]string{fieldUserID: fmt.Sprintf("%d", userID)}
data := map[string]string{fieldID: fmt.Sprintf("%d", userID)}

// Fire the request
var response string
Expand All @@ -342,3 +342,28 @@ func (c *Client) ActivateUser(userID uint64) (err error) {
err = c.error(http.StatusOK, response)
return
}

// PauseUser will pause a user account (all payouts go to internal address)
//
// For more information: https://docs.tonicpow.com/#3307310d-86a9-4a5c-84ff-c38c581c77e5
func (c *Client) PauseUser(userID uint64, reason string) (err error) {

// Basic requirements
if userID == 0 || len(reason) == 0 {
err = fmt.Errorf("missing required attribute: %s", fieldUserID)
return
}

// Start the post data
data := map[string]string{fieldID: fmt.Sprintf("%d", userID), fieldReason: reason}

// Fire the request
var response string
if response, err = c.request(fmt.Sprintf("%s/status/pause", modelUser), http.MethodPut, data, ""); err != nil {
return
}

// Only a 200 is treated as a success
err = c.error(http.StatusOK, response)
return
}

0 comments on commit f26a564

Please sign in to comment.