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

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

const (
	SourceAppfiguresUpdateGroupByNetwork SourceAppfiguresUpdateGroupBy = "network"
	SourceAppfiguresUpdateGroupByProduct SourceAppfiguresUpdateGroupBy = "product"
	SourceAppfiguresUpdateGroupByCountry SourceAppfiguresUpdateGroupBy = "country"
	SourceAppfiguresUpdateGroupByDate    SourceAppfiguresUpdateGroupBy = "date"
)

func (e SourceAppfiguresUpdateGroupBy) ToPointer() *SourceAppfiguresUpdateGroupBy {
	return &e
}
func (e *SourceAppfiguresUpdateGroupBy) 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 = SourceAppfiguresUpdateGroupBy(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceAppfiguresUpdateGroupBy: %v", v)
	}
}

type SourceAppfiguresUpdate struct {
	APIKey string `json:"api_key"`
	// Category term for grouping the search results
	GroupBy *SourceAppfiguresUpdateGroupBy `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"`
}

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

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

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

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

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

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