pubg

package module
v0.0.0-...-6e72688 Latest Latest
Warning

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

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

README

go-pubg

PUBG API Wrapper

documentation

Documentation can be found at here. This is a hard fork of https://github.com/LtSnuggie/pubg to remove the callback style of requests.

testing

In order to run the tests locally you will need to add a conf.json file in the root folder

In the file you will need to add the following:

{ "key" : "[API key]", }

dependencies

Though this client only has one dependency the project uses the new go module system. More information on go modules can be found here.

Documentation

Overview

Package pubg is a wrapper with helper functions for accessing pubg servers. Only thing that is required is a developer API key.

Index

Constants

View Source
const (

	// XboxAsia - Xbox Asia Region
	XboxAsia = "xbox-as"
	// XboxEurope - Xbox Europe Region
	XboxEurope = "xbox-eu"
	// XboxNorthAmerica - Xbox North America Region
	XboxNorthAmerica = "xbox-na"
	// XboxOceania - Xbox Oceana Region
	XboxOceania = "xbox-oc"
	// PCAsia - PC Asia  Region
	PCAsia = "pc-as"
	// PCEurope - PC Europe Region
	PCEurope = "pc-eu"
	// PCNorthAmerica - PC North America Region
	PCNorthAmerica = "pc-na"
	// PCOceania - PC Oceania Region
	PCOceania = "pc-oc"
	// PCKoreaJapan - PC Korea/Japan Region
	PCKoreaJapan = "pc-krjp"
	// PCKorea - PC Korea Region
	PCKorea = "pc-kr"
	// PCJapan - PC Japan Region
	PCJapan = "pc-jp"
	// PCKAKAO - PC KAKAO Region
	PCKAKAO = "pc-kakao"
	// PCSouthEastAsia - PC South East Asia Region
	PCSouthEastAsia = "pc-sea"
	// PCSouthAsia - PC South Asia Region
	PCSouthAsia = "pc-sa"
	// PCTournament - PC Tournament Shard
	PCTournament = "pc-tournament"
)

Variables

This section is empty.

Functions

func GetShards

func GetShards() (shards []string)

Types

type Base

type Base struct {
	// Version   int       `json:"_V"`
	Timestamp time.Time `json:"_D"`
	Type      string    `json:"_T"`
	Common    Common    `json:"Common"`
}

Base is the base of all telemetery event types. This information will always be returned.

func (Base) GetCommon

func (b Base) GetCommon() Common

GetCommon returns the common object of the event.

func (Base) GetTimestamp

func (b Base) GetTimestamp() time.Time

GetTimestamp returns the event timestamp.

func (Base) GetType

func (b Base) GetType() string

GetType returns the event type.

func (Base) GetVersion

func (b Base) GetVersion() int

GetVersion returns the version of the event.

type CarePackageLandEvent

type CarePackageLandEvent struct {
	Base
	ItemPackage ItemPackage `json:"ItemPackage"`
}

CarePackageLandEvent contains data about a care package landing on the map

type CarePackageSpawnEvent

type CarePackageSpawnEvent struct {
	Base
	ItemPackage ItemPackage `json:"ItemPackage"`
}

CarePackageSpawnEvent contains data about a care package spawning

type Character

type Character struct {
	Name      string   `json:"Name"`
	TeamID    int      `json:"TeamId"`
	Health    float32  `json:"Health"`
	Location  Location `json:"Location"`
	Ranking   int      `json:"Ranking"`
	AccountID string   `json:"AccountId"`
}

Character data for telemetry events

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the main struct for pubg

func New

func New(key string, httpClient *http.Client) (s *Client, err error)

New returns a new defaulted Client struct.

func (*Client) GetMatch

func (c *Client) GetMatch(matchID string, shardID string) (*MatchResponse, error)

GetMatch retrieves the data for a match with a given id and shard

func (*Client) GetPlayer

func (c *Client) GetPlayer(playerID string, shardID string) (*PlayerResponse, error)

