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

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

const (
	SourceZohoBooksRegionCom   SourceZohoBooksRegion = "com"
	SourceZohoBooksRegionEu    SourceZohoBooksRegion = "eu"
	SourceZohoBooksRegionIn    SourceZohoBooksRegion = "in"
	SourceZohoBooksRegionComCn SourceZohoBooksRegion = "com.cn"
	SourceZohoBooksRegionComAu SourceZohoBooksRegion = "com.au"
	SourceZohoBooksRegionJp    SourceZohoBooksRegion = "jp"
	SourceZohoBooksRegionSa    SourceZohoBooksRegion = "sa"
	SourceZohoBooksRegionCa    SourceZohoBooksRegion = "ca"
)

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

type ZohoBooks string

const (
	ZohoBooksZohoBooks ZohoBooks = "zoho-books"
)

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

type SourceZohoBooks 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     SourceZohoBooksRegion `json:"region"`
	StartDate  time.Time             `json:"start_date"`
	sourceType ZohoBooks             `const:"zoho-books" json:"sourceType"`
}

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

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

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

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

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

func (o *SourceZohoBooks) GetRegion() SourceZohoBooksRegion {
	if o == nil {
		return SourceZohoBooksRegion("")
	}
	return o.Region
}

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

func (o *SourceZohoBooks) GetSourceType() ZohoBooks {
	return ZohoBooksZohoBooks
}
