Skip to content

Commit

Permalink
Add user exists endpoint to SDK (#20)
Browse files Browse the repository at this point in the history
* Add user exists endpoint to SDK

* POST -> PUT

* fix text

* Bump version
  • Loading branch information
corbadovych authored Jan 19, 2024
1 parent bd959ba commit 79abdf3
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 65 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The [Corbado](https://www.corbado.com) Go SDK provides convenient access to the
Use the following command to install the Corbado Go SDK:

```bash
go get github.com/corbado/[email protected].0
go get github.com/corbado/[email protected].3
```

### Usage
Expand Down
15 changes: 15 additions & 0 deletions internal/services/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type User interface {
Create(ctx context.Context, req api.UserCreateReq, editors ...api.RequestEditorFn) (*api.UserCreateRsp, error)
Get(ctx context.Context, userID common.UserID, params *api.UserGetParams, editors ...api.RequestEditorFn) (*api.UserGetRsp, error)
Delete(ctx context.Context, userID common.UserID, req api.UserDeleteReq, editors ...api.RequestEditorFn) (*common.GenericRsp, error)
Exists(ctx context.Context, req api.UserExistsReq, editors ...api.RequestEditorFn) (*api.UserExistsRsp, error)
}

type Impl struct {
Expand Down Expand Up @@ -105,3 +106,17 @@ func (i *Impl) Delete(ctx context.Context, userID common.UserID, req api.UserDel

return res.JSON200, nil
}

// Exists checks if a confirmed user exists for provided login identifier
func (i *Impl) Exists(ctx context.Context, req api.UserExistsReq, editors ...api.RequestEditorFn) (*api.UserExistsRsp, error) {
res, err := i.client.UserExistsWithResponse(ctx, req, editors...)
if err != nil {
return nil, errors.WithStack(err)
}

if res.JSONDefault != nil {
return nil, servererror.New(res.JSONDefault)
}

return res.JSON200, nil
}
Loading

0 comments on commit 79abdf3

Please sign in to comment.