This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
go-discogs/models.go

198 lines
4.7 KiB
Go
Raw Normal View History

2016-03-10 14:25:55 +00:00
package discogs
import (
"net/url"
"strconv"
)
2018-03-12 20:31:47 +00:00
// Video ...
2016-03-10 14:25:55 +00:00
type Video struct {
Description string `json:"description"`
Duration int `json:"duration"`
Embed bool `json:"embed"`
Title string `json:"title"`
2018-03-12 20:31:47 +00:00
URI string `json:"uri"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// ArtistSource ...
2016-03-10 14:48:15 +00:00
type ArtistSource struct {
2018-03-12 20:31:47 +00:00
Anv string `json:"anv"`
ID int `json:"id"`
Join string `json:"join"`
2018-03-21 17:57:39 +00:00
Name string `json:"name"`
2018-03-12 20:31:47 +00:00
ResourceURL string `json:"resource_url"`
Role string `json:"role"`
Tracks string `json:"tracks"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// Image ...
2016-03-10 14:25:55 +00:00
type Image struct {
2018-03-12 20:31:47 +00:00
Height int `json:"height"`
Width int `json:"width"`
ResourceURL string `json:"resource_url"`
Type string `json:"type"`
URI string `json:"uri"`
URI150 string `json:"uri150"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// Track ...
2016-03-10 14:25:55 +00:00
type Track struct {
2016-03-10 14:48:15 +00:00
Duration string `json:"duration"`
Position string `json:"position"`
Title string `json:"title"`
Type string `json:"type_"`
Extraartists []ArtistSource `json:"extraartists,omitempty"`
Artists []ArtistSource `json:"artists,omitempty"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// LabelSource ...
2016-03-10 15:10:08 +00:00
type LabelSource struct {
Catno string `json:"catno"`
EntityType string `json:"entity_type"`
EntityTypeName string `json:"entity_type_name"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
2016-03-10 14:25:55 +00:00
}
2018-03-17 20:12:25 +00:00
// Identifier ...
2016-03-10 14:25:55 +00:00
type Identifier struct {
Type string `json:"type"`
Value string `json:"value"`
}
2018-03-12 20:31:47 +00:00
// Format ...
2016-03-10 14:25:55 +00:00
type Format struct {
Descriptions []string `json:"descriptions"`
Name string `json:"name"`
Qty string `json:"qty"`
}
2018-03-12 20:31:47 +00:00
// Company ...
2016-03-10 14:25:55 +00:00
type Company struct {
2018-03-12 20:31:47 +00:00
Catno string `json:"catno"`
EntityType string `json:"entity_type"`
EntityTypeName string `json:"entity_type_name"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// Community ...
2016-03-10 14:25:55 +00:00
type Community struct {
Contributors []Contributor `json:"contributors"`
DataQuality string `json:"data_quality"`
2016-03-10 14:25:55 +00:00
Have int `json:"have"`
Rating Rating `json:"rating"`
Status string `json:"status"`
Submitter Submitter `json:"submitter"`
Want int `json:"want"`
}
2018-03-12 20:31:47 +00:00
// Submitter ...
2016-03-10 14:25:55 +00:00
type Submitter struct {
2018-03-12 20:31:47 +00:00
ResourceURL string `json:"resource_url"`
Username string `json:"username"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// Rating ...
2016-03-10 14:25:55 +00:00
type Rating struct {
Average float32 `json:"average"`
Count int `json:"count"`
}
2018-03-12 20:31:47 +00:00
// Contributor ...
2016-03-10 14:25:55 +00:00
type Contributor struct {
2018-03-12 20:31:47 +00:00
ResourceURL string `json:"resource_url"`
Username string `json:"username"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// Page ...
2016-03-10 14:25:55 +00:00
type Page struct {
2018-03-12 20:31:47 +00:00
PerPage int `json:"per_page"`
Items int `json:"items"`
Page int `json:"page"`
URLs URLsList `json:"urls"`
Pages int `json:"pages"`
2016-03-10 14:25:55 +00:00
}
2018-03-12 20:31:47 +00:00
// URLsList ...
type URLsList struct {
2016-03-10 14:25:55 +00:00
Last string `json:"last"`
Next string `json:"next"`
}
2018-03-12 20:31:47 +00:00
// Version ...
2016-03-10 14:25:55 +00:00
type Version struct {
2018-03-12 20:31:47 +00:00
Catno string `json:"catno"`
Country string `json:"country"`
Format string `json:"format"`
ID int `json:"id"`
Label string `json:"label"`
Released string `json:"released"`
ResourceURL string `json:"resource_url"`
Status string `json:"status"`
Thumb string `json:"thumb"`
Title string `json:"title"`
2016-03-10 14:25:55 +00:00
}
2016-03-10 14:48:15 +00:00
2018-03-12 20:31:47 +00:00
// Member ...
2016-03-10 14:48:15 +00:00
type Member struct {
2018-03-12 20:31:47 +00:00
Active bool `json:"active"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
2016-03-10 14:48:15 +00:00
}
2016-03-10 15:10:08 +00:00
// Alias ...
type Alias struct {
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
}
2018-03-12 20:31:47 +00:00
// Sublable ...
2016-03-10 15:10:08 +00:00
type Sublable struct {
2018-03-12 20:31:47 +00:00
ResourceURL string `json:"url"`
ID int `json:"id"`
Name string `json:"name"`
2016-03-10 15:10:08 +00:00
}
2016-03-10 15:26:39 +00:00
2018-03-12 20:31:47 +00:00
// ReleaseSource ...
2016-03-10 15:26:39 +00:00
type ReleaseSource struct {
2018-03-12 20:31:47 +00:00
Artist string `json:"artist"`
Catno string `json:"catno"`
Format string `json:"format"`
ID int `json:"id"`
ResourceURL string `json:"resource_url"`
Status string `json:"status"`
Thumb string `json:"thumb"`
Title string `json:"title"`
Year int `json:"year"`
MainRelease int `json:"main_release"`
Role string `json:"role"`
Type string `json:"type"`
2016-03-10 15:26:39 +00:00
}
// Pagination ...
type Pagination struct {
Sort string // year, title, format
SortOrder string // asc, desc
Page int
PerPage int
}
// toParams converts pagaination params to request values
2019-06-06 12:18:10 +00:00
func (p *Pagination) params() url.Values {
if p == nil {
return nil
}
params := url.Values{}
2019-06-06 12:18:10 +00:00
params.Set("sort", p.Sort)
params.Set("sort_order", p.SortOrder)
params.Set("page", strconv.Itoa(p.Page))
params.Set("per_page", strconv.Itoa(p.PerPage))
return params
}