trials

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NineBaseURL                = "https://api.trialsofthenine.com"
	DestinyTrialsReportBaseURL = "https://api.destinytrialsreport.com"
	NineCurrentWeekStatsPath   = "/week/0/"
	// MembershipID
	NinePlayerSummaryFmt              = "/player/%s/"
	NinePlayerCurrentWeekStatsPathFmt = "/slack/trials/week/%s/0"
	NineRivalsPathFmt                 = "/player/%s/rivals/"
	NineFireteamFmt                   = "/player/%s/fireteam/"
	NineTeammatesFmt                  = "/player/%s/teammates/"

	// How many weapons to return in the Alexa response describing usage stats
	TopWeaponUsageLimit = 3
)

Constant Trials Report API endpoints

View Source
const (
	// RequestOrigin will be used in the Origin header when making requests to Trials Report
	RequestOrigin = "https://warmind-network.herokuapp.com"
)

Variables

This section is empty.

Functions

func GetCurrentMap

func GetCurrentMap() (*skillserver.EchoResponse, error)

GetCurrentMap will make a request to the Trials Report API endpoint and return an Alexa response describing the current map.

func GetCurrentWeek

func GetCurrentWeek(token string) (*skillserver.EchoResponse, error)

GetCurrentWeek is responsible for requesting the players stats from the current week from Trials Report.

func GetPersonalTopWeapons

func GetPersonalTopWeapons(token string) (*skillserver.EchoResponse, error)

GetPersonalTopWeapons will return a summary of the top weapons used by the linked player/account.

func GetPopularWeaponTypes

func GetPopularWeaponTypes() (*skillserver.EchoResponse, error)

GetPopularWeaponTypes will hit the Trials Report endpoint to load info about which weapon types are getting the most kills

func GetWeaponUsagePercentages

func GetWeaponUsagePercentages() (*skillserver.EchoResponse, error)

GetWeaponUsagePercentages will return a response describing the top 3 used weapons by all players for the current week.

func InitEnv added in v1.1.0

func InitEnv(apiKey, warmindKey, baseURL string)

InitEnv provides a package level initialization point for any work that is environment specific

Types

type CharacterStats added in v1.8.1

type CharacterStats struct {
	Matches int `json:"matches"`
	Deaths  int `json:"deaths"`
	Assists int `json:"assists"`
	Losses  int `json:"losses"`
	Kills   int `json:"kills"`
}

CharacterStats will store data about specific players as returned by the Trials Report API

type CurrentMap

type CurrentMap struct {
	Status   string `json:"Status"`
	Message  string `json:"Message"`
	Response *struct {
		MapName           string                                   `json:"name"`
		Mode              string                                   `json:"mode"`
		PlayerCount       int                                      `json:"players"`
		Matches           int                                      `json:"matches"`
		Week              int                                      `json:"week"`
		Kills             int                                      `json:"kills"`
		StartDate         NineTime                                 `json:"startDate"`
		EndDate           NineTime                                 `json:"endDate"`
		WeaponKills       int                                      `json:"weaponKills"`
		Weapons           map[string][]*nineWeaponStats            `json:"weapons"`
		WeaponsByPlatform map[string]map[string][]*nineWeaponStats `json:"weaponsByPlatform"`
	} `json:"Response"`
}

CurrentMap has stats for the current week of Trials of the Nine. This data includes the map name and the mode as well as the number of players, number of kills, etc. http://api.trialsofthenine.com/week/0/

type NineClient added in v1.4.0

type NineClient struct {
	BaseURL string
}

NineClient will be the type that will execute all rquests to the Trials Report API

func (*NineClient) Execute added in v1.4.0

func (client *NineClient) Execute(endpoint string, response interface{}) error

Execute is a generic method for a NineClient to make HTTP requests to the Trials Report API. This method will fully configure the HTTP request as needed including request body.

type NineTime added in v1.4.0

type NineTime struct {
	time.Time
}

NineTime is a custom time wrapper that allows the dates returned by Trials Report to be parsed with a custom format string.

func (*NineTime) UnmarshalJSON added in v1.4.0

func (nt *NineTime) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON is responsible for unmarshaling a time.Time in the format provided by Trials Report

type PlayerCurrentWeekStats added in v1.4.0

type PlayerCurrentWeekStats struct {
	Map      string `json:"map"`
	Flawless int    `json:"flawless"`
	Week     string `json:"week"`
	Weapons  []*struct {
		SumHeadshots int    `json:"sum_headshots"`
		SumKills     int    `json:"sum_kills"`
		ItemTypeName string `json:"itemTypeDisplayName"`
	} `json:"weapons"`
	Daily []*struct {
		Day     string  `json:"day"`
		Losses  int     `json:"losses"`
		Assists int     `json:"assists"`
		Deaths  int     `json:"deaths"`
		Kills   int     `json:"kills"`
		KD      float64 `json:"kd"`
		Matches int     `json:"matches"`
	} `json:"daily"`
}

PlayerCurrentWeekStats represents the stats for a particular membership for the current week of Trials of the Nine. https://api.destinytrialsreport.com/slack/trials/week/4611686018433214701/0

type PlayerSummaryStats added in v1.4.0

type PlayerSummaryStats struct {
	Count   int `json:"count"`
	Results []*struct {
		*CharacterStats
		Flawless       int    `json:"Flawless"`
		DisplayName    string `json:"displayName"`
		MembershipType int    `json:"membershipType"`
		MembershipID   string `json:"membershipId"`
		Current        *struct {
			*CharacterStats
			Weapons []*struct{} `json:"weapons"`
		} `json:"current"`
		Characters map[string]*struct {
			*CharacterStats
		} `json:"characters"`
		Activities []*struct {
		} `json:"activities"`
		Badges []string `json:"badges"`
	}
}

PlayerSummaryStats represents the player's total stats for all Trials of the Nine weeks. https://api.trialsofthenine.com/player/4611686018433723819/

type RivalsStats added in v1.4.0

type RivalsStats struct {
	Results []*playerStats
}

RivalsStats describes the players considered rivals and returned by Trials Report https://api.trialsofthenine.com/player/4611686018433723819/rivals/

type TeammatesStats added in v1.4.0

type TeammatesStats struct {
	Results []*playerStats
}

TeammatesStats holds statistics about the teammates a user has played with the most. https://api.trialsofthenine.com/player/4611686018433723819/teammates/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL