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

// DataCenterLocation - Please choose the region of your Data Center location. More info by this <a href="https://www.zoho.com/crm/developer/docs/api/v2/multi-dc.html">Link</a>
type DataCenterLocation string

const (
	DataCenterLocationUs DataCenterLocation = "US"
	DataCenterLocationAu DataCenterLocation = "AU"
	DataCenterLocationEu DataCenterLocation = "EU"
	DataCenterLocationIn DataCenterLocation = "IN"
	DataCenterLocationCn DataCenterLocation = "CN"
	DataCenterLocationJp DataCenterLocation = "JP"
)

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

// ZohoCRMEdition - Choose your Edition of Zoho CRM to determine API Concurrency Limits
type ZohoCRMEdition string

const (
	ZohoCRMEditionFree         ZohoCRMEdition = "Free"
	ZohoCRMEditionStandard     ZohoCRMEdition = "Standard"
	ZohoCRMEditionProfessional ZohoCRMEdition = "Professional"
	ZohoCRMEditionEnterprise   ZohoCRMEdition = "Enterprise"
	ZohoCRMEditionUltimate     ZohoCRMEdition = "Ultimate"
)

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

// SourceZohoCrmEnvironment - Please choose the environment
type SourceZohoCrmEnvironment string

const (
	SourceZohoCrmEnvironmentProduction SourceZohoCrmEnvironment = "Production"
	SourceZohoCrmEnvironmentDeveloper  SourceZohoCrmEnvironment = "Developer"
	SourceZohoCrmEnvironmentSandbox    SourceZohoCrmEnvironment = "Sandbox"
)

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

type ZohoCrm string

const (
	ZohoCrmZohoCrm ZohoCrm = "zoho-crm"
)

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

type SourceZohoCrm struct {
	// OAuth2.0 Client ID
	ClientID string `json:"client_id"`
	// OAuth2.0 Client Secret
	ClientSecret string `json:"client_secret"`
	// Please choose the region of your Data Center location. More info by this <a href="https://www.zoho.com/crm/developer/docs/api/v2/multi-dc.html">Link</a>
	DcRegion DataCenterLocation `json:"dc_region"`
	// Choose your Edition of Zoho CRM to determine API Concurrency Limits
	Edition *ZohoCRMEdition `default:"Free" json:"edition"`
	// Please choose the environment
	Environment SourceZohoCrmEnvironment `json:"environment"`
	// OAuth2.0 Refresh Token
	RefreshToken string `json:"refresh_token"`
	// ISO 8601, for instance: `YYYY-MM-DD`, `YYYY-MM-DD HH:MM:SS+HH:MM`
	StartDatetime *time.Time `json:"start_datetime,omitempty"`
	sourceType    ZohoCrm    `const:"zoho-crm" json:"sourceType"`
}

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

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

func (o *SourceZohoCrm) GetClientID() string {
	if o == nil {
		return ""
	}
	return o.ClientID
}

func (o *SourceZohoCrm) GetClientSecret() string {
	if o == nil {
		return ""
	}
	return o.ClientSecret
}

func (o *SourceZohoCrm) GetDcRegion() DataCenterLocation {
	if o == nil {
		return DataCenterLocation("")
	}
	return o.DcRegion
}

func (o *SourceZohoCrm) GetEdition() *ZohoCRMEdition {
	if o == nil {
		return nil
	}
	return o.Edition
}

func (o *SourceZohoCrm) GetEnvironment() SourceZohoCrmEnvironment {
	if o == nil {
		return SourceZohoCrmEnvironment("")
	}
	return o.Environment
}

func (o *SourceZohoCrm) GetRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.RefreshToken
}

func (o *SourceZohoCrm) GetStartDatetime() *time.Time {
	if o == nil {
		return nil
	}
	return o.StartDatetime
}

func (o *SourceZohoCrm) GetSourceType() ZohoCrm {
	return ZohoCrmZohoCrm
}