GetPlayer retrieves player data.

func (*Client) GetPlayers

func (c *Client) GetPlayers(options GetPlayersRequestOptions, shardID string) (*PlayersResponse, error)

GetPlayers retrieves data for players from the passed options.

func (*Client) GetSampleMatches

func (c *Client) GetSampleMatches(shardID string) (*SamplesResponse, error)

GetSampleMatches retrieves samples matches

func (*Client) GetSeasonStats

func (c *Client) GetSeasonStats(playerID string, shardID string, seasonID string) (*PlayerSeasonResponse, error)

GetSeasonStats retrieves data about a season

func (*Client) GetSeasons

func (c *Client) GetSeasons(shardID string) (*SeasonsResponse, error)

GetSeasons retrieves data about seasons in a shard

func (*Client) GetStatus

func (c *Client) GetStatus() (*StatusResponse, error)

GetStatus retrieves status data from the PUBG servers

func (*Client) GetTelemetry

func (c *Client) GetTelemetry(url string) (*TelemetryResponse, error)

GetTelemetry retrieves the telemetry data at a specified url

type Common

type Common struct {
	MatchID string  `json:"matchId"`
	MapName string  `json:"mapName"`
	IsGame  float32 `json:"isGame"`
}

Common data for telemetry events

type GameState

type GameState struct {
	ElapsedTime              int      `json:"ElapsedTime"`
	NumAliveTeams            int      `json:"NumAliveTeams"`
	NumJoinPlayers           int      `json:"NumJoinPlayers"`
	NumStartPlayers          int      `json:"NumStartPlayers"`
	NumAlivePlayers          int      `json:"NumAlivePlayers"`
	SafetyZonePosition       Location `json:"SafetyZonePosition"`
	SafetyZoneRadius         float32  `json:"SafetyZoneRadius"`
	PoisonGasWarningPosition Location `json:"PoisonGasWarningPosition"`
	PoisonGasWarningRadius   float32  `json:"PoisonGasWarningRadius"`
	RedZonePosition          Location `json:"RedZonePosition"`
	RedZoneRadius            float32  `json:"RedZoneRadius"`
}

GameState data for telemetry events

type GameStatePeriodicEvent

type GameStatePeriodicEvent struct {
	Base
	GameState GameState `json:"GameState"`
}

GameStatePeriodicEvent contains periodic data about the current state of the match

type GetPlayersRequestOptions

type GetPlayersRequestOptions struct {
	// PlayerNamesFilter Filters by player name. Usage: filter[playerNames]=player1,player2,…
	PlayerNamesFilter []string `url:"filter[playerNames],comma,omitempty"`
	// PlayerIDsFilter Filters by player Id. Usage:filter[playerIds]=playerId,playerId,…
	PlayerIDsFilter []string `url:"filter[playerIds],comma,omitempty"`
}

GetPlayersRequestOptions Filter options for the get players endpoint

type IncorrectContentTypeError

type IncorrectContentTypeError struct {
	// contains filtered or unexported fields
}

func NewIncorrectContentTypeError

func NewIncorrectContentTypeError(url string) *IncorrectContentTypeError

func (*IncorrectContentTypeError) Error

func (e *IncorrectContentTypeError) Error() string

type InvalidKeyError

type InvalidKeyError struct {
	// contains filtered or unexported fields
}

func NewInvalidKeyError

func NewInvalidKeyError(url string) *InvalidKeyError

func (*InvalidKeyError) Error

func (e *InvalidKeyError) Error() string

type Item

type Item struct {
	ItemID        string   `json:"ItemId"`
	StackCount    int      `json:"StackCount"`
	Category      string   `json:"Category"`
	SubCategory   string   `json:"SubCategory"`
	AttachedItems []string `json:"AttachedItems"`
}

Item data for telemetry events

type ItemAttachEvent

type ItemAttachEvent struct {
	Base
	Character  Character `json:"Character"`
	ParentItem Item      `json:"ParentItem"`
	ChildItem  Item      `json:"ChildItem"`
}

