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

const (
	PosthogPosthog Posthog = "posthog"
)

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

type SourcePosthog struct {
	// API Key. See the <a href="https://docs.airbyte.com/integrations/sources/posthog">docs</a> for information on how to generate this key.
	APIKey string `json:"api_key"`
	// Base PostHog url. Defaults to PostHog Cloud (https://app.posthog.com).
	BaseURL *string `default:"https://app.posthog.com" json:"base_url"`
	// Set lower value in case of failing long running sync of events stream.
	EventsTimeStep *int64 `default:"30" json:"events_time_step"`
	// The date from which you'd like to replicate the data. Any data before this date will not be replicated.
	StartDate  time.Time `json:"start_date"`
	sourceType Posthog   `const:"posthog" json:"sourceType"`
}

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

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

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

func (o *SourcePosthog) GetBaseURL() *string {
	if o == nil {
		return nil
	}
	return o.BaseURL
}

func (o *SourcePosthog) GetEventsTimeStep() *int64 {
	if o == nil {
		return nil
	}
	return o.EventsTimeStep
}

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

func (o *SourcePosthog) GetSourceType() Posthog {
	return PosthogPosthog
}
