Skip to content

Commit

Permalink
Merge pull request #5 from authorizerdev/feat/deativate-account
Browse files Browse the repository at this point in the history
feat: add deactivate acc
  • Loading branch information
lakhansamani authored Oct 12, 2023
2 parents 78a20b1 + 0fb1e03 commit e92ea54
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
24 changes: 24 additions & 0 deletions deactivate_account.go
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
}
32 changes: 32 additions & 0 deletions examples/deactivate_account.go
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)
}

0 comments on commit e92ea54

Please sign in to comment.