From 965c179045fc31e5e2e45cdb37075e88ec7ee9d1 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Thu, 19 Mar 2020 10:54:33 -0400 Subject: [PATCH] Added optional reason parameter for AcceptUser --- examples/examples.go | 2 +- users.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/examples.go b/examples/examples.go index cf5c66f..f96f3dd 100644 --- a/examples/examples.go +++ b/examples/examples.go @@ -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) diff --git a/users.go b/users.go index 7a9f02c..5074441 100644 --- a/users.go +++ b/users.go @@ -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