@@ -38,29 +38,29 @@ import (
3838 "github.com/hammingweight/synkctl/configuration"
3939)
4040
41- type PublicKeyResponse struct {
41+ type publicKeyResponse struct {
4242 Code int `json:"code"`
4343 Msg string `json:"msg"`
4444 Success bool `json:"success"`
4545 Data string `json:"data"` // The Base64 encoded RSA key
4646}
4747
48- type TokenData struct {
48+ type tokenData struct {
4949 AccessToken string `json:"access_token"`
5050 RefreshToken string `json:"refresh_token"`
5151 Scope string `json:"scope"`
5252 TokenType string `json:"token_type"`
5353 ExpiresIn int `json:"expires_in"`
5454}
5555
56- type TokenResponse struct {
56+ type tokenResponse struct {
5757 Code int `json:"code"`
5858 Msg string `json:"msg"`
5959 Success bool `json:"success"`
60- Data TokenData `json:"data"`
60+ Data tokenData `json:"data"`
6161}
6262
63- type LoginPayload struct {
63+ type loginPayload struct {
6464 Nonce int64 `json:"nonce"`
6565 AreaCode string `json:"areaCode"`
6666 ClientID string `json:"client_id"`
@@ -79,7 +79,7 @@ func md5Hash(s string) string {
7979}
8080
8181// GetSunsynkToken executes the full authentication workflow and returns the token data.
82- func getSunsynkToken (endpoint , username , password string ) (* TokenData , error ) {
82+ func getSunsynkToken (endpoint , username , password string ) (* tokenData , error ) {
8383 client := & http.Client {}
8484 source := "sunsynk"
8585
@@ -113,7 +113,7 @@ func getSunsynkToken(endpoint, username, password string) (*TokenData, error) {
113113 return nil , fmt .Errorf ("failed to read public key response: %w" , err )
114114 }
115115
116- var pkResp PublicKeyResponse
116+ var pkResp publicKeyResponse
117117 if err := json .Unmarshal (bodyPK , & pkResp ); err != nil {
118118 return nil , fmt .Errorf ("failed to parse public key JSON: %w" , err )
119119 }
@@ -155,7 +155,7 @@ func getSunsynkToken(endpoint, username, password string) (*TokenData, error) {
155155 encryptedPasswordB64 := base64 .StdEncoding .EncodeToString (encryptedBytes )
156156
157157 // 6. Login to get the bearer token
158- payload := LoginPayload {
158+ payload := loginPayload {
159159 Nonce : nonce ,
160160 AreaCode : "sunsynk" ,
161161 ClientID : "csp-web" ,
@@ -188,7 +188,7 @@ func getSunsynkToken(endpoint, username, password string) (*TokenData, error) {
188188 return nil , fmt .Errorf ("failed to read login response: %w" , err )
189189 }
190190
191- var tokenResp TokenResponse
191+ var tokenResp tokenResponse
192192 if err := json .Unmarshal (bodyLogin , & tokenResp ); err != nil {
193193 return nil , fmt .Errorf ("failed to parse login JSON: %w (body: %s)" , err , string (bodyLogin ))
194194 }
0 commit comments