Alphan version
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s

This commit is contained in:
2025-06-01 20:40:38 -04:00
parent f4fa996d53
commit b0385b15ab
4 changed files with 184 additions and 185 deletions

105
client.go
View File

@ -2,7 +2,6 @@ package mysubaru
import (
"encoding/json"
"fmt"
"io"
"log/slog"
"sync"
@ -283,15 +282,15 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
// Finished RemoteServiceState Service Request does not include Service Request ID
c.logger.Debug("Remote service request completed successfully")
case sr.RemoteServiceState == "started":
time.Sleep(3 * time.Second)
time.Sleep(5 * time.Second)
c.logger.Debug("Subaru API reports remote service request (started) is in progress", "id", sr.ServiceRequestID)
c.execute(pollingUrl, GET, map[string]string{"serviceRequestId": sr.ServiceRequestID}, pollingUrl, false)
case sr.RemoteServiceState == "stopping":
time.Sleep(3 * time.Second)
time.Sleep(5 * time.Second)
c.logger.Debug("Subaru API reports remote service request (stopping) is in progress", "id", sr.ServiceRequestID)
c.execute(pollingUrl, GET, map[string]string{"serviceRequestId": sr.ServiceRequestID}, pollingUrl, false)
default:
time.Sleep(3 * time.Second)
time.Sleep(5 * time.Second)
c.logger.Debug("Subaru API reports remote service request (stopping) is in progress")
c.execute(pollingUrl, GET, map[string]string{"serviceRequestId": sr.ServiceRequestID}, pollingUrl, false)
}
@ -507,57 +506,57 @@ func (c *Client) setDeviceName() bool {
return true
}
// listDevices .
func (c *Client) listDevices() {
// Accept: application/json, text/javascript, */*; q=0.01
// Accept-Encoding: gzip, deflate, br
// Accept-Language: en-US,en;q=0.9,ru;q=0.8
// Connection: keep-alive
// Cookie: ORA_OTD_JROUTE=ozLwELf5jS-NHQ2CKZorOFfRgb8uo6lL; soa-visitor=12212021VHWnkqERZYThWe87TLUhr2Db; AMCVS_94001C8B532957140A490D4D%40AdobeOrg=1; mys-referringCodes=7~direct~; s_cc=true; AMCVS_subarucom%40AdobeOrg=1; style=null; s_pv=login.html; AMCV_subarucom%40AdobeOrg=-1124106680%7CMCIDTS%7C18988%7CMCMID%7C81535064704660726005836131001032500276%7CMCAID%7CNONE%7CMCOPTOUT-1640567559s%7CNONE%7CvVersion%7C5.2.0; AMCV_94001C8B532957140A490D4D%40AdobeOrg=-1124106680%7CMCIDTS%7C18988%7CMCMID%7C76913534164341455390435376071204508177%7CMCAID%7CNONE%7CMCOPTOUT-1640567559s%7CNONE%7CvVersion%7C5.2.0; s_sq=subarumysubarucwpprod%3D%2526c.%2526a.%2526activitymap.%2526page%253Dlogin.html%2526link%253DLog%252520In%2526region%253DloginForm%2526pageIDType%253D1%2526.activitymap%2526.a%2526.c%2526pid%253Dlogin.html%2526pidt%253D1%2526oid%253DLog%252520In%2526oidt%253D3%2526ot%253DSUBMIT; JSESSIONID=9685CFEB7888A0E6E25239D559E3B580; X-Oracle-BMC-LBS-Route=89e3283ece707e8a0ba4850e1a622122e039fd3d27da03a11a2ff120e313e9b656c62fd8a7c42ae8061a49ad6e1caf63a49d7befe4ad2a0194b0aeca
// Host: www.mysubaru.com
// Referer: https://www.mysubaru.com/profile/authorizedDevices.html
// User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
// X-Requested-With: XMLHttpRequest
resp, err := c.httpClient.
SetBaseURL(WEB_API_SERVER[c.country]).
R().
EnableTrace().
Get(apiURLs["WEB_API_LIST_DEVICES"])
// // listDevices .
// func (c *Client) listDevices() {
// // Accept: application/json, text/javascript, */*; q=0.01
// // Accept-Encoding: gzip, deflate, br
// // Accept-Language: en-US,en;q=0.9,ru;q=0.8
// // Connection: keep-alive
// // Cookie: ORA_OTD_JROUTE=ozLwELf5jS-NHQ2CKZorOFfRgb8uo6lL; soa-visitor=12212021VHWnkqERZYThWe87TLUhr2Db; AMCVS_94001C8B532957140A490D4D%40AdobeOrg=1; mys-referringCodes=7~direct~; s_cc=true; AMCVS_subarucom%40AdobeOrg=1; style=null; s_pv=login.html; AMCV_subarucom%40AdobeOrg=-1124106680%7CMCIDTS%7C18988%7CMCMID%7C81535064704660726005836131001032500276%7CMCAID%7CNONE%7CMCOPTOUT-1640567559s%7CNONE%7CvVersion%7C5.2.0; AMCV_94001C8B532957140A490D4D%40AdobeOrg=-1124106680%7CMCIDTS%7C18988%7CMCMID%7C76913534164341455390435376071204508177%7CMCAID%7CNONE%7CMCOPTOUT-1640567559s%7CNONE%7CvVersion%7C5.2.0; s_sq=subarumysubarucwpprod%3D%2526c.%2526a.%2526activitymap.%2526page%253Dlogin.html%2526link%253DLog%252520In%2526region%253DloginForm%2526pageIDType%253D1%2526.activitymap%2526.a%2526.c%2526pid%253Dlogin.html%2526pidt%253D1%2526oid%253DLog%252520In%2526oidt%253D3%2526ot%253DSUBMIT; JSESSIONID=9685CFEB7888A0E6E25239D559E3B580; X-Oracle-BMC-LBS-Route=89e3283ece707e8a0ba4850e1a622122e039fd3d27da03a11a2ff120e313e9b656c62fd8a7c42ae8061a49ad6e1caf63a49d7befe4ad2a0194b0aeca
// // Host: www.mysubaru.com
// // Referer: https://www.mysubaru.com/profile/authorizedDevices.html
// // User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
// // X-Requested-With: XMLHttpRequest
// resp, err := c.httpClient.
// SetBaseURL(WEB_API_SERVER[c.country]).
// R().
// EnableTrace().
// Get(apiURLs["WEB_API_LIST_DEVICES"])
// Explore response object
fmt.Println("Response Info:")
fmt.Println(" Error :", err)
fmt.Println(" Status Code:", resp.StatusCode())
fmt.Println(" Status :", resp.Status())
fmt.Println(" Proto :", resp.Proto())
fmt.Println(" Time :", resp.Duration())
fmt.Println(" Received At:", resp.ReceivedAt())
// fmt.Println(" Body :\n", resp)
fmt.Println()
// // Explore response object
// fmt.Println("Response Info:")
// fmt.Println(" Error :", err)
// fmt.Println(" Status Code:", resp.StatusCode())
// fmt.Println(" Status :", resp.Status())
// fmt.Println(" Proto :", resp.Proto())
// fmt.Println(" Time :", resp.Duration())
// fmt.Println(" Received At:", resp.ReceivedAt())
// // fmt.Println(" Body :\n", resp)
// fmt.Println()
// Explore trace info
fmt.Println("Request Trace Info:")
ti := resp.Request.TraceInfo()
fmt.Println(" DNSLookup :", ti.DNSLookup)
fmt.Println(" ConnTime :", ti.ConnTime)
fmt.Println(" TCPConnTime :", ti.TCPConnTime)
fmt.Println(" TLSHandshake :", ti.TLSHandshake)
fmt.Println(" ServerTime :", ti.ServerTime)
fmt.Println(" ResponseTime :", ti.ResponseTime)
fmt.Println(" TotalTime :", ti.TotalTime)
fmt.Println(" IsConnReused :", ti.IsConnReused)
fmt.Println(" IsConnWasIdle :", ti.IsConnWasIdle)
fmt.Println(" ConnIdleTime :", ti.ConnIdleTime)
fmt.Println(" RequestAttempt:", ti.RequestAttempt)
fmt.Println(" RemoteAddr :", ti.RemoteAddr)
// // Explore trace info
// fmt.Println("Request Trace Info:")
// ti := resp.Request.TraceInfo()
// fmt.Println(" DNSLookup :", ti.DNSLookup)
// fmt.Println(" ConnTime :", ti.ConnTime)
// fmt.Println(" TCPConnTime :", ti.TCPConnTime)
// fmt.Println(" TLSHandshake :", ti.TLSHandshake)
// fmt.Println(" ServerTime :", ti.ServerTime)
// fmt.Println(" ResponseTime :", ti.ResponseTime)
// fmt.Println(" TotalTime :", ti.TotalTime)
// fmt.Println(" IsConnReused :", ti.IsConnReused)
// fmt.Println(" IsConnWasIdle :", ti.IsConnWasIdle)
// fmt.Println(" ConnIdleTime :", ti.ConnIdleTime)
// fmt.Println(" RequestAttempt:", ti.RequestAttempt)
// fmt.Println(" RemoteAddr :", ti.RemoteAddr)
// c.logger.Debug("LIST DEVICES OUTPUT", "body", string([]byte(resp.Body())))
// // c.logger.Debug("LIST DEVICES OUTPUT", "body", string([]byte(resp.Body())))
// c.httpClient.SetBaseURL(WEB_API_SERVER[c.country]).SetCookies(c.cookies)
// reqURL := apiURLs["WEB_API_LIST_DEVICES"]
// resp := c.execute(reqURL, GET, map[string]string{}, "", false)
// // c.httpClient.SetBaseURL(WEB_API_SERVER[c.country]).SetCookies(c.cookies)
// // reqURL := apiURLs["WEB_API_LIST_DEVICES"]
// // resp := c.execute(reqURL, GET, map[string]string{}, "", false)
// if isResponseSuccessfull(resp) {
// logger.Debugf("LIST DEVICES OUTPUT >> %v\n", string(resp))
// }
}
// // if isResponseSuccessfull(resp) {
// // logger.Debugf("LIST DEVICES OUTPUT >> %v\n", string(resp))
// // }
// }