// 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 SourceZohoInvoiceRegion string

const (
	SourceZohoInvoiceRegionCom   SourceZohoInvoiceRegion = "com"
	SourceZohoInvoiceRegionEu    SourceZohoInvoiceRegion = "eu"
	SourceZohoInvoiceRegionIn    SourceZohoInvoiceRegion = "in"
	SourceZohoInvoiceRegionComCn SourceZohoInvoiceRegion = "com.cn"
	SourceZohoInvoiceRegionComAu SourceZohoInvoiceRegion = "com.au"
	SourceZohoInvoiceRegionJp    SourceZohoInvoiceRegion = "jp"
	SourceZohoInvoiceRegionSa    SourceZohoInvoiceRegion = "sa"
	SourceZohoInvoiceRegionCa    SourceZohoInvoiceRegion = "ca"
)

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

type ZohoInvoice string

const (
	ZohoInvoiceZohoInvoice ZohoInvoice = "zoho-invoice"
)

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

type SourceZohoInvoice struct {
	ClientID           string `json:"client_id"`
	ClientRefreshToken string `json:"client_refresh_token"`
	ClientSecret       string `json:"client_secret"`
	// To be provided if a user belongs to multiple organizations
	OrganizationID *string                 `json:"organization_id,omitempty"`
	Region         SourceZohoInvoiceRegion `json:"region"`
	sourceType     ZohoInvoice             `const:"zoho-invoice" json:"sourceType"`
}

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

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

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

func (o *SourceZohoInvoice) GetClientRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.ClientRefreshToken
}

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

func (o *SourceZohoInvoice) GetOrganizationID() *string {
	if o == nil {
		return nil
	}
	return o.OrganizationID
}

func (o *SourceZohoInvoice) GetRegion() SourceZohoInvoiceRegion {
	if o == nil {
		return SourceZohoInvoiceRegion("")
	}
	return o.Region
}

func (o *SourceZohoInvoice) GetSourceType() ZohoInvoice {
	return ZohoInvoiceZohoInvoice
}
