itchio

package module
v0.0.0-...-dce2b1a Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2017 License: MIT Imports: 13 Imported by: 0

README

go-itchio

MIT licensed build status coverage report

go-itchio is a set of Go bindings to interact with the itch.io API

License

Licensed under MIT License, see LICENSE for details.

Documentation

Index

Constants

View Source
const (
	BuildFileType_PATCH     BuildFileType = "patch"
	BuildFileType_ARCHIVE                 = "archive"
	BuildFileType_SIGNATURE               = "signature"
	BuildFileType_MANIFEST                = "manifest"
)
View Source
const (
	BuildFileSubType_DEFAULT   BuildFileSubType = "default"
	BuildFileSubType_GZIP                       = "gzip"
	BuildFileSubType_OPTIMIZED                  = "optimized"
)
View Source
const (
	UploadType_MULTIPART          UploadType = "multipart"
	UploadType_RESUMABLE                     = "resumable"
	UploadType_DEFERRED_RESUMABLE            = "deferred_resumable"
)
View Source
const (
	BuildState_STARTED    BuildState = "started"
	BuildState_PROCESSING            = "processing"
	BuildState_COMPLETED             = "completed"
	BuildState_FAILED                = "failed"
)
View Source
const (
	BuildFileState_CREATED   BuildFileState = "created"
	BuildFileState_UPLOADING                = "uploading"
	BuildFileState_UPLOADED                 = "uploaded"
	BuildFileState_FAILED                   = "failed"
)

Variables

View Source
var (
	BuildFileNotFound = errors.New("build file not found in storage")
)

Functions

func ItchfsURL

func ItchfsURL(buildID int64, fileID int64, apiKey string) string

ItchfsURL returns the itchfs:/// url usable to download a given file from a given build

func ParseAPIResponse

func ParseAPIResponse(dst interface{}, res *http.Response) error

Types

type BuildEvent

type BuildEvent struct {
	Type    BuildEventType
	Message string
	Data    BuildEventData
}

type BuildEventData

type BuildEventData map[string]interface{}

type BuildEventType

type BuildEventType string
const (
	BuildEvent_LOG BuildEventType = "log"
)

type BuildFileInfo

