// 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 SourceCimisUpdateTargetsType string

const (
	SourceCimisUpdateTargetsTypeWsnStationNumbers        SourceCimisUpdateTargetsType = "WSN station numbers"
	SourceCimisUpdateTargetsTypeCaliforniaZipCodes       SourceCimisUpdateTargetsType = "California zip codes"
	SourceCimisUpdateTargetsTypeDecimalDegreeCoordinates SourceCimisUpdateTargetsType = "decimal-degree coordinates"
	SourceCimisUpdateTargetsTypeStreetAddresses          SourceCimisUpdateTargetsType = "street addresses"
)

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

type SourceCimisUpdateUnitOfMeasure string

const (
	SourceCimisUpdateUnitOfMeasureE SourceCimisUpdateUnitOfMeasure = "E"
	SourceCimisUpdateUnitOfMeasureM SourceCimisUpdateUnitOfMeasure = "M"
)

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

type SourceCimisUpdate 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     SourceCimisUpdateTargetsType    `json:"targets_type"`
	UnitOfMeasure   *SourceCimisUpdateUnitOfMeasure `json:"unit_of_measure,omitempty"`
}

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

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

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

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

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

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

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

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

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

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