Documentation
¶
Index ¶
- type ApplicationApprovalPayload
- type ApplicationPayload
- type Clan
- type ClanApplyResult
- type ClanMembers
- type ClanMembership
- type ClanMembershipPlayer
- type ClanMemberships
- type ClanNameAndPublicID
- type ClanPayload
- type ClanPlayerInfo
- type ClanSummary
- type ClansRelationships
- type ClansSummary
- type DeleteMembershipPayload
- type InvitationApprovalPayload
- type InvitationPayload
- type Khan
- func (k *Khan) ApplyForMembership(ctx context.Context, payload *ApplicationPayload) (*ClanApplyResult, error)
- func (k *Khan) ApproveDenyMembershipApplication(ctx context.Context, payload *ApplicationApprovalPayload) (*Result, error)
- func (k *Khan) ApproveDenyMembershipInvitation(ctx context.Context, payload *InvitationApprovalPayload) (*Result, error)
- func (k *Khan) CreateClan(ctx context.Context, clan *ClanPayload) (string, error)
- func (k *Khan) CreatePlayer(ctx context.Context, publicID, name string, metadata interface{}) (string, error)
- func (k *Khan) DeleteMembership(ctx context.Context, payload *DeleteMembershipPayload) (*Result, error)
- func (k *Khan) InviteForMembership(ctx context.Context, payload *InvitationPayload) (*Result, error)
- func (k *Khan) LeaveClan(ctx context.Context, clanID string) (*LeaveClanResult, error)
- func (k *Khan) PromoteDemote(ctx context.Context, payload *PromoteDemotePayload) (*Result, error)
- func (k *Khan) RetrieveClan(ctx context.Context, clanID string) (*Clan, error)
- func (k *Khan) RetrieveClanMembers(ctx context.Context, clanID string) (*ClanMembers, error)
- func (k *Khan) RetrieveClanSummary(ctx context.Context, clanID string) (*ClanSummary, error)
- func (k *Khan) RetrieveClansSummary(ctx context.Context, clanIDs []string) ([]*ClanSummary, error)
- func (k *Khan) RetrievePlayer(ctx context.Context, publicID string) (*Player, error)
- func (k *Khan) SearchClans(ctx context.Context, clanName string) (*SearchClansResult, error)
- func (k *Khan) TransferOwnership(ctx context.Context, playerPublicID, clanID string) (*TransferOwnershipResult, error)
- func (k *Khan) UpdateClan(ctx context.Context, clan *ClanPayload) (*Result, error)
- func (k *Khan) UpdatePlayer(ctx context.Context, publicID, name string, metadata interface{}) (*Result, error)
- type KhanInterface
- type KhanParams
- type LeaveClanResult
- type Player
- type PlayerMembership
- type PromoteDemotePayload
- type RequestError
- type Result
- type SearchClansResult
- type ShortPlayerInfo
- type TransferOwnershipResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicationApprovalPayload ¶
type ApplicationApprovalPayload struct {
ClanID string `json:"-"`
Action string `json:"-"`
PlayerPublicID string `json:"playerPublicID"`
RequestorPublicID string `json:"requestorPublicID"`
}
ApplicationApprovalPayload is the argument on approve or deny membership application
type ApplicationPayload ¶
type ApplicationPayload struct {
ClanID string `json:"-"`
Message string `json:"message"`
Level string `json:"level"`
PlayerPublicID string `json:"playerPublicID"`
}
ApplicationPayload is the argument on apply for membership
type Clan ¶
type Clan struct {
PublicID string `json:"publicID"`
Name string `json:"name"`
Metadata interface{} `json:"metadata"`
AllowApplication bool `json:"allowApplication"`
AutoJoin bool `json:"autoJoin"`
MembershipCount int `json:"membershipCount"`
Owner *ShortPlayerInfo `json:"owner"`
Roster []*ClanMembership `json:"roster"`
Memberships *ClanMemberships `json:"memberships"`
}
Clan is the structure returned by the retrieve clan route
type ClanApplyResult ¶
ClanApplyResult is the result on apply for membership
type ClanMembers ¶
type ClanMembers struct {
Members []string `json:"members"`
}
ClanMembers is used to unmarshal the response payload for clan members route
type ClanMembership ¶
type ClanMembership struct {
Level string `json:"level"`
Message string `json:"message"`
Player *ClanMembershipPlayer `json:"player"`
}
ClanMembership represents the membership structure inside a clan response
type ClanMembershipPlayer ¶
type ClanMembershipPlayer struct {
Approver *ShortPlayerInfo `json:"approver"`
Metadata interface{} `json:"metadata"`
Name string `json:"name"`
PublicID string `json:"publicID"`
}
ClanMembershipPlayer represents the player structure inside the clan membership
type ClanMemberships ¶
type ClanMemberships struct {
PendingApplications []*ClanMembership `json:"pendingApplications"`
PendingInvites []*ClanMembership `json:"pendingInvites"`
Denied []*ClanMembership `json:"denied"`
Banned []*ClanMembership `json:"banned"`
}
ClanMemberships is the memberships structure inside a clan response
type ClanNameAndPublicID ¶
ClanNameAndPublicID has name and publicID
type ClanPayload ¶
type ClanPayload struct {
PublicID string `json:"publicID,omitempty"`
Name string `json:"name"`
OwnerPublicID string `json:"ownerPublicID"`
Metadata interface{} `json:"metadata"`
AllowApplication bool `json:"allowApplication"`
AutoJoin bool `json:"autoJoin"`
}
ClanPayload maps the payload for the Create Clan route and Update Clan route
type ClanPlayerInfo ¶
type ClanPlayerInfo struct {
Metadata interface{} `json:"metadata"`
Name string `json:"name"`
PublicID string `json:"publicID"`
MembershipCount int `json:"membershipCount"`
}
ClanPlayerInfo defines the clan info returned on the membership
type ClanSummary ¶
type ClanSummary struct {
PublicID string `json:"publicID"`
Name string `json:"name"`
Metadata interface{} `json:"metadata"`
AllowApplication bool `json:"allowApplication"`
AutoJoin bool `json:"autoJoin"`
MembershipCount int `json:"membershipCount"`
}
ClanSummary defines the clan summary
type ClansRelationships ¶
type ClansRelationships struct {
Owned []*ClanNameAndPublicID `json:"owned"`
Approved []*ClanNameAndPublicID `json:"approved"`
Banned []*ClanNameAndPublicID `json:"banned"`
Denied []*ClanNameAndPublicID `json:"denied"`
PendingApplications []*ClanNameAndPublicID `json:"pendingApplications"`
PendingInvites []*ClanNameAndPublicID `json:"pendingInvites"`
}
ClansRelationships defines the struct returned inside player
type ClansSummary ¶
type ClansSummary struct {
Clans []*ClanSummary `json:"clans"`
}
ClansSummary defines the clans summary
type DeleteMembershipPayload ¶
type DeleteMembershipPayload struct {
ClanID string `json:"-"`
PlayerPublicID string `json:"playerPublicID"`
RequestorPublicID string `json:"requestorPublicID"`
}
DeleteMembershipPayload is the argument on delete membership method
type InvitationApprovalPayload ¶
type InvitationApprovalPayload struct {
ClanID string `json:"-"`
Action string `json:"-"`
PlayerPublicID string `json:"playerPublicID"`
}
InvitationApprovalPayload is the argument on approve or deny membership invitation
type InvitationPayload ¶
type InvitationPayload struct {
ClanID string `json:"-"`
Level string `json:"level"`
PlayerPublicID string `json:"playerPublicID"`
RequestorPublicID string `json:"requestorPublicID"`
}
InvitationPayload is the argument on invite for membership
type Khan ¶
Khan is a struct that represents a khan API application
func (*Khan) ApplyForMembership ¶
func (k *Khan) ApplyForMembership( ctx context.Context, payload *ApplicationPayload, ) (*ClanApplyResult, error)
ApplyForMembership calls apply for membership route on khan
func (*Khan) ApproveDenyMembershipApplication ¶
func (k *Khan) ApproveDenyMembershipApplication( ctx context.Context, payload *ApplicationApprovalPayload, ) (*Result, error)
ApproveDenyMembershipApplication approves or deny player application on clan
func (*Khan) ApproveDenyMembershipInvitation ¶
func (k *Khan) ApproveDenyMembershipInvitation( ctx context.Context, payload *InvitationApprovalPayload, ) (*Result, error)
ApproveDenyMembershipInvitation approves or deny player invitation on clan
func (*Khan) CreateClan ¶
CreateClan calls the create clan route from khan
func (*Khan) CreatePlayer ¶
func (k *Khan) CreatePlayer(ctx context.Context, publicID, name string, metadata interface{}) (string, error)
CreatePlayer calls Khan to create a new player
func (*Khan) DeleteMembership ¶
func (k *Khan) DeleteMembership( ctx context.Context, payload *DeleteMembershipPayload, ) (*Result, error)
DeleteMembership deletes membership on clan
func (*Khan) InviteForMembership ¶
func (k *Khan) InviteForMembership( ctx context.Context, payload *InvitationPayload, ) (*Result, error)
InviteForMembership invites a clan member to join clan
func (*Khan) PromoteDemote ¶
func (k *Khan) PromoteDemote( ctx context.Context, payload *PromoteDemotePayload, ) (*Result, error)
PromoteDemote promotes or demotes player on clan
func (*Khan) RetrieveClan ¶
RetrieveClan calls the route to retrieve clan from khan
func (*Khan) RetrieveClanMembers ¶
RetrieveClanMembers calls the route to retrieve clan members from khan
func (*Khan) RetrieveClanSummary ¶
RetrieveClanSummary calls the route to retrieve clan summary from khan
func (*Khan) RetrieveClansSummary ¶
RetrieveClansSummary calls the route to retrieve clans summary from khan
func (*Khan) RetrievePlayer ¶
RetrievePlayer calls the retrieve player route from khan
func (*Khan) SearchClans ¶
SearchClans returns clan summaries for all clans that contain the string "clanName".
func (*Khan) TransferOwnership ¶
func (k *Khan) TransferOwnership( ctx context.Context, playerPublicID, clanID string, ) (*TransferOwnershipResult, error)
TransferOwnership transfers clan ownership to another member
func (*Khan) UpdateClan ¶
UpdateClan calls the update clan route from khan
type KhanInterface ¶
type KhanInterface interface {
ApplyForMembership(context.Context, *ApplicationPayload) (*ClanApplyResult, error)
ApproveDenyMembershipApplication(context.Context, *ApplicationApprovalPayload) (*Result, error)
ApproveDenyMembershipInvitation(context.Context, *InvitationApprovalPayload) (*Result, error)
CreateClan(context.Context, *ClanPayload) (string, error)
CreatePlayer(context.Context, string, string, interface{}) (string, error)
DeleteMembership(context.Context, *DeleteMembershipPayload) (*Result, error)
InviteForMembership(context.Context, *InvitationPayload) (*Result, error)
LeaveClan(context.Context, string) (*LeaveClanResult, error)
PromoteDemote(context.Context, *PromoteDemotePayload) (*Result, error)
RetrieveClan(context.Context, string) (*Clan, error)
RetrieveClansSummary(context.Context, []string) ([]*ClanSummary, error)
RetrieveClanMembers(context.Context, string) (*ClanMembers, error)
RetrieveClanSummary(context.Context, string) (*ClanSummary, error)
RetrievePlayer(context.Context, string) (*Player, error)
TransferOwnership(context.Context, string, string) (*TransferOwnershipResult, error)
UpdateClan(context.Context, *ClanPayload) (*Result, error)
UpdatePlayer(context.Context, string, string, interface{}) (*Result, error)
SearchClans(context.Context, string) (*SearchClansResult, error)
}
KhanInterface defines the interface for the khan client
func NewKhan ¶
func NewKhan(config *viper.Viper) KhanInterface
NewKhan returns a new khan API application
func NewKhanWithParams ¶
func NewKhanWithParams(params *KhanParams) KhanInterface
NewKhanWithParams returns a new khan API application initialized with passed params
type KhanParams ¶
type KhanParams struct {
Timeout time.Duration
MaxIdleConns int
MaxIdleConnsPerHost int
URL string
User string
Pass string
GameID string
}
KhanParams represents the params to create a Khan client
func NewKhanParams ¶
func NewKhanParams() *KhanParams
NewKhanParams returns a new KhanParams instance with default values
type LeaveClanResult ¶
type LeaveClanResult struct {
Success bool
IsDeleted bool
PreviousOwner *ClanPlayerInfo
NewOwner *ClanPlayerInfo
}
LeaveClanResult is the result of leave clan method
type Player ¶
type Player struct {
PublicID string `json:"publicID"`
Name string `json:"name"`
Metadata interface{} `json:"metadata"`
Clans *ClansRelationships `json:"clans,omitempty"`
Memberships []*PlayerMembership `json:"memberships,omitempty"`
}
Player defines the struct returned by the khan API for retrieve player
type PlayerMembership ¶
type PlayerMembership struct {
Approved bool `json:"approved"`
Banned bool `json:"banned"`
Denied bool `json:"denied"`
Clan *ClanPlayerInfo `json:"clan"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
DeletedAt int64 `json:"deletedAt"`
ApprovedAt int64 `json:"approvedAt"`
DeniedAt int64 `json:"deniedAt"`
Level string `json:"level"`
Message string `json:"message"`
Requestor *ShortPlayerInfo `json:"requestor"`
Approver *ShortPlayerInfo `json:"approver"`
Denier *ShortPlayerInfo `json:"denier"`
}
PlayerMembership defines the membership returned by retrieve player
type PromoteDemotePayload ¶
type PromoteDemotePayload struct {
ClanID string `json:"-"`
Action string `json:"-"`
PlayerPublicID string `json:"playerPublicID"`
RequestorPublicID string `json:"requestorPublicID"`
}
PromoteDemotePayload is the argument on promote or demote method
type RequestError ¶
type RequestError struct {
// contains filtered or unexported fields
}
RequestError contains code and body of a request that failed
func (*RequestError) Error ¶
func (r *RequestError) Error() string
func (*RequestError) Status ¶
func (r *RequestError) Status() int
Status returns the status code of the error
type SearchClansResult ¶
type SearchClansResult struct {
Success bool
Clans []*ClanSummary
}
type ShortPlayerInfo ¶
type ShortPlayerInfo struct {
PublicID string `json:"publicID"`
Name string `json:"name"`
Metadata interface{} `json:"metadata"`
}
ShortPlayerInfo defines the data returned for these elements on each membership
type TransferOwnershipResult ¶
type TransferOwnershipResult struct {
Success bool
PreviousOwner *ClanPlayerInfo
NewOwner *ClanPlayerInfo
}
TransferOwnershipResult is the result of transfer ownership method