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

const (
	SourceSparkpostUpdateAPIEndpointPrefixAPI   SourceSparkpostUpdateAPIEndpointPrefix = "api"
	SourceSparkpostUpdateAPIEndpointPrefixAPIEu SourceSparkpostUpdateAPIEndpointPrefix = "api.eu"
)

func (e SourceSparkpostUpdateAPIEndpointPrefix) ToPointer() *SourceSparkpostUpdateAPIEndpointPrefix {
	return &e
}
func (e *SourceSparkpostUpdateAPIEndpointPrefix) 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 = SourceSparkpostUpdateAPIEndpointPrefix(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceSparkpostUpdateAPIEndpointPrefix: %v", v)
	}
}

type SourceSparkpostUpdate struct {
	APIKey    string                                  `json:"api_key"`
	APIPrefix *SourceSparkpostUpdateAPIEndpointPrefix `default:"api" json:"api_prefix"`
	StartDate time.Time                               `json:"start_date"`
}

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

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

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

func (o *SourceSparkpostUpdate) GetAPIPrefix() *SourceSparkpostUpdateAPIEndpointPrefix {
	if o == nil {
		return nil
	}
	return o.APIPrefix
}

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