Files
rideaware-api/internal/integration/model.go

36 lines
1.3 KiB
Go

package integration
import "time"
type OAuthConnection struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"not null;uniqueIndex:idx_user_provider" json:"user_id"`
Provider string `gorm:"not null;uniqueIndex:idx_user_provider" json:"provider"` // "garmin", "wahoo"
AccessToken string `gorm:"not null" json:"-"`
RefreshToken string `gorm:"default:''" json:"-"`
TokenExpiresAt time.Time `json:"token_expires_at"`
ProviderUserID string `gorm:"default:''" json:"provider_user_id"`
Scopes string `gorm:"default:''" json:"scopes"`
Status string `gorm:"default:'active'" json:"status"` // "active", "revoked", "expired"
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (OAuthConnection) TableName() string {
return "oauth_connections"
}
type OAuthState struct {
ID uint `gorm:"primaryKey"`
State string `gorm:"uniqueIndex;not null"`
UserID uint `gorm:"not null"`
Provider string `gorm:"not null"` // "garmin", "wahoo"
CodeVerifier string `gorm:"default:''"` // for PKCE (Garmin)
ExpiresAt time.Time `gorm:"not null"`
CreatedAt time.Time
}
func (OAuthState) TableName() string {
return "oauth_states"
}