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

type TargetsType string

const (
	TargetsTypeWsnStationNumbers        TargetsType = "WSN station numbers"
	TargetsTypeCaliforniaZipCodes       TargetsType = "California zip codes"
	TargetsTypeDecimalDegreeCoordinates TargetsType = "decimal-degree coordinates"
	TargetsTypeStreetAddresses          TargetsType = "street addresses"
)

func (e TargetsType) ToPointer() *TargetsType {
	return &e
}
func (e *TargetsType) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "WSN station numbers":
		fallthrough
	case "California zip codes":
		fallthrough
	case "decimal-degree coordinates":
		fallthrough
	case "street addresses":
		*e = TargetsType(v)
		return nil
	default:
		return fmt.Errorf("invalid value for TargetsType: %v", v)
	}
}

type UnitOfMeasure string

const (
	UnitOfMeasureE UnitOfMeasure = "E"
	UnitOfMeasureM UnitOfMeasure = "M"
)

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

type Cimis string

const (
	CimisCimis Cimis = "cimis"
)

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

type SourceCimis struct {
	APIKey          string         `json:"api_key"`
	DailyDataItems  []any          `json:"daily_data_items,omitempty"`
	EndDate         time.Time      `json:"end_date"`
	HourlyDataItems []any          `json:"hourly_data_items,omitempty"`
	StartDate       time.Time      `json:"start_date"`
	Targets         []any          `json:"targets"`
	TargetsType     TargetsType    `json:"targets_type"`
	UnitOfMeasure   *UnitOfMeasure `json:"unit_of_measure,omitempty"`
	sourceType      Cimis          `const:"cimis" json:"sourceType"`
}

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

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

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

func (o *SourceCimis) GetDailyDataItems() []any {
	if o == nil {
		return nil
	}
	return o.DailyDataItems
}

func (o *SourceCimis) GetEndDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.EndDate
}

func (o *SourceCimis) GetHourlyDataItems() []any {
	if o == nil {
		return nil
	}
	return o.HourlyDataItems
}

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

func (o *SourceCimis) GetTargets() []any {
	if o == nil {
		return []any{}
	}
	return o.Targets
}

func (o *SourceCimis) GetTargetsType() TargetsType {
	if o == nil {
		return TargetsType("")
	}
	return o.TargetsType
}

func (o *SourceCimis) GetUnitOfMeasure() *UnitOfMeasure {
	if o == nil {
		return nil
	}
	return o.UnitOfMeasure
}

func (o *SourceCimis) GetSourceType() Cimis {
	return CimisCimis
}
