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

const (
	APIEndpointPrefixAPI   APIEndpointPrefix = "api"
	APIEndpointPrefixAPIEu APIEndpointPrefix = "api.eu"
)

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

type Sparkpost string

const (
	SparkpostSparkpost Sparkpost = "sparkpost"
)

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

type SourceSparkpost struct {
	APIKey     string             `json:"api_key"`
	APIPrefix  *APIEndpointPrefix `default:"api" json:"api_prefix"`
	StartDate  time.Time          `json:"start_date"`
	sourceType Sparkpost          `const:"sparkpost" json:"sourceType"`
}

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

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

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

func (o *SourceSparkpost) GetAPIPrefix() *APIEndpointPrefix {
	if o == nil {
		return nil
	}
	return o.APIPrefix
}

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

func (o *SourceSparkpost) GetSourceType() Sparkpost {
	return SparkpostSparkpost
}
