diff --git a/deactivate_account.go b/deactivate_account.go new file mode 100644 index 0000000..3cd024b --- /dev/null +++ b/deactivate_account.go @@ -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 +} diff --git a/examples/deactivate_account.go b/examples/deactivate_account.go new file mode 100644 index 0000000..68d2dc4 --- /dev/null +++ b/examples/deactivate_account.go @@ -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: "test@yopmail.com", + 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) +}