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

// SourceAmplitudeUpdateDataRegion - Amplitude data region server
type SourceAmplitudeUpdateDataRegion string

const (
	SourceAmplitudeUpdateDataRegionStandardServer    SourceAmplitudeUpdateDataRegion = "Standard Server"
	SourceAmplitudeUpdateDataRegionEuResidencyServer SourceAmplitudeUpdateDataRegion = "EU Residency Server"
)

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

type SourceAmplitudeUpdate struct {
	// According to <a href="https://amplitude.com/docs/apis/analytics/dashboard-rest#query-parameters">Amplitude documentation</a>, grouping by `Country` is optional. If you face issues fetching the stream or checking the connection please set this field to `False`.
	//
	ActiveUsersGroupByCountry *bool `default:"true" json:"active_users_group_by_country"`
	// Amplitude API Key. See the <a href="https://docs.airbyte.com/integrations/sources/amplitude#setup-guide">setup guide</a> for more information on how to obtain this key.
	APIKey string `json:"api_key"`
	// Amplitude data region server
	DataRegion *SourceAmplitudeUpdateDataRegion `default:"Standard Server" json:"data_region"`
	// According to <a href="https://www.docs.developers.amplitude.com/analytics/apis/export-api/#considerations">Considerations</a> too large of a time range in te request can cause a timeout error. In this case, please provide a shorter time interval in hours.
	//
	RequestTimeRange *int64 `default:"24" json:"request_time_range"`
	// Amplitude Secret Key. See the <a href="https://docs.airbyte.com/integrations/sources/amplitude#setup-guide">setup guide</a> for more information on how to obtain this key.
	SecretKey string `json:"secret_key"`
	// UTC date and time in the format 2021-01-25T00:00:00Z. Any data before this date will not be replicated.
	StartDate time.Time `json:"start_date"`
}

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

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

func (o *SourceAmplitudeUpdate) GetActiveUsersGroupByCountry() *bool {
	if o == nil {
		return nil
	}
	return o.ActiveUsersGroupByCountry
}

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

func (o *SourceAmplitudeUpdate) GetDataRegion() *SourceAmplitudeUpdateDataRegion {
	if o == nil {
		return nil
	}
	return o.DataRegion
}

func (o *SourceAmplitudeUpdate) GetRequestTimeRange() *int64 {
	if o == nil {
		return nil
	}
	return o.RequestTimeRange
}

func (o *SourceAmplitudeUpdate) GetSecretKey() string {
	if o == nil {
		return ""
	}
	return o.SecretKey
}

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