nexus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

View Source
const DefaultUrlGetModFormat = "https://api.nexusmods.com/v1/games/%v/mods/%v.json"

Variables

View Source
var ErrorNoApiKey = errors.New("no nexus api key provided")
View Source
var ErrorNoDriver = errors.New("no nexus http driver provided")

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(options ...ClientOption) (*Client, error)

func (*Client) GetMod

func (c *Client) GetMod(ctx context.Context, gameCode string, modId string) (*SchemaMod, error)

type ClientOption

type ClientOption func(*ClientOptions)

func WithApiKey

func WithApiKey(key string) ClientOption

func WithHTTPDriver

func WithHTTPDriver(driver HttpClient) ClientOption

func WithUrlGetModFormat

func WithUrlGetModFormat(format string) ClientOption

Format should contains 2 placeholder in this sequence:

  • Game code
  • Mod ID

Defaults to: [DefaultUrlGetModFormat]

type ClientOptions

type ClientOptions struct {
	Driver HttpClient
	ApiKey string

	UrlGetModFormat string
}

type HttpClient

type HttpClient interface {
	Get(ctx context.Context, apiKey string, url string) (string, error)
}

type SchemaMod

type SchemaMod struct {
	Uid        int    `json:"uid"`
	ModId      int    `json:"mod_id"`
	GameId     int    `json:"game_id"`
	DomainName string `json:"domain_name"`

	Name        string `json:"name"`
	Summary     string `json:"summary"`
	Description string `json:"description"`
	Version     string `json:"version"`
	CategoryId  int    `json:"category_id"`
	Status      string `json:"status"`

	MetadataPageUrl      string
	MetadataCategoryIcon string

	Author                  string `json:"author"`
	UploadedBy              string `json:"uploaded_by"`
	UploadedUsersProfileUrl string `json:"uploaded_users_profile_url"`

	PictureUrl string `json:"picture_url"`

	AllowRating          bool `json:"allow_rating"`
	ContainsAdultContent bool `json:"contains_adult_content"`
	Available            bool `json:"available"`

	EndorsementCount   int `json:"endorsement_count"`
	ModDownloads       int `json:"mod_downloads"`
	ModUniqueDownloads int `json:"mod_unique_downloads"`

	CreatedTimestamp int `json:"created_timestamp"`
	UpdatedTimestamp int `json:"updated_timestamp"`

	User        *SchemaModUser        `json:"user"`
	Endorsement *SchemaModEndorsement `json:"endorsement"`
}

type SchemaModEndorsement

type SchemaModEndorsement struct {
	EndorseStatus string `json:"endorse_status"`
	Timestamp     int    `json:"timestamp"`
	Version       string `json:"version"`
}

type SchemaModUser

type SchemaModUser struct {
	MemberId      int    `json:"member_id"`
	MemberGroupId int    `json:"member_group_id"`
	Name          string `json:"name"`
}

Jump to

Keyboard shortcuts

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