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

const (
	CategoriesAccessibility Categories = "accessibility"
	CategoriesBestPractices Categories = "best-practices"
	CategoriesPerformance   Categories = "performance"
	CategoriesPwa           Categories = "pwa"
	CategoriesSeo           Categories = "seo"
)

func (e Categories) ToPointer() *Categories {
	return &e
}
func (e *Categories) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "accessibility":
		fallthrough
	case "best-practices":
		fallthrough
	case "performance":
		fallthrough
	case "pwa":
		fallthrough
	case "seo":
		*e = Categories(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Categories: %v", v)
	}
}

type Strategies string

const (
	StrategiesDesktop Strategies = "desktop"
	StrategiesMobile  Strategies = "mobile"
)

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

type GooglePagespeedInsights string

const (
	GooglePagespeedInsightsGooglePagespeedInsights GooglePagespeedInsights = "google-pagespeed-insights"
)

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

type SourceGooglePagespeedInsights struct {
	// Google PageSpeed API Key. See <a href="https://developers.google.com/speed/docs/insights/v5/get-started#APIKey">here</a>. The key is optional - however the API is heavily rate limited when using without API Key. Creating and using the API key therefore is recommended. The key is case sensitive.
	APIKey *string `json:"api_key,omitempty"`
	// Defines which Lighthouse category to run. One or many of: "accessibility", "best-practices", "performance", "pwa", "seo".
	Categories []Categories `json:"categories"`
	// The analyses strategy to use. Either "desktop" or "mobile".
	Strategies []Strategies `json:"strategies"`
	// The URLs to retrieve pagespeed information from. The connector will attempt to sync PageSpeed reports for all the defined URLs. Format: https://(www.)url.domain
	Urls       []string                `json:"urls"`
	sourceType GooglePagespeedInsights `const:"google-pagespeed-insights" json:"sourceType"`
}

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

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

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

func (o *SourceGooglePagespeedInsights) GetCategories() []Categories {
	if o == nil {
		return []Categories{}
	}
	return o.Categories
}

func (o *SourceGooglePagespeedInsights) GetStrategies() []Strategies {
	if o == nil {
		return []Strategies{}
	}
	return o.Strategies
}

func (o *SourceGooglePagespeedInsights) GetUrls() []string {
	if o == nil {
		return []string{}
	}
	return o.Urls
}

func (o *SourceGooglePagespeedInsights) GetSourceType() GooglePagespeedInsights {
	return GooglePagespeedInsightsGooglePagespeedInsights
}
