// 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"
	"time"
)

// GroupBy - Category term for grouping the search results
type GroupBy string

const (
	GroupByNetwork GroupBy = "network"
	GroupByProduct GroupBy = "product"
	GroupByCountry GroupBy = "country"
	GroupByDate    GroupBy = "date"
)

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

type Appfigures string

const (
	AppfiguresAppfigures Appfigures = "appfigures"
)

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

type SourceAppfigures struct {
	APIKey string `json:"api_key"`
	// Category term for grouping the search results
	GroupBy *GroupBy `default:"product" json:"group_by"`
	// The store which needs to be searched in streams
	SearchStore *string    `default:"apple" json:"search_store"`
	StartDate   time.Time  `json:"start_date"`
	sourceType  Appfigures `const:"appfigures" json:"sourceType"`
}

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

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

func (o *SourceAppfigures) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

func (o *SourceAppfigures) GetGroupBy() *GroupBy {
	if o == nil {
		return nil
	}
	return o.GroupBy
}

func (o *SourceAppfigures) GetSearchStore() *string {
	if o == nil {
		return nil
	}
	return o.SearchStore
}

func (o *SourceAppfigures) GetStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate
}

func (o *SourceAppfigures) GetSourceType() Appfigures {
	return AppfiguresAppfigures
}
