-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
package spotlike | ||
|
||
import () | ||
import ( | ||
"github.com/thanhpk/randstr" | ||
spotifyauth "github.com/zmb3/spotify/v2/auth" | ||
) | ||
|
||
// getAuthUrlUseCase is a struct that contains the use case of getting the authentication URL. | ||
type getAuthUrlUseCase struct{} | ||
|
||
// NewGetAuthUrlUseCase returns a new instance of the GetAuthUrlUseCase struct. | ||
func NewGetAuthUrlUseCase() *getAuthUrlUseCase { | ||
return &getAuthUrlUseCase{} | ||
type getAuthUrlUseCase struct { | ||
Authenticator *spotifyauth.Authenticator | ||
} | ||
|
||
type GetAuthUrlUseCaseOutputDto struct { | ||
AuthUrl string | ||
// NewGetAuthUrlUseCase returns a new instance of the GetAuthUrlUseCase struct. | ||
func NewGetAuthUrlUseCase(authenticator *spotifyauth.Authenticator) *getAuthUrlUseCase { | ||
return &getAuthUrlUseCase{ | ||
Authenticator: authenticator, | ||
} | ||
} | ||
|
||
// Run returns the output of the GetAuthUrlUseCase. | ||
func (uc *getAuthUrlUseCase) Run() *GetAuthUrlUseCaseOutputDto { | ||
return &GetAuthUrlUseCaseOutputDto{ | ||
AuthUrl: "https://accounts.spotify.com/authorize?client_id", | ||
} | ||
// Run returns the authentication URL. | ||
func (uc *getAuthUrlUseCase) Run() string { | ||
return uc.Authenticator.AuthURL(randstr.Hex(11)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package spotlike | ||
|
||
import ( | ||
spotifyauth "github.com/zmb3/spotify/v2/auth" | ||
|
||
"github.com/yanosea/spotlike/app/config" | ||
) | ||
|
||
// getAuthenticatorUseCase is a struct that contains the use case of getting the authenticator. | ||
type getAuthenticatorUseCase struct { | ||
SpotlikeConfig *config.SpotlikeConfig | ||
} | ||
|
||
// NewGetAuthenticatorUseCase returns a new instance of the GetAuthenticatorUseCase struct. | ||
func NewGetAuthenticatorUseCase(conf *config.SpotlikeConfig) *getAuthenticatorUseCase { | ||
return &getAuthenticatorUseCase{ | ||
SpotlikeConfig: conf, | ||
} | ||
} | ||
|
||
// Run returns the authenticator. | ||
func (uc *getAuthenticatorUseCase) Run() *spotifyauth.Authenticator { | ||
return spotifyauth.New( | ||
spotifyauth.WithScopes( | ||
spotifyauth.ScopeUserFollowRead, | ||
spotifyauth.ScopeUserFollowModify, | ||
spotifyauth.ScopeUserLibraryRead, | ||
spotifyauth.ScopeUserLibraryModify, | ||
), | ||
spotifyauth.WithClientID(uc.SpotlikeConfig.SpotifyID), | ||
spotifyauth.WithClientSecret(uc.SpotlikeConfig.SpotifySecret), | ||
spotifyauth.WithRedirectURL(uc.SpotlikeConfig.SpotifyRedirectUri), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters