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

type YandexMetrica string

const (
	YandexMetricaYandexMetrica YandexMetrica = "yandex-metrica"
)

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

type SourceYandexMetrica struct {
	// Your Yandex Metrica API access token
	AuthToken string `json:"auth_token"`
	// Counter ID
	CounterID string `json:"counter_id"`
	// Starting point for your data replication, in format of "YYYY-MM-DD". If not provided will sync till most recent date.
	EndDate *types.Date `json:"end_date,omitempty"`
	// Starting point for your data replication, in format of "YYYY-MM-DD".
	StartDate  types.Date    `json:"start_date"`
	sourceType YandexMetrica `const:"yandex-metrica" json:"sourceType"`
}

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

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

func (o *SourceYandexMetrica) GetAuthToken() string {
	if o == nil {
		return ""
	}
	return o.AuthToken
}

func (o *SourceYandexMetrica) GetCounterID() string {
	if o == nil {
		return ""
	}
	return o.CounterID
}

func (o *SourceYandexMetrica) GetEndDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceYandexMetrica) GetStartDate() types.Date {
	if o == nil {
		return types.Date{}
	}
	return o.StartDate
}

func (o *SourceYandexMetrica) GetSourceType() YandexMetrica {
	return YandexMetricaYandexMetrica
}
