platform

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 5 Imported by: 2

README

go-technic/platform

go-technic/platform is an API client library for interacting with the Technic Platform API.

Please note that at this time - the Technic Platform API is considered internal, and its use outside of Technic's software is unsupported.

Usage

import "github.com/jamiemansfield/go-technic/platform"

Documentation

Overview

Package platform provides a client for interacting with Technic Platform API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// Base URL for API requests. Defaults to Technic's Platform
	// 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 Platform API.
	UserAgent string
	// Build to use when communicating with the Platform API - as
	// Technic requires a valid launcher build to access the API.
	Build string

	// Services used for accessing different parts of the Platform
	// API.
	Modpack *ModpackService
	// contains filtered or unexported fields
}

A client manages communication with a Solder API, defaulting to Technic's instance.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Platform 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 Image added in v0.1.1

type Image struct {
	URL string `json:"url"`
	Md5 string `json:"md5"`
}

type Modpack

type Modpack struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	User        string `json:"user"`
	PlatformURL string `json:"platformUrl"`
	Ratings     int    `json:"ratings"`
	Downloads   int    `json:"downloads"`
	Runs        int    `json:"runs"`
	Description string `json:"description"`

	// Direct Download
	URL       string `json:"url"`
	Minecraft string `json:"minecraft"`
	Version   string `json:"version"`

	// Solder
	Solder string `json:"solder"`

	// Images
	Icon       *Image `json:"icon"`
	Background *Image `json:"background"`
}

type ModpackService

type ModpackService service

ModpackService provides access to the modpack routes of the Technic Platform API.

func (*ModpackService) GetModpack

func (s *ModpackService) GetModpack(slug string) (*Modpack, error)

GetModpack gets information about the given modpack from the Technic Platform API.

Jump to

Keyboard shortcuts

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