Skip to content

Commit

Permalink
Merge branch 'release/v1.0.29'
Browse files Browse the repository at this point in the history
  • Loading branch information
SheltonZhu committed Sep 18, 2024
2 parents bd76b75 + a75e41f commit c53fc96
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/driver/app_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package driver

// GetAppVersion get app version (win, android, mac, mac_arc, etc...)
func (c *Pan115Client) GetAppVersion() ([]AppVersion, error) {
result := VersionResp{}
req := c.NewRequest().
SetResult(&result).
ForceContentType("application/json;charset=UTF-8")

resp, err := req.Get(ApiGetVersion)

err = CheckErr(err, &result, resp)
if err != nil {
return nil, err
}

return result.Data.GetAppVersions(), nil
}

type VersionResp struct {
BasicResp
Data Versions `json:"data"`
}

type Versions map[string]map[string]any

func (v Versions) GetAppVersions() []AppVersion {
vers := make([]AppVersion, len(v))
for app, ver := range v {
vers = append(vers, AppVersion{
AppName: app,
Version: ver["version_code"].(string),
})
}
return vers
}

type AppVersion struct {
AppName string
Version string
}
9 changes: 9 additions & 0 deletions pkg/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,12 @@ func TestShareSnap(t *testing.T) {
_, err := client.GetShareSnap("ssw60op83nuc", "test", "")
assert.ErrorIs(t, err, ErrSharedNotFound)
}

func TestGetVersion(t *testing.T) {
down := teardown(t)
defer down(t)

vers, err := client.GetAppVersion()
assert.NoError(t, err)
assert.NotEmpty(t, vers)
}

0 comments on commit c53fc96

Please sign in to comment.