restapi

package
v0.0.0-...-4e209d0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package restapi contains a client for the Vimond REST API

Index

Constants

This section is empty.

Variables

View Source
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 BaseURL

func BaseURL(rawurl string) func(*Client)

BaseURL changes the *client base URL based on the provided rawurl

func Credentials

func Credentials(apiKey, secret string) func(*Client)

Credentials changes the apiKey and secret used to sign API requests

func HTTPClient

func HTTPClient(hc *http.Client) func(*Client)

HTTPClient changes the *client HTTP client to the provided *http.Client

func UserAgent

func UserAgent(ua string) func(*Client)

UserAgent changes the User-Agent used in requests sent by the *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 {
	Annotags               string         `json:"annotags,omitempty"`
	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

func (*Category) In

func (c *Category) In(id string) bool

In walks the category tree upwards, looking for the given ID

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for the Vimond REST API

func NewClient

func NewClient(options ...func(*Client)) *Client

NewClient creates a new Vimond REST API Client

func (*Client) Asset

func (c *Client) Asset(ctx context.Context, platform, assetID string) (*Asset, error)

Asset returns an asset from 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

func (c *Client) CurrentOrders(ctx context.Context, platform, userID string) ([]*Order, error)

CurrentOrders returns information about a user's currently active orders.

func (*Client) Order

func (c *Client) Order(ctx context.Context, platform, orderID string) (*Order, error)

Order returns information about an order.

func (*Client) Platforms

func (c *Client) Platforms(ctx context.Context) ([]Platform, error)

Platforms returns the list of available platforms.

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

func (c *Client) Videofiles(ctx context.Context, assetID string) (*VideofilesResponse, error)

Videofiles returns a list of videofiles for the given assetID

type Image

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

Image is a version of image representing the asset

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

type LocalizedValue struct {
	Lang  string `json:"lang"`
	Value string `json:"value"`
}

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 Platform

type Platform struct {
	ID   int
	Name string
}

Platform represents a Vimond platform, such as TV4.

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

Jump to

Keyboard shortcuts

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