// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package components

import (
	"encoding/json"
	"fmt"
)

// MediaType - The type of media to retrieve or filter by.
//
// 1 = movie
// 2 = show
// 3 = season
// 4 = episode
// 5 = artist
// 6 = album
// 7 = track
// 8 = photo_album
// 9 = photo
//
// E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
type MediaType int64

const (
	MediaTypeMovie      MediaType = 1
	MediaTypeTvShow     MediaType = 2
	MediaTypeSeason     MediaType = 3
	MediaTypeEpisode    MediaType = 4
	MediaTypeArtist     MediaType = 5
	MediaTypeAlbum      MediaType = 6
	MediaTypeTrack      MediaType = 7
	MediaTypePhotoAlbum MediaType = 8
	MediaTypePhoto      MediaType = 9
)

func (e MediaType) ToPointer() *MediaType {
	return &e
}
func (e *MediaType) UnmarshalJSON(data []byte) error {
	var v int64
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case 1:
		fallthrough
	case 2:
		fallthrough
	case 3:
		fallthrough
	case 4:
		fallthrough
	case 5:
		fallthrough
	case 6:
		fallthrough
	case 7:
		fallthrough
	case 8:
		fallthrough
	case 9:
		*e = MediaType(v)
		return nil
	default:
		return fmt.Errorf("invalid value for MediaType: %v", v)
	}
}