type BuildFileInfo struct {
	ID      int64
	Size    int64
	State   BuildFileState
	Type    BuildFileType    `json:"type"`
	SubType BuildFileSubType `json:"sub_type"`

	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

func FindBuildFile

func FindBuildFile(fileType BuildFileType, files []*BuildFileInfo) *BuildFileInfo

FindBuildFile looks for an uploaded file of the right type in a list of file. Returns nil if it can't find one.

type BuildFileState

type BuildFileState string

type BuildFileSubType

type BuildFileSubType string

type BuildFileType

type BuildFileType string

type BuildInfo

type BuildInfo struct {
	ID            int64
	ParentBuildID int64 `json:"parent_build_id"`
	State         BuildState

	Version     int64
	UserVersion string `json:"user_version"`

	Files []*BuildFileInfo

	User      User
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

func (BuildInfo) ItchfsURL

func (build BuildInfo) ItchfsURL(file *BuildFileInfo, apiKey string) string

ItchfsURL returns the itchfs:/// url usable to download a given file from a given build

type BuildState

type BuildState string

type ChannelInfo

type ChannelInfo struct {
	Name string
	Tags string

	Upload  Upload
	Head    *BuildInfo `json:"head"`
	Pending *BuildInfo `json:"pending"`
}

type Client

type Client struct {
	Key           string
	HTTPClient    *http.Client
	BaseURL       string
	RetryPatterns []time.Duration
	UserAgent     string
}

func ClientWithKey

func ClientWithKey(key string) *Client

func (*Client) CreateBuild

func (c *Client) CreateBuild(target string, channel string, userVersion string) (r NewBuildResponse, err error)

func (*Client) CreateBuildEvent

func (c *Client) CreateBuildEvent(buildID int64, eventType BuildEventType, message string, data BuildEventData) (r NewBuildEventResponse, err error)

func (*Client) CreateBuildFailure

func (c *Client) CreateBuildFailure(buildID int64, message string, fatal bool) (r CreateBuildFailureResponse, err error)

func (*Client) CreateBuildFile

func (c *Client) CreateBuildFile(buildID int64, fileType BuildFileType, subType BuildFileSubType, uploadType UploadType) (r NewBuildFileResponse, err error)

func (*Client) CreateRediffBuildFailure

func (c *Client) CreateRediffBuildFailure(buildID int64, message string) (r CreateBuildFailureResponse, err error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) DownloadBuildFile

func (c *Client) DownloadBuildFile(buildID int64, fileID int64) (reader io.ReadCloser, err error)

func (*Client) DownloadUploadBuild

func (c *Client) DownloadUploadBuild(uploadID int64, buildID int64) (r DownloadUploadBuildResponse, err error)

func (*Client) DownloadUploadBuildWithKey

func (c *Client) DownloadUploadBuildWithKey(downloadKey string, uploadID int64, buildID int64) (r DownloadUploadBuildResponse, err error)

func (*Client) DownloadUploadBuildWithKeyAndValues

func (c *Client) DownloadUploadBuildWithKeyAndValues(downloadKey string, uploadID int64, buildID int64, values url.Values) (r DownloadUploadBuildResponse, err error)

func (*Client) FinalizeBuildFile

func (c *Client) FinalizeBuildFile(buildID int64, fileID int64, size int64) (r FinalizeBuildFileResponse, err error)

func (*Client) GameUploads

func (c *Client) GameUploads(gameID int64) (r GameUploadsResponse, err error)

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) GetBuildFileDownloadURL

func (c *Client) GetBuildFileDownloadURL(buildID int64, fileID int64) (r DownloadBuildFileResponse, err error)

func (*Client) GetBuildFileDownloadURLWithValues

func (c *Client) GetBuildFileDownloadURLWithValues(buildID int64, fileID int64, values url.Values) (r DownloadBuildFileResponse, err error)

func (*Client) GetChannel

func (c *Client) GetChannel(target string, channel string) (r GetChannelResponse, err error)

func (*Client) ListBuildEvents

func (c *Client) ListBuildEvents(buildID int64) (r ListBuildEventsResponse, err error)

func (*Client) ListBuildFiles

func (c *Client) ListBuildFiles(buildID int64) (r ListBuildFilesResponse, err error)

func (*Client) ListChannels

func (c *Client) ListChannels(target string) (r ListChannelsResponse, err error)

func (*Client) MakePath

func (c *Client) MakePath(format string, a ...interface{}) string

func (*Client) MyGames

func (c *Client) MyGames() (r MyGamesResponse, err error)

func (*Client) PostForm

func (c *Client) PostForm(url string, data url.Values) (*http.Response, error)

func (*Client) SetServer

func (c *Client) SetServer(itchioServer string) *Client

func (*Client) UploadDownload

func (c *Client) UploadDownload(uploadID int64) (r UploadDownloadResponse, err error)

func (*Client) UploadDownloadWithKey

func (c *Client) UploadDownloadWithKey(downloadKey string, uploadID int64) (r UploadDownloadResponse, err error)

func (*Client) UploadDownloadWithKeyAndValues

func (c *Client) UploadDownloadWithKeyAndValues(downloadKey string, uploadID int64, values url.Values) (r UploadDownloadResponse, err error)

func (*Client) WharfStatus

func (c *Client) WharfStatus() (r StatusResponse, err error)

type CreateBuildFailureResponse

type CreateBuildFailureResponse struct {
	Response
}

type DownloadBuildFileResponse

type DownloadBuildFileResponse struct {
	Response

	URL string
}

type DownloadUploadBuildResponseItem

type DownloadUploadBuildResponseItem struct {
	URL string
}

type FinalizeBuildFileResponse

type FinalizeBuildFileResponse struct {
	Response
}

type Game

type Game struct {
	ID  int64
	Url string
}

type GameUploadsResponse

type GameUploadsResponse struct {
	Response

	Uploads []*Upload `json:"uploads"`
}

type GetChannelResponse

type GetChannelResponse struct {
	Response

	Channel ChannelInfo
}

type ListBuildEventsResponse

type ListBuildEventsResponse struct {
	Response

	Events []BuildEvent
}

type ListBuildFilesResponse

type ListBuildFilesResponse struct {
	Response

	Files []*BuildFileInfo
}

type ListChannelsResponse

type ListChannelsResponse struct {
	Response

	Channels map[string]ChannelInfo
}

type MyGamesResponse

type MyGamesResponse struct {
	Response

	Games []Game
}

type NewBuildEventResponse

type NewBuildEventResponse struct {
	Response
}

type NewBuildFileResponse

type NewBuildFileResponse struct {
	Response

	File struct {
		ID            int64
		UploadURL     string            `json:"upload_url"`
		UploadParams  map[string]string `json:"upload_params"`
		UploadHeaders map[string]string `json:"upload_headers"`
	}
}

type NewBuildResponse

type NewBuildResponse struct {
	Response

	Build struct {
		ID          int64 `json:"id"`
		UploadID    int64 `json:"upload_id"`
		ParentBuild struct {
			ID int64 `json:"id"`
		} `json:"parent_build"`
	}
}

type Response

type Response struct {
	Errors []string
}

type Spec

type Spec struct {
	Target  string
	Channel string
}

A Spec points to a given itch.io game, optionally to a specific channel

func ParseSpec

func ParseSpec(specIn string) (*Spec, error)

ParseSpec parses something of the form `user/page:channel` and returns `user/page` and `channel` separately

func (*Spec) EnsureChannel

func (spec *Spec) EnsureChannel() error

EnsureChannel returns an error if this spec is missing a channel

func (*Spec) String

func (spec *Spec) String() string

type StatusResponse

type StatusResponse struct {
	Response

	Success bool
}

type Upload

type Upload struct {
	ID          int64
	Filename    string
	Size        int64
	ChannelName string `json:"channel_name"`
	Build       *BuildInfo

	OSX     bool `json:"p_osx"`
	Linux   bool `json:"p_linux"`
	Windows bool `json:"p_windows"`
	Android bool `json:"p_android"`
}

type UploadDownloadResponse

type UploadDownloadResponse struct {
	Response

	URL string
}

type UploadType

type UploadType string

type User

type User struct {
	ID       int64
	Username string
	CoverUrl string `json:"cover_url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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