nexus

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultUrlGetFilesFormat = "https://api.nexusmods.com/v1/games/%v/mods/%v/files.json"
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 WithUrlGetFilesFormat added in v0.2.1

func WithUrlGetFilesFormat(format string) 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
	UrlGetFilesFormat 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"`

	Files *SchemaModFiles
}

type SchemaModEndorsement

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

type SchemaModFile added in v0.2.1

type SchemaModFile struct {
	Id         []int `json:"id"`
	Uid        int   `json:"uid"`
	FileId     int   `json:"file_id"`
	CategoryId int   `json:"category_id"`

	Name         string `json:"name"`
	CategoryName string `json:"category_name"`
	FileName     string `json:"file_name"`
	Description  string `json:"description"`

	Version       string `json:"version"`
	ModVersion    string `json:"mod_version"`
	IsPrimary     bool   `json:"is_primary"`
	Size          int    `json:"size"`
	SizeKb        int    `json:"size_kb"`
	SizeKbInBytes int    `json:"size_kb_in_bytes"`

	UploadedTimestamp    int    `json:"uploaded_timestamp"`
	UploadedTime         string `json:"uploaded_time"`
	ExternalVirusScanUrl string `json:"external_virus_scan_url"`

	ChangelogHtml      string `json:"changelog_html"`
	ContentPreviewLink string `json:"content_preview_link"`
}

type SchemaModFileUpdate added in v0.2.1

type SchemaModFileUpdate struct {
	OldFileId         int    `json:"old_file_id"`
	NewFileId         int    `json:"new_file_id"`
	OldFileName       string `json:"old_file_name"`
	NewFileName       string `json:"new_file_name"`
	UploadedTimestamp int    `json:"uploaded_timestamp"`
	UploadedTime      string `json:"uploaded_time"`
}

type SchemaModFiles added in v0.2.1

type SchemaModFiles struct {
	Files       []SchemaModFile       `json:"files"`
	FileUpdates []SchemaModFileUpdate `json:"file_updates"`
}

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