// 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"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/types"
	"time"
)

// StatisticsInterval - Periodicity of statistics returned. it may be daily(P1D), weekly(P1W) or monthly(P1M).
type StatisticsInterval string

const (
	StatisticsIntervalP1D StatisticsInterval = "P1D"
	StatisticsIntervalP1W StatisticsInterval = "P1W"
	StatisticsIntervalP1M StatisticsInterval = "P1M"
)

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

type Mention string

const (
	MentionMention Mention = "mention"
)

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

type SourceMention struct {
	APIKey       string      `json:"api_key"`
	StatsEndDate *types.Date `json:"stats_end_date,omitempty"`
	// Periodicity of statistics returned. it may be daily(P1D), weekly(P1W) or monthly(P1M).
	StatsInterval  *StatisticsInterval `default:"P1D" json:"stats_interval"`
	StatsStartDate time.Time           `json:"stats_start_date"`
	sourceType     Mention             `const:"mention" json:"sourceType"`
}

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

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

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

func (o *SourceMention) GetStatsEndDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.StatsEndDate
}

func (o *SourceMention) GetStatsInterval() *StatisticsInterval {
	if o == nil {
		return nil
	}
	return o.StatsInterval
}

func (o *SourceMention) GetStatsStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StatsStartDate
}

func (o *SourceMention) GetSourceType() Mention {
	return MentionMention
}