ItemAttachEvent contains data from the player attaching an item

type ItemDetachEvent

type ItemDetachEvent struct {
	Base
	Character  Character `json:"Character"`
	ParentItem Item      `json:"ParentItem"`
	ChildItem  Item      `json:"ChildItem"`
}

ItemDetachEvent contains data from the player detaching an item

type ItemDropEvent

type ItemDropEvent struct {
	Base
	Character Character `json:"Character"`
	Item      Item      `json:"Item"`
}

ItemDropEvent contains data from the player dropping an item

type ItemEquipEvent

type ItemEquipEvent struct {
	Base
	Character Character `json:"Character"`
	Item      Item      `json:"Item"`
}

ItemEquipEvent contains data from the player equipping an item

type ItemPackage

type ItemPackage struct {
	ItemPackageID string   `json:"ItemPackageId"`
	Location      Location `json:"Location"`
	Items         []Item   `json:"Items"`
}

ItemPackage data for telemetry events

type ItemPickupEvent

type ItemPickupEvent struct {
	Base
	Character Character `json:"Character"`
	Item      Item      `json:"Item"`
}

ItemPickupEvent contains data from the player picking up an item

type ItemUnequipEvent

type ItemUnequipEvent struct {
	Base
	Character Character `json:"Character"`
	Item      Item      `json:"Item"`
}

ItemUnequipEvent contains data from the player unequipping an item

type ItemUseEvent

type ItemUseEvent struct {
	Base
	Character Character `json:"Character"`
	Item      Item      `json:"Item"`
}

ItemUseEvent contains data from the player using an item

type Location

type Location struct {
	X float32 `json:"X"`
	Y float32 `json:"Y"`
	Z float32 `json:"Z"`
}

Location data for telemetry events

type MatchAsset

type MatchAsset struct {
	Attributes struct {
		URL         string    `json:"URL"`
		CreatedAt   time.Time `json:"createdAt"`
		Description string    `json:"description"`
		Name        string    `json:"name"`
	} `json:"attributes"`
	// contains filtered or unexported fields
}

MatchAsset contains all the assets returned in the MatchResponse

type MatchData

type MatchData struct {
	// contains filtered or unexported fields
}

MatchData contains all the match data returned in the PlayerResponse

type MatchDefinitionEvent

type MatchDefinitionEvent struct {
	Base
	MatchID     string `json:"MatchId"`
	PingQuality string `json:"PingQuality"`
}

MatchDefinitionEvent contains data about the current match

type MatchEndEvent

type MatchEndEvent struct {
	Base
	Characters []Character `json:"Characters"`
}

MatchEndEvent contains data about the match ending

type MatchParticipant

type MatchParticipant struct {
	Attributes struct {
		Actor   string     `json:"actor"`
		ShardID string     `json:"shardId"`
		Stats   MatchStats `json:"stats"`
	} `json:"attributes"`
	// contains filtered or unexported fields
}

MatchParticipant contains all the participants returned in the MatchResponse

type MatchResponse

type MatchResponse struct {
	Data struct {
		Type       string `json:"type"`
		ID         string `json:"id"`
		Attributes struct {
			CreatedAt    time.Time `json:"createdAt"`
			Duration     int       `json:"duration"`
			GameMode     string    `json:"gameMode"`
			MapName      string    `json:"mapName"`
			PatchVersion string    `json:"patchVersion"`
			ShardID      string    `json:"shardId"`
			Stats        string    `json:"stats"`
			Tags         string    `json:"tags"`
			TitleID      string    `json:"titleId"`
			Description  string    `json:"description"`
			Name         string    `json:"name"`
			URL          string    `json:"URL"`
		} `json:"attributes"`
		Relationships struct {
			Assets struct {
				Data []typeIDPair `json:"data"`
			} `json:"assets"`
			Rosters struct {
				Data []typeIDPair `json:"data"`
			} `json:"rosters"`
		} `json:"relationships"`
		Links struct {
			Schema string `json:"schema"`
			Self   string `json:"self"`
		} `json:"links"`
	} `json:"data"`
	Included     []json.RawMessage `json:"included"`
	Participants []MatchParticipant
	Rosters      []MatchRoster
	Assets       []MatchAsset
	Links        struct {
		Self string `json:"self"`
	} `json:"links"`
	Meta struct{} `json:"meta"`
}

