-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78a20b1
commit 0fb1e03
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package authorizer | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
// DeactivateAccount is method attached to AuthorizerClient. | ||
// It performs deactivate_account mutation on authorizer instance. | ||
// It returns Response reference or error. | ||
// For implementation details check DeactivateAccountExample examples/deactivate_account.go | ||
func (c *AuthorizerClient) DeactivateAccount(headers map[string]string) (*Response, error) { | ||
bytesData, err := c.ExecuteGraphQL(&GraphQLRequest{ | ||
Query: `mutation deactivateAccount { deactivate_account { message } }`, | ||
Variables: nil, | ||
}, headers) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res map[string]*Response | ||
json.Unmarshal(bytesData, &res) | ||
|
||
return res["deactivate_account"], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package examples | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/authorizerdev/authorizer-go" | ||
) | ||
|
||
// DeactivateAccountExample demonstrates how to use DeactivateAccount function of authorizer sdk | ||
func DeactivateAccountExample() { | ||
c, err := authorizer.NewAuthorizerClient(ClientID, AuthorizerURL, "", nil) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
loginRes, err := c.Login(&authorizer.LoginInput{ | ||
Email: "[email protected]", | ||
Password: "Abc@123", | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
res, err := c.DeactivateAccount(map[string]string{ | ||
"Authorization": fmt.Sprintf("Bearer %s", authorizer.StringValue(loginRes.AccessToken)), | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println(res.Message) | ||
} |