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

const (
	TodoistTodoist Todoist = "todoist"
)

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

type SourceTodoist struct {
	// API authorization bearer token for authenticating the API
	Token      string  `json:"token"`
	sourceType Todoist `const:"todoist" json:"sourceType"`
}

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

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

func (o *SourceTodoist) GetToken() string {
	if o == nil {
		return ""
	}
	return o.Token
}

func (o *SourceTodoist) GetSourceType() Todoist {
	return TodoistTodoist
}
