community

package module
v0.0.0-...-65a0d88 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: GPL-3.0 Imports: 15 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 AuthenticatedClient

type AuthenticatedClient interface {
	Client
	User(ctx context.Context, id uint) (*User, error)

	Close() error
	Wait()
}

AuthenticatedClient extends the Client interface with methods to fetch information that requires authentication

func NewAuthenticatedClient

func NewAuthenticatedClient(httpClient *http.Client, initSessionID string) AuthenticatedClient

NewAuthenticatedClient creates a new instance of an authenticated client.

type Client

type Client interface {
	// Organizations returns all Dual Universe organizations
	Organizations(ctx context.Context, start, length, sort, order int) (*OrganizationsResp, error)

	// OrganizationMembers returns all members of a given organization
	OrganizationMembers(ctx context.Context, id string, start, length int) (*OrganizationMembersResp, error)

	// OrganizationExtraDescription returns the descriptions
	// provided on the organizations page
	OrganizationExtraDescription(ctx context.Context, id string) (*OrganizationDescription, error)
}

Client provides methods to fetch information from the Dual Universe Community page without authentication

func NewClient

func NewClient(httpClient *http.Client) Client

NewClient creates a new instance of an unauthenticated client.

type Organization

type Organization struct {
	ID           int               `json:"id"`
	OwnerID      int               `json:"ownerId"`
	Active       bool              `json:"active"`
	Posts        []interface{}     `json:"posts"`
	Description  string            `json:"description"`
	Keywords     string            `json:"keywords"`
	Language     string            `json:"language"`
	Manifest     string            `json:"manifest"`
	Name         string            `json:"name"`
	IsRecruiting bool              `json:"recruiting"`
	Tag          string            `json:"tag"`
	CreatedAt    string            `json:"createdAt"`
	MemberCount  int               `json:"memberCount"`
	// contains filtered or unexported fields
}

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) ExtractKeywords

func (o *Organization) ExtractKeywords() []string

ExtractKeywords extracts the keywords of the organization

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

type OrganizationDescription

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

OrganizationDescription represents information shown on the organization's overview page

type OrganizationDescriptionResp

type OrganizationDescriptionResp struct{}
type OrganizationLogo struct {
	Content string `json:"content"`
	IsSVG   bool   `json:"svg"`
}

type OrganizationMember

type OrganizationMember struct {
	MemberID    int    `json:"memberId"`
	UserID      int    `json:"userId"`
	PlayerID    int    `json:"playerId"`
	DisplayName string `json:"displayName"`
	Role        string `json:"role"`
	JoinedAt    string `json:"joinedAt"`
	Avatar      string `json:"avatar"`
}

func (*OrganizationMember) ExtractAvatarURL

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

ExtractAvatarURL extracts the avatar URL from the logo html tag

func (*OrganizationMember) ExtractDisplayName

func (m *OrganizationMember) ExtractDisplayName() (string, error)

ExtractDisplayName extracts the display name of a org member

func (*OrganizationMember) ExtractJoinedAt

func (m *OrganizationMember) ExtractJoinedAt() (time.Time, error)

ExtractJoinedAt extracts the joined at date

func (*OrganizationMember) ExtractRank

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

ExtractRank extracts the rank from the rank html tag

type OrganizationMembersResp

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

type OrganizationParser

type OrganizationParser struct {
	Document *goquery.Document
}

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

func (*OrganizationParser) Parse

Parse parses all overview information provided on the Dual Universe page

type OrganizationsResp

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

type User

type User struct {
	ID           uint      `json:"id"`
	Name         string    `json:"name"`
	Status       *string   `json:"status"`
	AboutMe      string    `json:"about_me"`
	Location     *string   `json:"location"`
	JoinedAt     time.Time `json:"joined_at"`
	AvatarURL    string    `json:"avatar_url"`
	TwitterName  *string   `json:"twitter_url"`
	FacebookName *string   `json:"facebook_url"`
}

User represents a dual universe user profile

Jump to

Keyboard shortcuts

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