Skip to content

Commit

Permalink
chore: refactor hand-written code to match codegen updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran88 committed Dec 23, 2024
1 parent ad5ba71 commit 71f580b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
32 changes: 16 additions & 16 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func (a *auth) CreateMagicLinkWithEmail(
send bool,
opts *MagicLinkOptions,
) (*MagicLink, error) {
args := CreateMagicLinkBody{
Email: email,
Channel: EmailChannel,
Type: magicLinkType,
Send: send,
args := magicLinkArgs{
Email: email,
ChannelType: EmailChannel,
Type: magicLinkType,
Send: send,
}

return a.createMagicLink(args, opts)
Expand All @@ -67,11 +67,11 @@ func (a *auth) CreateMagicLinkWithPhone(
send bool,
opts *MagicLinkOptions,
) (*MagicLink, error) {
args := CreateMagicLinkBody{
Phone: phone,
Channel: PhoneChannel,
Type: magicLinkType,
Send: send,
args := magicLinkArgs{
Phone: phone,
ChannelType: PhoneChannel,
Type: magicLinkType,
Send: send,
}

return a.createMagicLink(args, opts)
Expand All @@ -85,11 +85,11 @@ func (a *auth) CreateMagicLinkWithUser(
send bool,
opts *MagicLinkOptions,
) (*MagicLink, error) {
args := CreateMagicLinkBody{
UserID: userID,
Channel: channel,
Type: magicLinkType,
Send: send,
args := magicLinkArgs{
UserID: userID,
ChannelType: channel,
Type: magicLinkType,
Send: send,
}

return a.createMagicLink(args, opts)
Expand Down Expand Up @@ -123,7 +123,7 @@ func (a *auth) ValidateJWT(jwt string) (string, error) {
return userID, nil
}

func (a *auth) createMagicLink(args CreateMagicLinkBody, opts *MagicLinkOptions) (*MagicLink, error) {
func (a *auth) createMagicLink(args magicLinkArgs, opts *MagicLinkOptions) (*MagicLink, error) {
if opts != nil {
args.Language = opts.Language
args.MagicLinkPath = opts.MagicLinkPath
Expand Down
14 changes: 5 additions & 9 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import (
"strings"
)

type PassageUser = User
type CreateUserArgs = CreateUserBody
type UpdateUserOptions = UpdateBody

type user struct {
appID string
client *ClientWithResponses
Expand All @@ -35,7 +31,7 @@ func (u *user) Get(userID string) (*PassageUser, error) {
}

if res.JSON200 != nil {
return &res.JSON200.User, nil
return &res.JSON200.PassageUser, nil
}

return nil, errorFromResponse(res.Body, res.StatusCode())
Expand Down Expand Up @@ -91,7 +87,7 @@ func (u *user) Activate(userID string) (*PassageUser, error) {
}

if res.JSON200 != nil {
return &res.JSON200.User, nil
return &res.JSON200.PassageUser, nil
}

return nil, errorFromResponse(res.Body, res.StatusCode())
Expand All @@ -109,7 +105,7 @@ func (u *user) Deactivate(userID string) (*PassageUser, error) {
}

if res.JSON200 != nil {
return &res.JSON200.User, nil
return &res.JSON200.PassageUser, nil
}

return nil, errorFromResponse(res.Body, res.StatusCode())
Expand All @@ -127,7 +123,7 @@ func (u *user) Update(userID string, options UpdateUserOptions) (*PassageUser, e
}

if res.JSON200 != nil {
return &res.JSON200.User, nil
return &res.JSON200.PassageUser, nil
}

return nil, errorFromResponse(res.Body, res.StatusCode())
Expand All @@ -145,7 +141,7 @@ func (u *user) Create(args CreateUserArgs) (*PassageUser, error) {
}

if res.JSON201 != nil {
return &res.JSON201.User, nil
return &res.JSON201.PassageUser, nil
}

return nil, errorFromResponse(res.Body, res.StatusCode())
Expand Down

0 comments on commit 71f580b

Please sign in to comment.