Skip to content

Commit

Permalink
Merge branch 'master' into markspolakovs-podcast-with-show
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs committed Jun 6, 2020
2 parents ce7141a + a199ef8 commit b8ecc0f
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions subtype.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
package myradio

// ShowSeasonSubtype gives information about an available show subtype
type ShowSeasonSubtype struct {
SubtypeID string `json:"id"`
Name string `json:"name"`
Class string `json:"class"`
SubtypeID string `json:"id"`
Name string `json:"name"`
Class string `json:"class"`
Description string `json:"description"`
}

// GetAllShowSubtypes returns an array of all ShowSeasonSubtypes
func (s *Session) GetAllShowSubtypes() (subtypes []ShowSeasonSubtype, err error) {
err = s.get("/showSubtype/all").Into(&subtypes)
return
}

// GetShowSubtypeByClass returns a ShowSeasonSubtype based on a given class
// Can return nil pointer if no subtype found for given class
func (s *Session) GetShowSubtypeByClass(class string) (subtype *ShowSeasonSubtype, err error) {
subtypes, err := s.GetAllShowSubtypes()
if err != nil {
return
}

for _, subtype := range subtypes {
if subtype.Class == class {
return &subtype, err
}
}
return
}

0 comments on commit b8ecc0f

Please sign in to comment.