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

package components

import (
	"encoding/json"
	"fmt"
	"github.com/LukeHagar/plexgo/internal/utils"
)

type SortPivot struct {
	Title   *string `json:"title,omitempty"`
	Type    *string `json:"type,omitempty"`
	Context *string `json:"context,omitempty"`
	ID      *string `json:"id,omitempty"`
	Key     *string `json:"key,omitempty"`
	Symbol  *string `json:"symbol,omitempty"`
}

func (s *SortPivot) GetTitle() *string {
	if s == nil {
		return nil
	}
	return s.Title
}

func (s *SortPivot) GetType() *string {
	if s == nil {
		return nil
	}
	return s.Type
}

func (s *SortPivot) GetContext() *string {
	if s == nil {
		return nil
	}
	return s.Context
}

func (s *SortPivot) GetID() *string {
	if s == nil {
		return nil
	}
	return s.ID
}

func (s *SortPivot) GetKey() *string {
	if s == nil {
		return nil
	}
	return s.Key
}

func (s *SortPivot) GetSymbol() *string {
	if s == nil {
		return nil
	}
	return s.Symbol
}

// SortDefault - If present, this sort is the default and in this direction
type SortDefault string

const (
	SortDefaultAsc  SortDefault = "asc"
	SortDefaultDesc SortDefault = "desc"
)

func (e SortDefault) ToPointer() *SortDefault {
	return &e
}
func (e *SortDefault) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "asc":
		fallthrough
	case "desc":
		*e = SortDefault(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SortDefault: %v", v)
	}
}

// DefaultDirection - This default diction of this sort
type DefaultDirection string

const (
	DefaultDirectionAsc  DefaultDirection = "asc"
	DefaultDirectionDesc DefaultDirection = "desc"
)

func (e DefaultDirection) ToPointer() *DefaultDirection {
	return &e
}
func (e *DefaultDirection) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "asc":
		fallthrough
	case "desc":
		*e = DefaultDirection(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DefaultDirection: %v", v)
	}
}

// Sort - Each `Sort` object contains a description of the sort field.
type Sort struct {
	// The title of the field.
	Title            *string `json:"title,omitempty"`
	Type             *string `json:"type,omitempty"`
	Art              *string `json:"art,omitempty"`
	Content          *bool   `json:"content,omitempty"`
	Filter           *string `json:"filter,omitempty"`
	HasPrefs         *bool   `json:"hasPrefs,omitempty"`
	HasStoreServices *bool   `json:"hasStoreServices,omitempty"`
	HubKey           *string `json:"hubKey,omitempty"`
	Identifier       *string `json:"identifier,omitempty"`
	// The key to use in the sort field to make items sort by this item
	Key            *string     `json:"key,omitempty"`
	LastAccessedAt *int64      `json:"lastAccessedAt,omitempty"`
	Pivot          []SortPivot `json:"Pivot,omitempty"`
	Share          *int64      `json:"share,omitempty"`
	Thumb          *string     `json:"thumb,omitempty"`
	TitleBar       *string     `json:"titleBar,omitempty"`
	// If present, this sort is the default and in this direction
	Default *SortDefault `json:"default,omitempty"`
	// This default diction of this sort
	DefaultDirection *DefaultDirection `json:"defaultDirection,omitempty"`
	// The key for sorting this field in reverse order
	DescKey *string `json:"descKey,omitempty"`
	// The key to use to get items sorted by this field and indexed by the first character
	FirstCharacterKey    *string        `json:"firstCharacterKey,omitempty"`
	AdditionalProperties map[string]any `additionalProperties:"true" json:"-"`
}

func (s Sort) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

func (s *Sort) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil {
		return err
	}
	return nil
}

func (s *Sort) GetTitle() *string {
	if s == nil {
		return nil
	}
	return s.Title
}

func (s *Sort) GetType() *string {
	if s == nil {
		return nil
	}
	return s.Type
}

func (s *Sort) GetArt() *string {
	if s == nil {
		return nil
	}
	return s.Art
}

func (s *Sort) GetContent() *bool {
	if s == nil {
		return nil
	}
	return s.Content
}

func (s *Sort) GetFilter() *string {
	if s == nil {
		return nil
	}
	return s.Filter
}

func (s *Sort) GetHasPrefs() *bool {
	if s == nil {
		return nil
	}
	return s.HasPrefs
}

func (s *Sort) GetHasStoreServices() *bool {
	if s == nil {
		return nil
	}
	return s.HasStoreServices
}

func (s *Sort) GetHubKey() *string {
	if s == nil {
		return nil
	}
	return s.HubKey
}

func (s *Sort) GetIdentifier() *string {
	if s == nil {
		return nil
	}
	return s.Identifier
}

func (s *Sort) GetKey() *string {
	if s == nil {
		return nil
	}
	return s.Key
}

func (s *Sort) GetLastAccessedAt() *int64 {
	if s == nil {
		return nil
	}
	return s.LastAccessedAt
}

func (s *Sort) GetPivot() []SortPivot {
	if s == nil {
		return nil
	}
	return s.Pivot
}

func (s *Sort) GetShare() *int64 {
	if s == nil {
		return nil
	}
	return s.Share
}

func (s *Sort) GetThumb() *string {
	if s == nil {
		return nil
	}
	return s.Thumb
}

func (s *Sort) GetTitleBar() *string {
	if s == nil {
		return nil
	}
	return s.TitleBar
}

func (s *Sort) GetDefault() *SortDefault {
	if s == nil {
		return nil
	}
	return s.Default
}

func (s *Sort) GetDefaultDirection() *DefaultDirection {
	if s == nil {
		return nil
	}
	return s.DefaultDirection
}

func (s *Sort) GetDescKey() *string {
	if s == nil {
		return nil
	}
	return s.DescKey
}

func (s *Sort) GetFirstCharacterKey() *string {
	if s == nil {
		return nil
	}
	return s.FirstCharacterKey
}

func (s *Sort) GetAdditionalProperties() map[string]any {
	if s == nil {
		return nil
	}
	return s.AdditionalProperties
}
