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

type SourceZohoBillingRegion string

const (
	SourceZohoBillingRegionCom   SourceZohoBillingRegion = "com"
	SourceZohoBillingRegionEu    SourceZohoBillingRegion = "eu"
	SourceZohoBillingRegionIn    SourceZohoBillingRegion = "in"
	SourceZohoBillingRegionComCn SourceZohoBillingRegion = "com.cn"
	SourceZohoBillingRegionComAu SourceZohoBillingRegion = "com.au"
	SourceZohoBillingRegionJp    SourceZohoBillingRegion = "jp"
	SourceZohoBillingRegionSa    SourceZohoBillingRegion = "sa"
	SourceZohoBillingRegionCa    SourceZohoBillingRegion = "ca"
)

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

type ZohoBilling string

const (
	ZohoBillingZohoBilling ZohoBilling = "zoho-billing"
)

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

type SourceZohoBilling struct {
	ClientID     string                  `json:"client_id"`
	ClientSecret string                  `json:"client_secret"`
	RefreshToken string                  `json:"refresh_token"`
	Region       SourceZohoBillingRegion `json:"region"`
	sourceType   ZohoBilling             `const:"zoho-billing" json:"sourceType"`
}

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

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

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

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

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

func (o *SourceZohoBilling) GetRegion() SourceZohoBillingRegion {
	if o == nil {
		return SourceZohoBillingRegion("")
	}
	return o.Region
}

func (o *SourceZohoBilling) GetSourceType() ZohoBilling {
	return ZohoBillingZohoBilling
}
