mirror of
https://github.com/sstent/go-garth.git
synced 2026-02-02 04:21:43 +00:00
feat(refactor): Implement 1A.1 Package Structure Refactoring
This commit implements the package structure refactoring as outlined in phase1.md (Task 1A.1). Key changes include: - Reorganized packages into `pkg/garmin` for public API and `internal/` for internal implementations. - Updated all import paths to reflect the new structure. - Consolidated types and client logic into their respective new packages. - Updated `cmd/garth/main.go` to use the new public API. - Fixed various compilation and test issues encountered during the refactoring process. - Converted `internal/api/client/auth_test.go` to a functional test. This establishes a solid foundation for future enhancements and improves maintainability.
This commit is contained in:
50
pkg/garmin/client.go
Normal file
50
pkg/garmin/client.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package garmin
|
||||
|
||||
import (
|
||||
internalClient "garmin-connect/internal/api/client"
|
||||
"garmin-connect/internal/types"
|
||||
)
|
||||
|
||||
// Client is the main Garmin Connect client type
|
||||
type Client struct {
|
||||
Client *internalClient.Client
|
||||
}
|
||||
|
||||
// NewClient creates a new Garmin Connect client
|
||||
func NewClient(domain string) (*Client, error) {
|
||||
c, err := internalClient.NewClient(domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Client{Client: c}, nil
|
||||
}
|
||||
|
||||
// Login authenticates to Garmin Connect
|
||||
func (c *Client) Login(email, password string) error {
|
||||
return c.Client.Login(email, password)
|
||||
}
|
||||
|
||||
// LoadSession loads a session from a file
|
||||
func (c *Client) LoadSession(filename string) error {
|
||||
return c.Client.LoadSession(filename)
|
||||
}
|
||||
|
||||
// SaveSession saves the current session to a file
|
||||
func (c *Client) SaveSession(filename string) error {
|
||||
return c.Client.SaveSession(filename)
|
||||
}
|
||||
|
||||
// GetActivities retrieves recent activities
|
||||
func (c *Client) GetActivities(limit int) ([]Activity, error) {
|
||||
return c.Client.GetActivities(limit)
|
||||
}
|
||||
|
||||
// OAuth1Token returns the OAuth1 token
|
||||
func (c *Client) OAuth1Token() *types.OAuth1Token {
|
||||
return c.Client.OAuth1Token
|
||||
}
|
||||
|
||||
// OAuth2Token returns the OAuth2 token
|
||||
func (c *Client) OAuth2Token() *types.OAuth2Token {
|
||||
return c.Client.OAuth2Token
|
||||
}
|
||||
Reference in New Issue
Block a user