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

const (
	MicrosoftDataverseMicrosoftDataverse MicrosoftDataverse = "microsoft-dataverse"
)

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

type SourceMicrosoftDataverse struct {
	// App Registration Client Id
	ClientID string `json:"client_id"`
	// App Registration Client Secret
	ClientSecretValue string `json:"client_secret_value"`
	// Max number of results per page. Default=5000
	OdataMaxpagesize *int64 `default:"5000" json:"odata_maxpagesize"`
	// Tenant Id of your Microsoft Dataverse Instance
	TenantID string `json:"tenant_id"`
	// URL to Microsoft Dataverse API
	URL        string             `json:"url"`
	sourceType MicrosoftDataverse `const:"microsoft-dataverse" json:"sourceType"`
}

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

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

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

func (o *SourceMicrosoftDataverse) GetClientSecretValue() string {
	if o == nil {
		return ""
	}
	return o.ClientSecretValue
}

func (o *SourceMicrosoftDataverse) GetOdataMaxpagesize() *int64 {
	if o == nil {
		return nil
	}
	return o.OdataMaxpagesize
}

func (o *SourceMicrosoftDataverse) GetTenantID() string {
	if o == nil {
		return ""
	}
	return o.TenantID
}

func (o *SourceMicrosoftDataverse) GetURL() string {
	if o == nil {
		return ""
	}
	return o.URL
}

func (o *SourceMicrosoftDataverse) GetSourceType() MicrosoftDataverse {
	return MicrosoftDataverseMicrosoftDataverse
}
