// 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"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/types"
)

type CloseCom string

const (
	CloseComCloseCom CloseCom = "close-com"
)

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

type SourceCloseCom struct {
	// Close.com API key (usually starts with 'api_'; find yours <a href="https://app.close.com/settings/api/">here</a>).
	APIKey string `json:"api_key"`
	// The start date to sync data; all data after this date will be replicated. Leave blank to retrieve all the data available in the account. Format: YYYY-MM-DD.
	StartDate  *types.Date `default:"2021-01-01" json:"start_date"`
	sourceType CloseCom    `const:"close-com" json:"sourceType"`
}

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

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

func (o *SourceCloseCom) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

func (o *SourceCloseCom) GetStartDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourceCloseCom) GetSourceType() CloseCom {
	return CloseComCloseCom
}