MatchResponse is the response payload for the match end point

func (*MatchResponse) GetMatchID

func (mr *MatchResponse) GetMatchID() (id string)

func (*MatchResponse) GetStatsByName

func (mr *MatchResponse) GetStatsByName() (s map[string]*MatchStats)

GetStatsByName is a helper function to retrieve player MatchStats from a MatchResponse. A map is more performant than a slice in larger data sets so it is recommended to use this map instead of iterating through the MatchResponse data looking for players

func (*MatchResponse) GetStatsByWinRank

func (mr *MatchResponse) GetStatsByWinRank() (s map[int][]*MatchStats)

GetStatsByWinRank is a helper function to retrieve player MatchStats

by final rank from a MatchResponse. A map is more performant than a

slice in larger data sets so it is recommended to use this map instead of iterating through the MatchResponse data looking for player ranks

type MatchRoster

type MatchRoster struct {
	Attributes struct {
		ShardIDn string `json:"shardId"`
		Stats    struct {
			Rank   int `json:"rank"`
			TeamID int `json:"teamId"`
		} `json:"stats"`
		Won bool `json:"won"`
	} `json:"attributes"`
	Relationships struct {
		Participants struct {
			Data []typeIDPair
		} `json:"participants"`
		Team struct {
			Data string `json:"data"`
		} `json:"team"`
	} `json:"relationships"`
	// contains filtered or unexported fields
}

MatchRoster contains all the rosters returned in the MatchResponse

type MatchStartEvent

type MatchStartEvent struct {
	Base
	Characters []Character `json:"Characters"`
}

MatchStartEvent contains data about the start of the match

type MatchStats

type MatchStats struct {
	DBNOs           int     `json:"DBNOs"`
	Assists         int     `json:"assists"`
	Boosts          int     `json:"boosts"`
	DamageDealt     float32 `json:"damageDealt"`
	DeathType       string  `json:"deathType"`
	HeadshotKills   int     `json:"headshotKills"`
	Heals           int     `json:"heals"`
	KillPlace       int     `json:"killPlace"`
	KillPoints      int     `json:"killPoints"`
	KillPointsDelta int     `json:"killPointsDelta"`
	KillStreaks     int     `json:"killStreaks"`
	Kills           int     `json:"kills"`
	LastKillPoints  int     `json:"lastKillPoints"`
	LastWinPoints   int     `json:"lastWinPoints"`
	LongestKill     float32 `json:"longestKill"`
	MostDamage      int     `json:"mostDamage"`
	Name            string  `json:"name"`
	PlayerID        string  `json:"playerId"`
	Revives         int     `json:"revives"`
	RideDistance    float32 `json:"rideDistance"`
	RoadKills       int     `json:"roadKills"`
	TeamKills       int     `json:"teamKills"`
	TimeSurvived    float32 `json:"timeSurvived"`
	VehicleDestroys int     `json:"vehicleDestroys"`
	WalkDistance    float32 `json:"walkDistance"`
	WeaponsAcquired int     `json:"weaponsAcquired"`
	WinPlace        int     `json:"winPlace"`
	WinPoints       int     `json:"winPoints"`
	WinPointsDelta  int     `json:"winPointsDelta"`
}

MatchStats are all the stats returned in the MatchResponse

type Matches

type Matches struct {
	Data []MatchData `json:"data"`
}

Matches contains a slice of all the matches returned in the PlayerResponse

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

func NewNotFoundError

