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 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 { AssetLength int `json:"assetLength,omitempty"` ContentAPIID string `json:"contentApiId,omitempty"` ContentAPISeasonID string `json:"contentApiSeasonId,omitempty"` ContentAPISeriesID string `json:"contentApiSeriesId,omitempty"` ContentSource string `json:"contentSource,omitempty"` DescriptionShort LocalizedValue `json:"descriptionShort,omitempty"` Episode json.Number `json:"episode,omitempty"` Genre string `json:"genre,omitempty"` GenreDescription LocalizedField `json:"genreDescription,omitempty"` HideAds bool `json:"hideAds,omitempty"` JuneMediaID string `json:"juneMediaId,omitempty"` JuneProgramID string `json:"juneProgramId,omitempty"` LouisePressTitle string `json:"louisePressTitle,omitempty"` LouiseProductKey string `json:"louiseProductKey,omitempty"` LouiseProgramType string `json:"louiseProgramType,omitempty"` Season json.Number `json:"season,omitempty"` SeasonID string `json:"seasonId,omitempty"` SeasonSynopsis LocalizedField `json:"seasonSynopsis,omitempty"` SeriesDescriptionShort LocalizedField `json:"seriesDescriptionShort,omitempty"` SeriesID string `json:"seriesId,omitempty"` Title LocalizedValue `json:"title,omitempty"` YouTubeTemplate string `json:"youtubeTemplate,omitempty"` }
AssetMetadata is metadata for an Asset in the Vimond Rest API
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 parsed multi-language value
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