Skip to content

Commit

Permalink
Merge pull request #7 from bots-house/feat/in-app-purchase
Browse files Browse the repository at this point in the history
add in-app-purchase field
  • Loading branch information
nikkibuster authored Oct 9, 2024
2 parents c4daac7 + ab9b33b commit 6fcb39e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/scraper/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ var appDetailsMapping = shared.AppMapping{
},
RecentChanges: []any{"ds:5", 1, 2, 144, 1, 1},
Comments: []any{"ds:9", 0},
InAppPurchase: shared.MappingWithFunc[string, bool]{
Path: []any{"ds:5", 1, 2, 9, 3, 1},
Fun: func(s string) bool {
return strings.Contains(s, "Purchase")
},
},
}

type dataSafety struct {
Expand Down
1 change: 1 addition & 0 deletions internal/shared/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type AppMapping struct {
Version MappingWithFunc[string, string]
RecentChanges []any
Comments []any // TODO: no comments by this path
InAppPurchase MappingWithFunc[string, bool]
}

type MappingWithFunc[I, O any] struct {
Expand Down
2 changes: 2 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type App struct {
Version string `json:"version,omitempty"`
RecentChanges string `json:"recent_changes,omitempty"`
Comments []any `json:"comments,omitempty"`
InAppPurchase bool `json:"in_app_purchase"`
}

func newFromInternal(app *models.App) App {
Expand Down Expand Up @@ -105,6 +106,7 @@ func newFromInternal(app *models.App) App {
Version: app.Version,
RecentChanges: app.RecentChanges,
Comments: app.Comments,
InAppPurchase: app.InAppPurchase,
}
}

Expand Down
1 change: 1 addition & 0 deletions models/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type App struct {
Version string
RecentChanges string
Comments []any
InAppPurchase bool
}

func (app *App) Assign(rhs *App) App {
Expand Down
38 changes: 38 additions & 0 deletions scrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,41 @@ func Test_Scraper(t *testing.T) {
}
})
}

func Test_InAppPurchases(t *testing.T) {
tests := []struct {
appID string
inAppPurchase bool
}{
{
appID: "com.mojang.minecraftpe",
inAppPurchase: true,
},

{
appID: "com.miniclip.plagueinc",
inAppPurchase: true,
},

{
appID: "com.einnovation.temu",
},

{
appID: "com.whatsapp",
},
}

collector := New()

for _, test := range tests {
app, err := collector.App(context.Background(), ApplicationSpec{
AppID: test.appID,
})
if !assert.NoError(t, err) {
return
}

assert.Equal(t, test.inAppPurchase, app.InAppPurchase)
}
}

0 comments on commit 6fcb39e

Please sign in to comment.