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

const (
	PlausiblePlausible Plausible = "plausible"
)

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

type SourcePlausible struct {
	// Plausible API Key. See the <a href="https://plausible.io/docs/stats-api">docs</a> for information on how to generate this key.
	APIKey string `json:"api_key"`
	// The API URL of your plausible instance. Change this if you self-host plausible. The default is https://plausible.io/api/v1/stats
	APIURL *string `json:"api_url,omitempty"`
	// The domain of the site you want to retrieve data for. Enter the name of your site as configured on Plausible, i.e., excluding "https://" and "www". Can be retrieved from the 'domain' field in your Plausible site settings.
	SiteID string `json:"site_id"`
	// Start date for data to retrieve, in ISO-8601 format.
	StartDate  *string   `json:"start_date,omitempty"`
	sourceType Plausible `const:"plausible" json:"sourceType"`
}

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

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

func (o *SourcePlausible) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

func (o *SourcePlausible) GetAPIURL() *string {
	if o == nil {
		return nil
	}
	return o.APIURL
}

func (o *SourcePlausible) GetSiteID() string {
	if o == nil {
		return ""
	}
	return o.SiteID
}

func (o *SourcePlausible) GetStartDate() *string {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourcePlausible) GetSourceType() Plausible {
	return PlausiblePlausible
}
