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

// SourcePaddleUpdateEnvironment - The environment for the Paddle API, either 'sandbox' or 'live'.
type SourcePaddleUpdateEnvironment string

const (
	SourcePaddleUpdateEnvironmentAPI        SourcePaddleUpdateEnvironment = "api"
	SourcePaddleUpdateEnvironmentSandboxAPI SourcePaddleUpdateEnvironment = "sandbox-api"
)

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

type SourcePaddleUpdate struct {
	// Your Paddle API key. You can generate it by navigating to Paddle > Developer tools > Authentication > Generate API key. Treat this key like a password and keep it secure.
	APIKey string `json:"api_key"`
	// The environment for the Paddle API, either 'sandbox' or 'live'.
	Environment *SourcePaddleUpdateEnvironment `default:"api" json:"environment"`
	StartDate   time.Time                      `json:"start_date"`
}

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

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

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

func (o *SourcePaddleUpdate) GetEnvironment() *SourcePaddleUpdateEnvironment {
	if o == nil {
		return nil
	}
	return o.Environment
}

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