Add comprehensive godoc documentation to all exported symbols
- Document all exported types, functions, methods, and constants across 52 files - Add package-level doc comments to client, models, utils, and ynison packages - Document HTTP method and endpoint path for each API client method - Document model struct fields and DeJSON/DeList/ToJSON/ToMap methods - Fix duplicate package doc comment in internal/models/base.go Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
7a68ad86cb
commit
0456ca0665
54 files changed
+1097
-652
No files matched your search
+10
-6
@@ -13,7 +13,7 @@ import (
|
||||
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/utils"
|
||||
)
|
||||
|
||||
// DeviceCode represents the device authorization response
|
||||
// DeviceCode represents the device authorization response from the Yandex OAuth device flow.
|
||||
type DeviceCode struct {
|
||||
DeviceCode string `json:"device_code"`
|
||||
UserCode string `json:"user_code"`
|
||||
@@ -22,7 +22,7 @@ type DeviceCode struct {
|
||||
Interval int `json:"interval"`
|
||||
}
|
||||
|
||||
// OAuthToken represents an OAuth token response
|
||||
// OAuthToken represents an OAuth token response from the Yandex OAuth token endpoint.
|
||||
type OAuthToken struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
@@ -30,7 +30,9 @@ type OAuthToken struct {
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
}
|
||||
|
||||
// DeviceAuth performs OAuth Device Flow authentication
|
||||
// DeviceAuth performs OAuth Device Flow authentication.
|
||||
// It requests a device code, invokes the onCode callback with it, then polls for the token.
|
||||
// The onCode callback receives the DeviceCode which contains the user_code and verification URL.
|
||||
func (r *Request) DeviceAuth(ctx context.Context, onCode func(*DeviceCode)) (*OAuthToken, error) {
|
||||
// Step 1: Request device code
|
||||
deviceCode, err := r.requestDeviceCode(ctx)
|
||||
@@ -47,7 +49,7 @@ func (r *Request) DeviceAuth(ctx context.Context, onCode func(*DeviceCode)) (*OA
|
||||
return r.pollForToken(ctx, deviceCode)
|
||||
}
|
||||
|
||||
// requestDeviceCode requests a device code from Yandex OAuth
|
||||
// requestDeviceCode requests a device code from the Yandex OAuth device code endpoint.
|
||||
func (r *Request) requestDeviceCode(ctx context.Context) (*DeviceCode, error) {
|
||||
// Use Yandex OAuth endpoint for device auth
|
||||
data := url.Values{}
|
||||
@@ -85,7 +87,8 @@ func (r *Request) requestDeviceCode(ctx context.Context) (*DeviceCode, error) {
|
||||
return &deviceCode, nil
|
||||
}
|
||||
|
||||
// pollForToken polls for the OAuth token
|
||||
// pollForToken polls the Yandex OAuth token endpoint until the user authorizes the device code.
|
||||
// It returns the OAuthToken once authorization is complete, or an error if the code expires or is denied.
|
||||
func (r *Request) pollForToken(ctx context.Context, deviceCode *DeviceCode) (*OAuthToken, error) {
|
||||
interval := deviceCode.Interval
|
||||
if interval == 0 {
|
||||
@@ -155,7 +158,8 @@ func (r *Request) pollForToken(ctx context.Context, deviceCode *DeviceCode) (*OA
|
||||
}
|
||||
}
|
||||
|
||||
// RefreshToken refreshes an access token using a refresh token
|
||||
// RefreshToken refreshes an access token using the provided refresh token.
|
||||
// It makes a POST request to the Yandex OAuth token endpoint with grant_type=refresh_token.
|
||||
func (r *Request) RefreshToken(ctx context.Context, refreshToken string) (*OAuthToken, error) {
|
||||
data := url.Values{}
|
||||
data.Set("grant_type", "refresh_token")
|
||||
|
||||
Reference in new issue
Block a user