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

const (
	SourceCapsuleCrmUpdateEntityParties       SourceCapsuleCrmUpdateEntity = "parties"
	SourceCapsuleCrmUpdateEntityOpportunities SourceCapsuleCrmUpdateEntity = "opportunities"
	SourceCapsuleCrmUpdateEntityKases         SourceCapsuleCrmUpdateEntity = "kases"
)

func (e SourceCapsuleCrmUpdateEntity) ToPointer() *SourceCapsuleCrmUpdateEntity {
	return &e
}
func (e *SourceCapsuleCrmUpdateEntity) 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 = SourceCapsuleCrmUpdateEntity(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceCapsuleCrmUpdateEntity: %v", v)
	}
}

type SourceCapsuleCrmUpdate 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      SourceCapsuleCrmUpdateEntity `json:"entity"`
	StartDate   time.Time                    `json:"start_date"`
}

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

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

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

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

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