func NewNotFoundError(url string) *NotFoundError

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type PlayerAttackEvent

type PlayerAttackEvent struct {
	Base
	AttackID   int       `json:"AttackId"`
	Attacker   Character `json:"Attacker"`
	AttackType string    `json:"AttackType"`
	Weapon     Item      `json:"Weapon"`
	Vehicle    Vehicle   `json:"Vehicle"`
}

PlayerAttackEvent contains data about the player attacking another player

type PlayerAttributes

type PlayerAttributes struct {
	// CreatedAt    string          `json:"createdAt"`
	Name         string          `json:"name"`
	PatchVersion string          `json:"patchVersion"`
	ShardID      string          `json:"shardId"`
	Stats        json.RawMessage `json:"stats"`
	TitleID      string          `json:"titleId"`
}

PlayerAttributes contains all of the player attributes returned in the PlayerResponse

type PlayerCreateEvent

type PlayerCreateEvent struct {
	Base
	Character Character `json:"Character"`
}

PlayerCreateEvent contains data from the player being created on the server

type PlayerKillEvent

type PlayerKillEvent struct {
	Base
	AttackID           int       `json:"AttackId"`
	Killer             Character `json:"Killer"`
	Victim             Character `json:"Victim"`
	DamageTypeCategory string    `json:"DamageTypeCategory"`
	DamageCauserName   string    `json:"DamageCauserName"`
	Distance           float32   `json:"Distance"`
}

PlayerKillEvent contains data from the player killing another player

type PlayerLoginEvent

type PlayerLoginEvent struct {
	Base
	// Result bool `json:"Result"`
	// ErrorMessage string `json:"ErrorMessage"`
	AccountID string `json:"AccountId"`
}

PlayerLoginEvent contains data from the player loging in

type PlayerLogoutEvent

type PlayerLogoutEvent struct {
	Base
	AccountID string `json:"AccountId"`
}

PlayerLogoutEvent contains data about the player logging out

type PlayerPositionEvent

type PlayerPositionEvent struct {
	Base
	Character       Character `json:"Character"`
	ElapsedTime     float32   `json:"ElapsedTime"`
	NumAlivePlayers int       `json:"NumAlivePlayers"`
}

PlayerPositionEvent contains data about the current position of the player

type PlayerResponse

type PlayerResponse struct {
	Data PlayerResponseData `json:"data"`
}

PlayerResponse is the response payload for the player end point

type PlayerResponseData

type PlayerResponseData struct {
	Attributes    PlayerAttributes `json:"attributes"`
	Relationships Relationships    `json:"relationships"`
	// contains filtered or unexported fields
}

PlayerResponseData contains all of the data returned in the PlayerResponse

func (*PlayerResponseData) GetMatchIDs

func (prd *PlayerResponseData) GetMatchIDs() (ids []string)

GetMatchIDs is a helper function to exctract a slice of MatchId's from PlayerResponseData. This is useful if the caller is only interested in the MatchId's for a player. This helper function becomes very handy when trying to work with Telemetry data

func (*PlayerResponseData) GetMatches

func (prd *PlayerResponseData) GetMatches() (m []MatchData)

GetMatches is a helper function to extract a slice of MatchData from PlayerResponseData. This is useful if the caller is only interested in MatchData

type PlayerSeasonAttributes

type PlayerSeasonAttributes struct {
	GameModeStats struct {
		DuoTPP   PlayerSeasonGameModeStats `json:"duo"`
		DuoFPP   PlayerSeasonGameModeStats `json:"duo-fpp"`
		SoloTPP  PlayerSeasonGameModeStats `json:"solo"`
		SoloFPP  PlayerSeasonGameModeStats `json:"solo-fpp"`
		SquadTPP PlayerSeasonGameModeStats `json:"squad"`
		SquadFPP PlayerSeasonGameModeStats `json:"squad-fpp"`
	} `json:"gameModeStats"`
}

type PlayerSeasonData

