@@ -17,19 +17,19 @@ const (
1717
1818type UserInterface interface {
1919 Base
20- GetUserByID (ctx context.Context , id int ) (* User , error )
21- GetUserByUsername (ctx context.Context , username string ) (* User , error )
22- GetUserByEmail (ctx context.Context , email string ) (* User , error )
20+ GetUserByID (ctx context.Context , id int ) (* User , int , error )
21+ GetUserByUsername (ctx context.Context , username string ) (* User , int , error )
22+ GetUserByEmail (ctx context.Context , email string ) (* User , int , error )
2323 CreateUser (ctx context.Context , user * User ) (* User , error )
2424 UpdateUser (ctx context.Context , user * User ) (* User , error )
2525 DeleteUser (ctx context.Context , id int ) error
2626 GetCurrentUser (ctx context.Context ) (u * User , err error )
2727}
2828
29- func (c * Client ) GetUserByID (ctx context.Context , id int ) (user * User , error error ) {
29+ func (c * Client ) GetUserByID (ctx context.Context , id int ) (user * User , statusCode int , error error ) {
3030 response , err := c .requester .Request (ctx , http .MethodGet , c .getUserURL (id ), nil )
3131 if err != nil {
32- return nil , err
32+ return nil , 0 , err
3333 }
3434 defer func () {
3535 if dErr := response .Body .Close (); dErr != nil {
@@ -38,21 +38,21 @@ func (c *Client) GetUserByID(ctx context.Context, id int) (user *User, error err
3838 }()
3939
4040 if response .StatusCode != http .StatusOK {
41- return nil , c .ErrorFromResponse (response )
41+ return nil , response . StatusCode , c .ErrorFromResponse (response )
4242 }
4343
4444 wrapper , err := Unmarshal [userWrapper ](response .Body )
4545 if err != nil {
46- return nil , err
46+ return nil , 0 , err
4747 }
4848
49- return & wrapper .User , nil
49+ return & wrapper .User , response . StatusCode , nil
5050}
5151
52- func (c * Client ) GetUserByUsername (ctx context.Context , username string ) (user * User , err error ) {
52+ func (c * Client ) GetUserByUsername (ctx context.Context , username string ) (user * User , statusCode int , err error ) {
5353 response , err := c .requester .Request (ctx , http .MethodGet , c .getUserByUsernameURL (username ), nil )
5454 if err != nil {
55- return nil , err
55+ return nil , 0 , err
5656 }
5757 defer func () {
5858 if dErr := response .Body .Close (); dErr != nil {
@@ -61,18 +61,18 @@ func (c *Client) GetUserByUsername(ctx context.Context, username string) (user *
6161 }()
6262
6363 if response .StatusCode != http .StatusOK {
64- return nil , c .ErrorFromResponse (response )
64+ return nil , response . StatusCode , c .ErrorFromResponse (response )
6565 }
6666
6767 wrapper , err := Unmarshal [userWrapper ](response .Body )
6868 if err != nil {
69- return nil , err
69+ return nil , 0 , err
7070 }
7171
72- return & wrapper .User , nil
72+ return & wrapper .User , response . StatusCode , nil
7373}
7474
75- func (c * Client ) GetUserByEmail (ctx context.Context , email string ) (* User , error ) {
75+ func (c * Client ) GetUserByEmail (ctx context.Context , email string ) (* User , int , error ) {
7676 return c .GetUserByUsername (ctx , email )
7777}
7878
0 commit comments