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

const (
	ConfigcatConfigcat Configcat = "configcat"
)

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

type SourceConfigcat struct {
	// Basic auth password. See <a href="https://api.configcat.com/docs/#section/Authentication">here</a>.
	Password string `json:"password"`
	// Basic auth user name. See <a href="https://api.configcat.com/docs/#section/Authentication">here</a>.
	Username   string    `json:"username"`
	sourceType Configcat `const:"configcat" json:"sourceType"`
}

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

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

func (o *SourceConfigcat) GetPassword() string {
	if o == nil {
		return ""
	}
	return o.Password
}

func (o *SourceConfigcat) GetUsername() string {
	if o == nil {
		return ""
	}
	return o.Username
}

func (o *SourceConfigcat) GetSourceType() Configcat {
	return ConfigcatConfigcat
}
