modpacksch

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package modpacksch provides a client for using the modpacks.ch API.

Index

Constants

View Source
const (
	StatusSuccess = "success"
	StatusError   = "error"
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

Types

type Art

type Art struct {
	ID         int    `json:"id"`
	URL        string `json:"url"`
	Type       string `json:"type"`
	Width      int    `json:"width"`
	Height     int    `json:"height"`
	Compressed bool   `json:"compressed"`
	Sha1       string `json:"sha1"`
	Size       int    `json:"size"`
	Updated    int64  `json:"updated"`
}

type Author

type Author struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Website string `json:"website"`
	Updated int64  `json:"updated"`
}

type Client

type Client struct {

	// Base URL for API requests. Defaults to the production
	// modpacks.ch API, but can be set to a domain endpoint
	// to use with other instances. BaseURL should always be
	// set with a trailing slash.
	BaseURL *url.URL

	// User Agent used when communicating with the modpacks.ch API.
	UserAgent string

	// Services used for accessing different parts of the modpacks.ch
	// API.
	Packs      *PackService
	Tags       *TagService
	CurseForge *CurseForgeService
	Mods       *ModService
	// contains filtered or unexported fields
}

A client manages communication with the modpacks.ch API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new modpacks.ch API client. If a nil client is provided, http.DefaultClient will be used.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v.

func (*Client) NewRequest

func (c *Client) NewRequest(method string, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by the body is JSON encoded and included as the request body.

type CurseForgeService

type CurseForgeService service

CurseForgeService handles communication with the CurseForge related methods of the modpacks.ch API.

modpacks.ch API docs: https://modpacksch.docs.apiary.io/#/reference/0/curseforge

func (*CurseForgeService) GetPack

func (s *CurseForgeService) GetPack(id int) (*Pack, error)

func (*CurseForgeService) GetVersion

func (s *CurseForgeService) GetVersion(packId int, versionId int) (*PackVersion, error)

func (*CurseForgeService) Search

func (s *CurseForgeService) Search(limit int, term string) ([]int, error)

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response

	Status  string `json:"status"`
	Message string `json:"message"`
}

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type File

type File struct {
	ID         int      `json:"id"`
	Type       string   `json:"type"`
	Path       string   `json:"path"`
	Name       string   `json:"name"`
	Version    string   `json:"version"`
	URL        string   `json:"url"`
	Sha1       string   `json:"sha1"`
	Size       int      `json:"size"`
	ClientOnly bool     `json:"clientonly"`
	ServerOnly bool     `json:"serveronly"`
	Optional   bool     `json:"optional"`
	Tags       []string `json:"tags"`
	Mirrors    []string `json:"mirrors"`
	Updated    int64    `json:"updated"`
}
type Link struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Link string `json:"link"`
	Type string `json:"type"`
}

type Mod

type Mod struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Synopsis    string `json:"synopsis"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Installs    int    `json:"installs"`

	Art      []*Art        `json:"art"`
	Authors  []*Author     `json:"authors"`
	Versions []*ModVersion `json:"versions"`

	Updated   int64 `json:"updated"`
	Refreshed int64 `json:"refreshed"`
}

type ModService

type ModService service

ModService handles communication with the mods related methods of the modpacks.ch API.

modpacks.ch API docs: https://modpacksch.docs.apiary.io/#/reference/0/mods

func (*ModService) Get

func (s *ModService) Get(id int) (*Mod, error)

func (*ModService) Search

func (s *ModService) Search(limit int, term string) ([]int, error)

type ModVersion

type ModVersion struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`

	Path       string `json:"path"`
	Version    string `json:"version"`
	URL        string `json:"url"`
	Sha1       string `json:"sha1"`
	Size       int    `json:"size"`
	ClientOnly bool   `json:"clientonly"`

	Targets      []*Target `json:"targets"`
	Dependencies []int     `json:"dependencies"`

	Updated int64 `json:"updated"`
}

type Pack

