Expose Lookup API (#172)

This commit is contained in:
Majd Alfhaily authored and GitHub committed 2023-04-09 18:34:46 +00:00
1 parent 8762eaf192
commit 5abc5d1777
2 files changed
+26

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ type AppStore interface {
Login(email, password, authCode string) (LoginOutput, error)
Info() (InfoOutput, error)
Revoke() error
Lookup(bundleID string) (LookupOutput, error)
Search(term string, limit int64) (SearchOutput, error)
Purchase(bundleID string) error
Download(bundleID string, outputPath string, acquireLicense bool) (DownloadOutput, error)
+25
View File
@@ -7,6 +7,31 @@ import (
"net/url"
)
type LookupOutput struct {
App App
}
func (a *appstore) Lookup(bundleID string) (LookupOutput, error) {
acc, err := a.account()
if err != nil {
return LookupOutput{}, errors.Wrap(err, ErrGetAccount.Error())
}
countryCode, err := a.countryCodeFromStoreFront(acc.StoreFront)
if err != nil {
return LookupOutput{}, errors.Wrap(err, ErrInvalidCountryCode.Error())
}
app, err := a.lookup(bundleID, countryCode)
if err != nil {
return LookupOutput{}, err
}
return LookupOutput{
App: app,
}, nil
}
func (a *appstore) lookup(bundleID, countryCode string) (App, error) {
if StoreFronts[countryCode] == "" {
return App{}, ErrInvalidCountryCode