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

const (
	SegmentSegment Segment = "segment"
)

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

type SourceSegment struct {
	// API token to use. Generate it in Segment's Workspace settings.
	APIToken string `json:"api_token"`
	// The region for the API, e.g., 'api' for US or 'eu1' for EU
	Region     *string   `default:"api" json:"region"`
	StartDate  time.Time `json:"start_date"`
	sourceType Segment   `const:"segment" json:"sourceType"`
}

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

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

func (o *SourceSegment) GetAPIToken() string {
	if o == nil {
		return ""
	}
	return o.APIToken
}

func (o *SourceSegment) GetRegion() *string {
	if o == nil {
		return nil
	}
	return o.Region
}

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

func (o *SourceSegment) GetSourceType() Segment {
	return SegmentSegment
}
