add api-interfaces command

master
Jordan Orelli 9 years ago
parent 9142e647bb
commit bcd00e802e

@ -0,0 +1,61 @@
package main
import (
"encoding/json"
"fmt"
"github.com/jordanorelli/steam"
)
type ApiList struct {
Interfaces []Interface `json:"interfaces"`
}
type Interface struct {
Name string `json:"name"`
Methods []Method `json:"methods"`
}
type Method struct {
Name string `json:"name"`
Version int `json:"version"`
HttpMethod string `json:"httpmethod"`
Params []Param `json:"parameters"`
}
type Param struct {
Name string `json:"name"`
Type string `json:"type"`
Optional bool `json:"optional"`
Description string `json:"description"`
}
var cmd_api_list = command{
help: `
retrieves the list of currently supported api endpoints from steam and dumps
out the raw json
`,
handler: func(c *steam.Client, args ...string) {
dump(c.Get("ISteamWebAPIUtil", "GetSupportedAPIList", "v0001"))
},
}
var cmd_api_interfaces = command{
help: `
retrieves the list of currently supported api interfaces from steam
`,
handler: func(c *steam.Client, args ...string) {
res, err := c.Get("ISteamWebAPIUtil", "GetSupportedAPIList", "v0001")
if err != nil {
bail(1, "error: %s", err)
}
var response struct {
ApiList ApiList `json:"apilist"`
}
if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
bail(1, "error parsing response: %s", err)
}
for _, i := range response.ApiList.Interfaces {
fmt.Println(i.Name)
}
},
}

@ -16,6 +16,7 @@ var commands map[string]command
func init() {
commands = map[string]command{
"api-list": cmd_api_list,
"api-interfaces": cmd_api_interfaces,
"user-friends": cmd_user_friends,
"user-id": cmd_user_id,
"user-details": cmd_user_details,
@ -57,15 +58,6 @@ retrieves info about a specific command
}
}
var cmd_api_list = command{
help: `
retrieves the list of currently supported api endpoints from steam
`,
handler: func(c *steam.Client, args ...string) {
dump(c.Get("ISteamWebAPIUtil", "GetSupportedAPIList", "v0001"))
},
}
var cmd_user_friends = command{
help: `
retrieves the provided user's list of friends

Loading…
Cancel
Save