Skip to content

Commit

Permalink
Added optional reason parameter for AcceptUser
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Mar 19, 2020
1 parent 1e7b901 commit 965c179
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func main() {
//
// Example: Accept/Approve the User (if required by application config)
//
if err = TonicPowAPI.AcceptUser(user.ID, ""); err != nil {
if err = TonicPowAPI.AcceptUser(user.ID, "", "awesome person"); err != nil {
log.Fatalf("get user failed error %s - api error: %s", err.Error(), TonicPowAPI.LastRequest.Error.Message)
} else {
log.Printf("user accepted: %d", user.ID)
Expand Down
7 changes: 4 additions & 3 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,17 +375,18 @@ func (c *Client) CompletePhoneVerification(phone, code string) (err error) {

// AcceptUser will accept a user (if approval is required for new users)
// ID or email address
// Reason field is optional
//
// For more information: https://docs.tonicpow.com/#65c3962d-c309-4ef4-b85f-7ec1f08f031b
func (c *Client) AcceptUser(userID uint64, email string) (err error) {
func (c *Client) AcceptUser(userID uint64, email string, reason string) (err error) {

var data map[string]string

// Basic requirements
if userID > 0 {
data = map[string]string{fieldID: fmt.Sprintf("%d", userID)}
data = map[string]string{fieldID: fmt.Sprintf("%d", userID), fieldReason: reason}
} else if len(email) > 0 {
data = map[string]string{fieldEmail: email}
data = map[string]string{fieldEmail: email, fieldReason: reason}
} else {
err = fmt.Errorf("missing required attribute: %s or %s", fieldUserID, fieldEmail)
return
Expand Down

0 comments on commit 965c179

Please sign in to comment.