Skip to content

Commit

Permalink
feat: add game card
Browse files Browse the repository at this point in the history
  • Loading branch information
starudream committed Dec 25, 2023
1 parent e0fb298 commit a8d61ba
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/miyoushe/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package miyoushe

const (
AddrTakumi = "https://api-takumi.mihoyo.com"
AddrBBS = "https://bbs-api.miyoushe.com"
AddrTakumi = "https://api-takumi.mihoyo.com"
AddrTakumiRecord = "https://api-takumi-record.mihoyo.com"
AddrBBS = "https://bbs-api.miyoushe.com"
)
27 changes: 27 additions & 0 deletions api/miyoushe/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,30 @@ func ListGameRole(gameBiz string, account config.Account) (*ListGameRoleData, er
req := common.R(account.Device).SetCookies(common.SToken(account)).SetQueryParam("game_biz", gameBiz)
return common.Exec[*ListGameRoleData](req, "GET", AddrTakumi+"/binding/api/getUserGameRolesByStoken")
}

type ListGameCardData struct {
List []*GameCard `json:"list"`
}

type GameCard struct {
HasRole bool `json:"has_role"`
IsPublic bool `json:"is_public"`
GameId int `json:"game_id"`
GameRoleId string `json:"game_role_id"`
Region string `json:"region"`
RegionName string `json:"region_name"`
Level int `json:"level"`
Nickname string `json:"nickname"`
Data []*GameCardItem `json:"data"`
}

type GameCardItem struct {
Type int `json:"type"`
Name string `json:"name"`
Value string `json:"value"`
}

func ListGameCard(account config.Account) (*ListGameCardData, error) {
req := common.R(account.Device).SetCookies(common.SToken(account)).SetQueryParam("uid", account.Uid)
return common.Exec[*ListGameCardData](req, "GET", AddrTakumiRecord+"/game_record/card/api/getGameRecordCard")
}
5 changes: 5 additions & 0 deletions api/miyoushe/game_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ func TestListGameRole(t *testing.T) {
testutil.LogNoErr(t, err, data)
})
}

func TestListGameCard(t *testing.T) {
data, err := ListGameCard(config.C().FirstAccount())
testutil.LogNoErr(t, err, data)
}

0 comments on commit a8d61ba

Please sign in to comment.