type PlayerSeasonData struct {
	Type          string                    `json:"type"`
	Attributes    PlayerSeasonAttributes    `json:"attributes"`
	Relationships PlayerSeasonRelationships `json:"relationships"`
}

type PlayerSeasonGameModeStats

type PlayerSeasonGameModeStats struct {
	Assists             int     `json:"assists"`
	Boosts              int     `json:"boosts"`
	DBNOs               int     `json:"dBNOs"`
	DailyKills          int     `json:"dailyKills"`
	DamageDealt         float32 `json:"damageDealt"`
	Days                int     `json:"days"`
	HeadshotKills       int     `json:"headshotKills"`
	Heals               int     `json:"heals"`
	KillPoints          float32 `json:"killPoints"`
	Kills               int     `json:"kills"`
	LongestKill         float32 `json:"longestKill"`
	LongestTimeSurvived float32 `json:"longestTimeSurvived"`
	Losses              int     `json:"losses"`
	MaxKillStreaks      int     `json:"maxKillStreaks"`
	MostSurvivalTime    float32 `json:"mostSurvivalTime"`
	Revives             int     `json:"revives"`
	RideDistance        float32 `json:"rideDistance"`
	RoadKills           int     `json:"roadKills"`
	RoundMostKills      int     `json:"roundMostKills"`
	RoundsPlayed        int     `json:"roundsPlayed"`
	Suicides            int     `json:"suicides"`
	TeamKills           int     `json:"teamKills"`
	TimeSurvived        float32 `json:"timeSurvived"`
	Top10s              int     `json:"top10s"`
	VehicleDestroys     int     `json:"vehicleDestroys"`
	WalkDistance        float32 `json:"walkDistance"`
	WeaponsAcquired     int     `json:"weaponsAcquired"`
	WeeklyKills         int     `json:"weeklyKills"`
	WinPoints           float32 `json:"winPoints"`
	Wins                int     `json:"wins"`
}

type PlayerSeasonRelationships

type PlayerSeasonRelationships struct {
	MatchesSquadFPP struct {
		Data []typeIDPair `json:"data"`
	} `json:"matchesSquadFPP"`
	MatchesSquadTPP struct {
		Data []typeIDPair `json:"data"`
	} `json:"matchesSquadTPP"`
	MatchesSoloFPP struct {
		Data []typeIDPair `json:"data"`
	} `json:"matchesSoloFPP"`
	MatchesSoloTPP struct {
		Data []typeIDPair `json:"data"`
	} `json:"matchesSoloTPP"`
	MatchesDuoFPP struct {
		Data []typeIDPair `json:"data"`
	} `json:"matchesDuoFPP"`
	MatchesDuoTPP struct {
		Data []typeIDPair `json:"data"`
	} `json:"matchesDuoTPP"`
	Season struct {
		Data typeIDPair `json:"data"`
	} `json:"season"`
	Player struct {
		Data typeIDPair `json:"data"`
	} `json:"player"`
}

type PlayerSeasonResponse

type PlayerSeasonResponse struct {
	Data  PlayerSeasonData `json:"data"`
	Links struct {
		Self string `json:"self"`
	} `json:"links"`
	Meta struct{} `json:"meta"`
}

type PlayerTakeDamageEvent

type PlayerTakeDamageEvent struct {
	Base
	AttackID           int       `json:"AttackId"`
	Attacker           Character `json:"Attacker"`
	Victim             Character `json:"Victim"`
	DamageTypeCategory string    `json:"DamageTypeCategory"`
	DamageReason       string    `json:"DamageReason"`
	Damage             float32   `json:"Damage"`
	DamageCauserName   string    `json:"DamageCauserName"`
}

PlayerTakeDamageEvent contains data from the player taking damage

type PlayersResponse

type PlayersResponse struct {
	Data  []PlayerResponseData
	Links struct {
		Self string `json:"self"`
	} `json:"links"`
}

type Relationships

type Relationships struct {
	Matches Matches `json:"matches"`
}

