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

// SourceZohoBooksUpdateRegion - The region code for the Zoho Books API, such as 'com', 'eu', 'in', etc.
type SourceZohoBooksUpdateRegion string

const (
	SourceZohoBooksUpdateRegionCom   SourceZohoBooksUpdateRegion = "com"
	SourceZohoBooksUpdateRegionEu    SourceZohoBooksUpdateRegion = "eu"
	SourceZohoBooksUpdateRegionIn    SourceZohoBooksUpdateRegion = "in"
	SourceZohoBooksUpdateRegionComCn SourceZohoBooksUpdateRegion = "com.cn"
	SourceZohoBooksUpdateRegionComAu SourceZohoBooksUpdateRegion = "com.au"
	SourceZohoBooksUpdateRegionJp    SourceZohoBooksUpdateRegion = "jp"
	SourceZohoBooksUpdateRegionSa    SourceZohoBooksUpdateRegion = "sa"
	SourceZohoBooksUpdateRegionCa    SourceZohoBooksUpdateRegion = "ca"
)

func (e SourceZohoBooksUpdateRegion) ToPointer() *SourceZohoBooksUpdateRegion {
	return &e
}
func (e *SourceZohoBooksUpdateRegion) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "com":
		fallthrough
	case "eu":
		fallthrough
	case "in":
		fallthrough
	case "com.cn":
		fallthrough
	case "com.au":
		fallthrough
	case "jp":
		fallthrough
	case "sa":
		fallthrough
	case "ca":
		*e = SourceZohoBooksUpdateRegion(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourceZohoBooksUpdateRegion: %v", v)
	}
}

type SourceZohoBooksUpdate struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RefreshToken string `json:"refresh_token"`
	// The region code for the Zoho Books API, such as 'com', 'eu', 'in', etc.
	Region    SourceZohoBooksUpdateRegion `json:"region"`
	StartDate time.Time                   `json:"start_date"`
}

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

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

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

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

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

func (o *SourceZohoBooksUpdate) GetRegion() SourceZohoBooksUpdateRegion {
	if o == nil {
		return SourceZohoBooksUpdateRegion("")
	}
	return o.Region
}

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