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

package shared

import (
	"encoding/json"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
)

type Gutendex string

const (
	GutendexGutendex Gutendex = "gutendex"
)

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

type SourceGutendex struct {
	// (Optional) Defines the maximum birth year of the authors. Books by authors born after the end year will not be returned. Supports both positive (CE) or negative (BCE) integer values
	AuthorYearEnd *string `json:"author_year_end,omitempty"`
	// (Optional) Defines the minimum birth year of the authors. Books by authors born prior to the start year will not be returned. Supports both positive (CE) or negative (BCE) integer values
	AuthorYearStart *string `json:"author_year_start,omitempty"`
	// (Optional) Use this to find books with a certain copyright status - true for books with existing copyrights, false for books in the public domain in the USA, or null for books with no available copyright information.
	Copyright *string `json:"copyright,omitempty"`
	// (Optional) Use this to find books in any of a list of languages. They must be comma-separated, two-character language codes.
	Languages *string `json:"languages,omitempty"`
	// (Optional) Use this to search author names and book titles with given words. They must be separated by a space (i.e. %20 in URL-encoded format) and are case-insensitive.
	Search *string `json:"search,omitempty"`
	// (Optional) Use this to sort books - ascending for Project Gutenberg ID numbers from lowest to highest, descending for IDs highest to lowest, or popular (the default) for most popular to least popular by number of downloads.
	Sort *string `json:"sort,omitempty"`
	// (Optional) Use this to search for a case-insensitive key-phrase in books' bookshelves or subjects.
	Topic      *string  `json:"topic,omitempty"`
	sourceType Gutendex `const:"gutendex" json:"sourceType"`
}

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

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

func (o *SourceGutendex) GetAuthorYearEnd() *string {
	if o == nil {
		return nil
	}
	return o.AuthorYearEnd
}

func (o *SourceGutendex) GetAuthorYearStart() *string {
	if o == nil {
		return nil
	}
	return o.AuthorYearStart
}

func (o *SourceGutendex) GetCopyright() *string {
	if o == nil {
		return nil
	}
	return o.Copyright
}

func (o *SourceGutendex) GetLanguages() *string {
	if o == nil {
		return nil
	}
	return o.Languages
}

func (o *SourceGutendex) GetSearch() *string {
	if o == nil {
		return nil
	}
	return o.Search
}

func (o *SourceGutendex) GetSort() *string {
	if o == nil {
		return nil
	}
	return o.Sort
}

func (o *SourceGutendex) GetTopic() *string {
	if o == nil {
		return nil
	}
	return o.Topic
}

func (o *SourceGutendex) GetSourceType() Gutendex {
	return GutendexGutendex
}
