carlocayos / go-cod Goto Github PK
View Code? Open in Web Editor NEWCall of Duty API Go SDK
Home Page: https://github.com/carlocayos/go-cod
License: MIT License
Call of Duty API Go SDK
Home Page: https://github.com/carlocayos/go-cod
License: MIT License
When trying to import v2 I get the following message:
require github.com/carlocayos/go-cod: version "v2.0.0" invalid: should be v0 or v1, not v2
Problem:
In the Gamer Loot response payload, it returns a "streams" object with repeating objects (i.e. loot_season_1, loot_season_2, etc).
{
"status": "success",
"data": {
"streams": {
"loot_season_1": {
"name": "loot_season_1",
"categoryNameLabel": "Season 1",
"categoryTitleLabel": "Season 1",
"tier": 0,
"streamType": "season",
"rarity": null,
"lootType": null,
"seasonInfoUrlKey": "season-1",
"itemsObtained": null,
"premiumTokenOwnedNotRedeemed": false,
"tierSkipTokensUnredeemed": null,
"premium": false
},
"loot_season_0": {
"name": "loot_season_0",
"categoryNameLabel": "Season 0",
"categoryTitleLabel": "Season 0",
"tier": 0,
"streamType": "season",
"rarity": null,
"lootType": null,
"seasonInfoUrlKey": "season-0",
"itemsObtained": null,
"premiumTokenOwnedNotRedeemed": false,
"tierSkipTokensUnredeemed": null,
"premium": false
}
}
}
}
Find a way using go-swagger to autogenerate and represent the streams
field as type map[string]SomeStruct
Sample
type SomeStruct struct {
Name string
CategoryNameLabel string
CategoryTitleLabel string
...
}
someStruct := streams["loot_season_1"]
someStruct.CategoryNameLabel
Problem:
Activision can introduce breaking changes to the COD API. The SDK, along with all SDK users will then have to update their codes to adhere to the changes.
Solution:
Implement a facade pattern for simplicity and protecting SDK users of any breaking changes (e.g. Activision changing API format). The facade must be simple, allowing users to pass only the necessary values to the request without managing the swagger auto-generated codes.
Example:
Current steps in sending a leader board request.
c := gocod.NewClient(nil)
serviceOperations := c.ServiceClient.Operations
leaderBoardParams := service.LeaderBoardParams{
Page: 1,
Platform: "battle",
Title: "mw",
Context: context.Background(),
}
leaderBoardResponse, err := serviceOperations.LeaderBoard(&leaderBoardParams)
We can simplify it to this code
c := gocod.NewClient(nil)
c.LeaderBoard(context.Background, 1, "battle", "mw")
// or create a simple struct containing passed parameter values
Add constant declarations for Game Type, Game Title, Lookup Types, Platforms ...
See https://github.com/carlocayos/go-cod/blob/main/go-cod.go#L16-L37
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.