Relationships contains all of the relationships returned in the PlayerResponse

type SamplesAttributes

type SamplesAttributes struct {
	CreatedAt time.Time `json:"createdAt"`
	ShardID   string    `json:"shardId"`
	TitleID   string    `json:"titleId"`
}

type SamplesResponse

type SamplesResponse struct {
	Data SamplesResponseData `json:"data"`
}

SamplesResponse is the response payload for the samples endpoint

func (*SamplesResponse) GetMatches

func (sr *SamplesResponse) GetMatches() (m []MatchData)

GetMatches is a helper function to extract a slice of MatchData from SamplesResponse. This is useful if the caller is only interested in MatchData

type SamplesResponseData

type SamplesResponseData struct {
	Attributes    SamplesAttributes `json:"attributes"`
	Relationships Relationships     `json:"relationships"`
	// contains filtered or unexported fields
}

type SeasonsAttributes

type SeasonsAttributes struct {
	IsCurrentSeason bool `json:"isCurrentSeason"`
	IsOffseason     bool `json:"isOffseason"`
}

type SeasonsResponse

type SeasonsResponse struct {
	Data  []SeasonsResponseData `json:"data"`
	Links struct {
		Self string `json:"self"`
	} `json:"links"`
	Meta struct{} `json:"meta"`
}

type SeasonsResponseData

type SeasonsResponseData struct {
	Type       string            `json:"type"`
	ID         string            `json:"id"`
	Attributes SeasonsAttributes `json:"attributes"`
}

type StatusAttributes

type StatusAttributes struct {
	Released string `json:"releasedAt"`
	Version  string `json:"version"`
}

StatusAttributes contains all of the attributes returned in the StatusResponse

type StatusData

type StatusData struct {
	Attributes StatusAttributes `json:"attributes"`
	// contains filtered or unexported fields
}

StatusData contains all of the data returned in the StatusResponse

type StatusResponse

type StatusResponse struct {
	Data StatusData `json:"data"`
}

StatusResponse is the response payload for the status end point

type TelemetryEvent

type TelemetryEvent interface {
	GetType() string         // returns the event type.
	GetTimestamp() time.Time // returns the Timestamp of the event.
	GetVersion() int         // returns the version of the event.
	GetCommon() Common       // returns the Common object of the event.
}

TelemetryEvent is an interface for TelemetryEvent's.

type TelemetryResponse

type TelemetryResponse struct {
	Events                  []TelemetryEvent          //All telemetry events in chronoligic order
	PlayerLoginEvents       []*PlayerLoginEvent       //All PlayerLoginEvent's in chronoligic order
	PlayerCreateEvents      []*PlayerCreateEvent      //All PlayerCreateEvent's in chronoligic order
	PlayerPositionEvents    []*PlayerPositionEvent    //All PlayerPositionEvent's in chronoligic order
	PlayerAttackEvents      []*PlayerAttackEvent      //All PlayerAttackEvent's in chronoligic order
	ItemPickupEvents        []*ItemPickupEvent        //All ItemPickupEvent's in chronoligic order
	ItemEquipEvent          []*ItemEquipEvent         //All ItemEquipEvent's in chronoligic order
	ItemUnequipEvents       []*ItemUnequipEvent       //All ItemUnequipEvent's in chronoligic order
	VehicleRideEvents       []*VehicleRideEvent       //All VehicleRideEvent's in chronoligic order
	MatchDefinitionEvents   []*MatchDefinitionEvent   //All MatchDefinitionEvent's in chronoligic order
	MatchStartEvents        []*MatchStartEvent        //All MatchStartEvent's in chronoligic order
	GameStatePeriodicEvents []*GameStatePeriodicEvent //All GameStatePeriodicEvent's in chronoligic order
	VehicleLeaveEvents      []*VehicleLeaveEvent      //All VehicleLeaveEvent's in chronoligic order
	PlayerTakeDamageEvents  []*PlayerTakeDamageEvent  //All PlayerTakeDamageEvent's in chronoligic order
	PlayerLogoutEvents      []*PlayerLogoutEvent      //All PlayerLogoutEvent's in chronoligic order
	ItemAttachEvents        []*ItemAttachEvent        //All ItemAttachEvent's in chronoligic order
	ItemDropEvents          []*ItemDropEvent          //All ItemDropEvent's in chronoligic order
	PlayerKillEvents        []*PlayerKillEvent        //All PlayerKillEvent's in chronoligic order
	ItemDetachEvents        []*ItemDetachEvent        //All ItemDetachEvent's in chronoligic order
	ItemUseEvents           []*ItemUseEvent           //All ItemUseEvent's in chronoligic order
	CarePackageSpawnEvents  []*CarePackageSpawnEvent  //All CarePackageSpawnEvent's in chronoligic order
	VehicleDestroyEvents    []*VehicleDestroyEvent    //All VehicleDestroyEvent's in chronoligic order
	CarePackageLandEvents   []*CarePackageLandEvent   //All CarePackageLandEvent's in chronoligic order
	MatchEndEvents          []*MatchEndEvent          //All MatchEndEvent's in chronoligic order
}

