Documentation
¶
Overview ¶
Package restapi contains a client for the Vimond REST API
Index ¶
- Variables
- func BaseURL(rawurl string) func(*Client)
- func Credentials(apiKey, secret string) func(*Client)
- func HTTPClient(hc *http.Client) func(*Client)
- func UserAgent(ua string) func(*Client)
- type Asset
- type AssetMetadata
- type Category
- type Client
- func (c *Client) Asset(ctx context.Context, platform, assetID string) (*Asset, error)
- func (c *Client) AssetRaw(ctx context.Context, platform, assetID, headerAccept string) ([]byte, error)
- func (c *Client) CreateOrder(ctx context.Context, platform, userID, productPaymentID string) (*Order, error)
- func (c *Client) CurrentOrders(ctx context.Context, platform, userID string) ([]*Order, error)
- func (c *Client) Order(ctx context.Context, platform, orderID string) (*Order, error)
- func (c *Client) Platforms(ctx context.Context) ([]Platform, error)
- func (c *Client) SetOrderEndDates(ctx context.Context, platform, orderID string, endDate time.Time) (*Order, error)
- func (c *Client) Videofiles(ctx context.Context, assetID string) (*VideofilesResponse, error)
- type Image
- type ImageVersions
- type LocalizedField
- type LocalizedValue
- type MetadataEntries
- type Order
- type Platform
- type Videofile
- type VideofilesResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAssetID = errors.New("vimond/restapi: invalid asset id") ErrNotFound = errors.New("vimond/restapi: not found") ErrUnknown = errors.New("vimond/restapi: unknown") )
Errors
Functions ¶
func Credentials ¶
Credentials changes the apiKey and secret used to sign API requests
func HTTPClient ¶
HTTPClient changes the *client HTTP client to the provided *http.Client
Types ¶
type Asset ¶
type Asset struct {
ID string `json:"id"`
ChannelID string `json:"channelId"`
CategoryID string `json:"categoryId"`
AssetTypeID string `json:"assetTypeId"`
Description string `json:"description"`
ImageURL string `json:"imageUrl"`
Title string `json:"title"`
ImageVersions ImageVersions `json:"imageVersions"`
Archive bool `json:"archive"`
Aspect16x9 bool `json:"aspect16x9"`
AutoDistribute bool `json:"autoDistribute"`
AutoEncode bool `json:"autoEncode"`
AutoPublish bool `json:"autoPublish"`
CopyLiveStream bool `json:"copyLiveStream"`
DRMProtected bool `json:"drmProtected"`
Deleted bool `json:"deleted"`
ItemsPublished bool `json:"itemsPublished"`
LabeledAsFree bool `json:"labeledAsFree"`
Live bool `json:"live"`
Duration int `json:"duration"`
Views int `json:"views"`
AccurateDuration float64 `json:"accurateDuration"`
CreateTime time.Time `json:"createTime"`
ExpireDate time.Time `json:"expireDate"`
LiveBroadcastTime time.Time `json:"liveBroadcastTime"`
UpdateTime time.Time `json:"updateTime"`
Metadata AssetMetadata `json:"metadata"`
Category Category `json:"category"`
}
Asset is a Vimond Rest API asset
type AssetMetadata ¶
type AssetMetadata struct {
Entries MetadataEntries `json:"entries"`
}
AssetMetadata represents Vimond asset metadata.
type Category ¶
type Category struct {
Parent *Category `json:"parent"`
Title string `json:"title"`
ID string `json:"id"`
}
Category is a category node in the Vimond Rest API category tree
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the Vimond REST API
func (*Client) AssetRaw ¶
func (c *Client) AssetRaw(ctx context.Context, platform, assetID, headerAccept string) ([]byte, error)
AssetRaw returns the raw response for an asset from the Vimond Rest API. possible values for headerAccept: application/json; v=3; charset=utf-8 application/json; v=2; charset=utf-8 application/json; charset=utf-8 application/xml; charset=utf-8
func (*Client) CreateOrder ¶
func (c *Client) CreateOrder(ctx context.Context, platform, userID, productPaymentID string) (*Order, error)
CreateOrder creates an order.
func (*Client) CurrentOrders ¶
CurrentOrders returns information about a user's currently active orders.
func (*Client) SetOrderEndDates ¶
func (c *Client) SetOrderEndDates(ctx context.Context, platform, orderID string, endDate time.Time) (*Order, error)
SetOrderEndDates updates the endData and accessEndDate fields of an order to the given end date. This method fetches the given order, strips null values and nested objects (the Vimond API explodes on them), sets the dates, and PUTs the resulting object back. This may result in data loss. Use with caution.
func (*Client) Videofiles ¶
Videofiles returns a list of videofiles for the given assetID
type ImageVersions ¶
type ImageVersions struct {
Images []Image `json:"images,omitempty"`
}
ImageVersions is a slice of ImageVersion
func (ImageVersions) TypeURL ¶
func (ivs ImageVersions) TypeURL(ivt string) string
TypeURL returns the URL for the given image version type
type LocalizedField ¶
type LocalizedField []LocalizedValue
LocalizedField is field with localized values
func (LocalizedField) Value ¶
func (lf LocalizedField) Value(lang string) string
Value returns the value for the given lang, fallback to *
type LocalizedValue ¶
LocalizedValue is a representation of a multi-language value
type MetadataEntries ¶
type MetadataEntries struct {
AssetLength LocalizedField `json:"asset-length,omitempty"`
ContentAPIID LocalizedField `json:"content-api-id,omitempty"`
ContentAPISeasonID LocalizedField `json:"content-api-season-id,omitempty"`
ContentAPISeriesID LocalizedField `json:"content-api-series-id,omitempty"`
ContentSource LocalizedField `json:"content-source,omitempty"`
DescriptionShort LocalizedField `json:"description-short,omitempty"`
Episode LocalizedField `json:"episode,omitempty"`
Genre LocalizedField `json:"genre,omitempty"`
GenreDescription LocalizedField `json:"genre-description,omitempty"`
HideAds LocalizedField `json:"hideAds,omitempty"`
ImagePack LocalizedField `json:"image-pack,omitempty"`
JuneMediaID LocalizedField `json:"june-media-id,omitempty"`
JuneProgramID LocalizedField `json:"june-program-id,omitempty"`
LouisePressTitle LocalizedField `json:"louise-press-title,omitempty"`
LouiseProductKey LocalizedField `json:"louise-product-key,omitempty"`
Season LocalizedField `json:"season,omitempty"`
SeasonID LocalizedField `json:"season-id,omitempty"`
SeasonSynopsis LocalizedField `json:"season-synopsis,omitempty"`
SeriesDescriptionShort LocalizedField `json:"series-description-short,omitempty"`
SeriesID LocalizedField `json:"series-id,omitempty"`
Title LocalizedField `json:"title,omitempty"`
YouTubeTemplate LocalizedField `json:"youtube-template,omitempty"`
}
MetadataEntries is metadata for an Asset in the Vimond Rest API
type Order ¶
type Order struct {
AccessEndDate time.Time
EndDate time.Time
ID string
ProductName string
ProductPaymentID string
StartDate time.Time
UserID string
}
Order holds a subset of the fields of an order.
type Videofile ¶
type Videofile struct {
Bitrate int `json:"bitrate"`
MediaFormat string `json:"mediaFormat"`
Scheme string `json:"scheme"`
Server string `json:"server"`
Base string `json:"base"`
URL string `json:"url"`
FileSize int64 `json:"filesize"`
}
Videofile has information like bitrate, format, etc. for a video file
type VideofilesResponse ¶
type VideofilesResponse struct {
AssetID int `json:"assetId"`
Title string `json:"title"`
Videofiles []Videofile `json:"videofiles"`
}
VideofilesResponse is the response returned by the Videofiles method