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

type Entity string

const (
	EntityParties       Entity = "parties"
	EntityOpportunities Entity = "opportunities"
	EntityKases         Entity = "kases"
)

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

type CapsuleCrm string

const (
	CapsuleCrmCapsuleCrm CapsuleCrm = "capsule-crm"
)

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

type SourceCapsuleCrm struct {
	// Bearer token to authenticate API requests. Generate it from the 'My Preferences' > 'API Authentication Tokens' page in your Capsule account.
	BearerToken string     `json:"bearer_token"`
	Entity      Entity     `json:"entity"`
	StartDate   time.Time  `json:"start_date"`
	sourceType  CapsuleCrm `const:"capsule-crm" json:"sourceType"`
}

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

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

func (o *SourceCapsuleCrm) GetBearerToken() string {
	if o == nil {
		return ""
	}
	return o.BearerToken
}

func (o *SourceCapsuleCrm) GetEntity() Entity {
	if o == nil {
		return Entity("")
	}
	return o.Entity
}

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

func (o *SourceCapsuleCrm) GetSourceType() CapsuleCrm {
	return CapsuleCrmCapsuleCrm
}
