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

const (
	CodaCoda Coda = "coda"
)

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

type SourceCoda struct {
	// Bearer token
	AuthToken  string `json:"auth_token"`
	sourceType Coda   `const:"coda" json:"sourceType"`
}

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

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

func (o *SourceCoda) GetAuthToken() string {
	if o == nil {
		return ""
	}
	return o.AuthToken
}

func (o *SourceCoda) GetSourceType() Coda {
	return CodaCoda
}
