areena

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

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

Go to latest
Published: Feb 15, 2016 License: MIT Imports: 16 Imported by: 0

README

Areena

Go client for interacting with Yle Areena API. WIP.

Usage

define the following environment variables (get these from http://developer.yle.fi/):

export YLE_APP_ID="YOUR_APP_ID"
export YLE_APP_KEY="YOUR_APP_KEY"
export YLE_SECRET="YOUR_APP_SECRET"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound - resource was not found
	ErrNotFound       = errors.New("Resource not found")
	ErrMediaIDMissing = errors.New("Failed to find available media id")
)

Functions

func DecryptURL

func DecryptURL(secret string, encStr string) (url string, err error)

DecryptURL decrypts URL according to http://developer.yle.fi/tutorial-playing-a-program/

func Slugify

func Slugify(s string) (res string)

Slugify create slug e.g. for filename

Types

type Client

type Client struct {

	// Base URL for API requests, should have a trailing slash.
	BaseURL *url.URL

	// User agent
	UserAgent string
	// contains filtered or unexported fields
}

Client manages communication with the Yle API.

func NewClient

func NewClient(cfg *Config) (client *Client, err error)

NewClient Client constructor

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (err error)

Do sends an API request

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. Areena API is GET only.

func (*Client) Playout

func (c *Client) Playout(programID string, mediaID string, protocol string) (playout *responses.Playout, err error)

Playout fetch playout details

func (*Client) Program

func (c *Client) Program(programID string) (program *responses.Program, err error)

Program fetch details of program

func (*Client) ProgramDetails

func (c *Client) ProgramDetails(programID string) (details *results.ProgramDetails, err error)

ProgramDetails fetch & parse program details for given programID

type Config

type Config struct {
	YleAppID   string `envconfig:"APP_ID" required:"true"`
	YleAppKey  string `envconfig:"APP_KEY" required:"true"`
	YleSecret  string `envconfig:"SECRET" required:"true"`
	APIBaseURL string `envconfig:"BASE_URL" default:"https://external.api.yle.fi/v1/"`
	Debug      bool   `envconfig:"DEBUG" default:"false"`
	HTTPClient *http.Client
}

Config - client settings

func NewConfig

func NewConfig() (cfg *Config, err error)

NewConfig init config based on env

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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