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

type SourceTremendousEnvironment string

const (
	SourceTremendousEnvironmentAPI        SourceTremendousEnvironment = "api"
	SourceTremendousEnvironmentTestflight SourceTremendousEnvironment = "testflight"
)

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

type Tremendous string

const (
	TremendousTremendous Tremendous = "tremendous"
)

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

type SourceTremendous struct {
	// API key to use. You can generate an API key through the Tremendous dashboard under Team Settings > Developers. Save the key once you’ve generated it.
	APIKey      string                      `json:"api_key"`
	Environment SourceTremendousEnvironment `json:"environment"`
	sourceType  Tremendous                  `const:"tremendous" json:"sourceType"`
}

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

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

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

func (o *SourceTremendous) GetEnvironment() SourceTremendousEnvironment {
	if o == nil {
		return SourceTremendousEnvironment("")
	}
	return o.Environment
}

func (o *SourceTremendous) GetSourceType() Tremendous {
	return TremendousTremendous
}
