organization

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SortByName sorts the organizations by their name
	SortByName = iota
	// SortByCreatedAt sorts the organizations by their creation date
	SortByCreatedAt = iota
	// SortByPlayerCount sorts the organizations by their player count
	SortByPlayerCount = iota
)
View Source
const (
	// OrderDescending orders the organizations descending by their sort filter
	OrderDescending = 0
	// OrderAscending orders the organizations ascending by their sort filter
	OrderAscending = 1
)

Variables

View Source
var ErrInternalServerError = errors.New("internal server error")

ErrInternalServerError is thrown if the Dual Universe servers return an internal server error

Functions

This section is empty.

Types

type Client

type Client interface {
	GetOrganizations(ctx context.Context, start, length, sort, order int) (*OrganizationsResponse, error)
	GetOrganizationMembers(ctx context.Context, id string) (*MembersResponse, error)
	GetOrganizationExtendedDescription(ctx context.Context, id string) (*ExtendedDescription, error)
}

Client provides methods to interact with the Dual Universe API

func NewClient

func NewClient(httpClient *http.Client) Client

NewClient returns a new organizations api client

type ExtendedDescription

type ExtendedDescription struct {
	ShortDescription string `json:"short_description"`
	LongDescription  string `json:"long_description"`
}

ExtendedDescription represents information shown on the organization's overview page

type ExtendedDescriptionParser

type ExtendedDescriptionParser struct {
	Document *goquery.Document
}

ExtendedDescriptionParser is used to parse the organization's overview page for information provided there

func (*ExtendedDescriptionParser) Parse

Parse parses all overview information provided on the Dual Universe page

type Member

type Member struct {
	EntityID          *MemberEntityID `json:"entityId"`
	DisplayName       string          `json:"displayName"`
	Rank              string          `json:"rank"`
	Online            bool            `json:"online"`
	JoinedAtUnix      int64           `json:"joinedAt"`
	Avatar            string          `json:"avatar"`
	JoinedAtTimestamp string          `json:"joinedAt_yymmjj"`
}

Member represents an organization member

func (*Member) ExtractAvatarURL

func (m *Member) ExtractAvatarURL() (string, error)

ExtractAvatarURL extracts the avatar URL from the logo html tag

func (*Member) ExtractJoinedAt

func (m *Member) ExtractJoinedAt() time.Time

ExtractJoinedAt extracts the joined at date

func (*Member) ExtractRank

func (m *Member) ExtractRank() (string, error)

ExtractRank extracts the rank from the rank html tag

type MemberEntityID

type MemberEntityID struct {
	PlayerID       int `json:"playerId"`
	OrganizationID int `json:"organizationId"`
}

MemberEntityID represents an organization-id-player-id-pair

type MembersResponse

type MembersResponse struct {
	Data []*Member `json:"data"`
}

MembersResponse represents the members response of an organisation

type Organization

type Organization struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	MemberCount int    `json:"member_count"`
	LegateCount int    `json:"legate_count"`
	Created     string `json:"created"`
	Button      string `json:"button"`
	Client      Client `json:"-"`
}

Organization represents a Dual Universe organization

func (*Organization) ExtractCreated

func (o *Organization) ExtractCreated() (time.Time, error)

ExtractCreated extracts the created timestamp

func (*Organization) ExtractID

func (o *Organization) ExtractID() (string, error)

ExtractID extracts the identifier of the organization the html tag

func (*Organization) ExtractLogoURL

func (o *Organization) ExtractLogoURL() (string, error)

ExtractLogoURL extracts the logo url from the html tag

func (*Organization) ExtractName

func (o *Organization) ExtractName() (string, error)

ExtractName extracts the name from the html tag

func (*Organization) GetExtendedDescription

func (o *Organization) GetExtendedDescription(ctx context.Context) (*ExtendedDescription, error)

GetExtendedDescription is an alias of Client.GetOrganizationExtendedDescription for this organization

func (*Organization) GetMembers

func (o *Organization) GetMembers(ctx context.Context) (*MembersResponse, error)

GetMembers is an alias of Client.GetOrganizationMembers for this organization

type OrganizationsResponse

type OrganizationsResponse struct {
	Draw            int             `json:"draw"`
	RecordsTotal    int             `json:"recordsTotal"`
	RecordsFiltered int             `json:"recordsFiltered"`
	Data            []*Organization `json:"data"`
}

OrganizationsResponse is the organizations response

Directories

Path Synopsis
Package mock_organization is a generated GoMock package.
Package mock_organization is a generated GoMock package.

Jump to

Keyboard shortcuts

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