TelemetryResponse is the response payload for the telemetry end point

func ParseTelemetry

func ParseTelemetry(b []byte) (tr *TelemetryResponse, err error)

ParseTelemetry reads the telemetry event type from the json and passes it to the unmarshaller

func ReadTelemetryFromFile

func ReadTelemetryFromFile(path string) (tr *TelemetryResponse, err error)

ReadTelemetryFromFile parses json telemetry data from a given file and returns a TelemetryResponse struct. It is more performant to cache telemetry data for future use.

func (*TelemetryResponse) ToFile

func (tr *TelemetryResponse) ToFile(path string) (err error)

ToFile will save a TelemetryResponse to the file at a specified location. These data are always static and so it makes sense to cache/save this somewhere locally to prevent from having to request the large file multiple times

type TooManyRequestsError

type TooManyRequestsError struct {
	// contains filtered or unexported fields
}

func NewTooManyRequestsError

func NewTooManyRequestsError(url string) *TooManyRequestsError

func (*TooManyRequestsError) Error

func (e *TooManyRequestsError) Error() string

type UnhandledStatusCodeError

type UnhandledStatusCodeError struct {
	// contains filtered or unexported fields
}

func NewUnhandledStatusCodeError

func NewUnhandledStatusCodeError(url, status string) *UnhandledStatusCodeError

func (*UnhandledStatusCodeError) Error

func (e *UnhandledStatusCodeError) Error() string

type Vehicle

type Vehicle struct {
	VehicleType   string  `json:"VehicleType"`
	VehicleID     string  `json:"VehicleId"`
	HealthPercent float32 `json:"HealthPercent"`
	FuelPercent   float32 `json:"FeulPercent"`
}

Vehicle data for telemetry events

type VehicleDestroyEvent

type VehicleDestroyEvent struct {
	Base
	AttackID           int       `json:"AttackId"`
	Attacker           Character `json:"Attacker"`
	Vehicle            Vehicle   `json:"Vehicle"`
	DamageTypeCategory string    `json:"DamageTypeCategory"`
	DamageCauserName   string    `json:"DamageCauserName"`
	Distance           float32   `json:"Distance"`
}

VehicleDestroyEvent contains data from a vehicle being destroyed

type VehicleLeaveEvent

type VehicleLeaveEvent struct {
	Base
	Character Character `json:"Character"`
	Vehicle   Vehicle   `json:"Vehicle"`
}

VehicleLeaveEvent contains data from the player leaving a vehicle

type VehicleRideEvent

type VehicleRideEvent struct {
	Base
	Character Character `json:"Character"`
	Vehicle   Vehicle   `json:"Vehicle"`
}

VehicleRideEvent contains data from the player riding in a vehicle

Jump to

Keyboard shortcuts

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