// 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"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/types"
)

type SonarCloud string

const (
	SonarCloudSonarCloud SonarCloud = "sonar-cloud"
)

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

type SourceSonarCloud struct {
	// Comma-separated list of component keys.
	ComponentKeys []any `json:"component_keys"`
	// To retrieve issues created before the given date (inclusive).
	EndDate *types.Date `json:"end_date,omitempty"`
	// Organization key. See <a href="https://docs.sonarcloud.io/appendices/project-information/#project-and-organization-keys">here</a>.
	Organization string `json:"organization"`
	// To retrieve issues created after the given date (inclusive).
	StartDate *types.Date `json:"start_date,omitempty"`
	// Your User Token. See <a href="https://docs.sonarcloud.io/advanced-setup/user-accounts/">here</a>. The token is case sensitive.
	UserToken  string     `json:"user_token"`
	sourceType SonarCloud `const:"sonar-cloud" json:"sourceType"`
}

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

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

func (o *SourceSonarCloud) GetComponentKeys() []any {
	if o == nil {
		return []any{}
	}
	return o.ComponentKeys
}

func (o *SourceSonarCloud) GetEndDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceSonarCloud) GetOrganization() string {
	if o == nil {
		return ""
	}
	return o.Organization
}

func (o *SourceSonarCloud) GetStartDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourceSonarCloud) GetUserToken() string {
	if o == nil {
		return ""
	}
	return o.UserToken
}

func (o *SourceSonarCloud) GetSourceType() SonarCloud {
	return SonarCloudSonarCloud
}