type Pack struct {
	ID           int    `json:"id"`
	Name         string `json:"name"`
	Synopsis     string `json:"synopsis"`
	Description  string `json:"description"`
	Type         string `json:"type"`
	Featured     bool   `json:"featured"`
	Installs     int    `json:"installs"`
	Plays        int    `json:"plays"`
	Updated      int64  `json:"updated"`
	Refreshed    int64  `json:"refreshed"`
	Notification string `json:"notification"`

	Rating   *Rating            `json:"rating"`
	Art      []*Art             `json:"art"`
	Links    []*Link            `json:"links"`
	Authors  []*Author          `json:"authors"`
	Versions []*PackVersionInfo `json:"versions"`
	Tags     []*Tag             `json:"tags"`
}

func (*Pack) GetIcon

func (p *Pack) GetIcon() *Art

func (*Pack) HasIcon

func (p *Pack) HasIcon() bool

type PackService

type PackService service

PackService handles communication with the pack related methods of the modpacks.ch API.

modpacks.ch API docs: https://modpacksch.docs.apiary.io/#/reference/0/modpacks

func (*PackService) All

func (s *PackService) All() ([]int, error)

func (*PackService) Featured

func (s *PackService) Featured(limit int) ([]int, error)

func (*PackService) GetPack

func (s *PackService) GetPack(id int) (*Pack, error)

func (*PackService) GetVersion

func (s *PackService) GetVersion(packId int, versionId int) (*PackVersion, error)

func (*PackService) GetVersionChangelog

func (s *PackService) GetVersionChangelog(packId int, versionId int) (*VersionChangelog, error)

func (*PackService) IncrementInstallCount

func (s *PackService) IncrementInstallCount(packId int, versionId int) error

func (*PackService) IncrementPlayCount

func (s *PackService) IncrementPlayCount(packId int, versionId int) error

func (*PackService) MostInstalled

func (s *PackService) MostInstalled(limit int) ([]int, error)

func (*PackService) MostInstalledWithTag

func (s *PackService) MostInstalledWithTag(limit int, tag string) ([]int, error)

func (*PackService) MostPlayed

func (s *PackService) MostPlayed(limit int) ([]int, error)

func (*PackService) MostPlayedWithTag

func (s *PackService) MostPlayedWithTag(limit int, tag string) ([]int, error)

func (*PackService) RecentlyUpdated

func (s *PackService) RecentlyUpdated(limit int) ([]int, error)

func (*PackService) Search

func (s *PackService) Search(limit int, term string) ([]int, error)

type PackVersion

type PackVersion struct {
	ID        int    `json:"id"`
	Parent    int    `json:"parent"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	Installs  int    `json:"installs"`
	Plays     int    `json:"plays"`
	Updated   int64  `json:"updated"`
	Refreshed int64  `json:"refreshed"`

	Specs   *Specs    `json:"specs"`
	Targets []*Target `json:"targets"`
	Files   []*File   `json:"files"`
}

type PackVersionInfo

type PackVersionInfo struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Updated int64  `json:"updated"`

	Specs   *Specs    `json:"specs"`
	Targets []*Target `json:"targets"`
}

type Rating added in v0.3.2

type Rating struct {
	ID  int `json:"id"`
	Age int `json:"age"`

	AlcoholDrugs    bool `json:"alcoholdrugs"`
	Configured      bool `json:"configured"`
	Frightening     bool `json:"frightening"`
	Gambling        bool `json:"gambling"`
	Language        bool `json:"language"`
	NuditySexual    bool `json:"nuditysexual"`
	StereotypesHate bool `json:"sterotypeshate"`
	Verified        bool `json:"verified"`
	Violence        bool `json:"violence"`
}

type Specs

type Specs struct {
	ID          int `json:"id"`
	Minimum     int `json:"minimum"`
	Recommended int `json:"recommended"`
}

Hardware minimum spec and recommended spec information. Specifically, the Minimum and Recommended fields are for memory in mebibytes.

type Tag

type Tag struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type TagService

type TagService service

TagService handles communication with the tags related methods of the modpacks.ch API.

modpacks.ch API docs: https://modpacksch.docs.apiary.io/#/reference/0/tags

func (*TagService) MostUsed

func (s *TagService) MostUsed(limit int) ([]string, error)

type Target

type Target struct {
	ID      int    `json:"id"`
	Type    string `json:"type"`
	Name    string `json:"name"`
	Version string `json:"version"`
	Updated int64  `json:"updated"`
}

type VersionChangelog

type VersionChangelog struct {
	Content string `json:"content"`
	Updated int64  `json:"updated"`
}

Jump to

Keyboard shortcuts

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