GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

63 lines
1.7 KiB

package models
import (
"fmt"
"io"
"strconv"
)
// ChangeModel describes a model related to the change.
type ChangeModel string
const (
// ChangeModelCharacter is a value of ChangeModel
ChangeModelCharacter ChangeModel = "Character"
// ChangeModelChannel is a value of ChangeModel
ChangeModelChannel ChangeModel = "Channel"
// ChangeModelLog is a value of ChangeModel
ChangeModelLog ChangeModel = "Log"
// ChangeModelPost is a value of ChangeModel
ChangeModelPost ChangeModel = "Post"
// ChangeModelStory is a value of ChangeModel
ChangeModelStory ChangeModel = "Story"
// ChangeModelTag is a value of ChangeModel
ChangeModelTag ChangeModel = "Tag"
// ChangeModelChapter is a value of ChangeModel
ChangeModelChapter ChangeModel = "Chapter"
// ChangeModelComment is a value of ChangeModel
ChangeModelComment ChangeModel = "Comment"
// ChangeModelFile is a value of ChangeModel
ChangeModelFile ChangeModel = "File"
)
// IsValid returns true if the underlying string is one of the correct values.
func (e ChangeModel) IsValid() bool {
switch e {
case ChangeModelCharacter, ChangeModelChannel, ChangeModelLog, ChangeModelPost, ChangeModelStory, ChangeModelTag, ChangeModelChapter, ChangeModelComment:
return true
}
return false
}
func (e ChangeModel) String() string {
return string(e)
}
// UnmarshalGQL unmarshals the underlying graphql value.
func (e *ChangeModel) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = ChangeModel(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid ChangeModel", str)
}
return nil
}
// MarshalGQL marshals the underlying graphql value.
func (e ChangeModel) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}