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

const (
	WebScrapperWebScrapper WebScrapper = "web-scrapper"
)

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

type SourceWebScrapper struct {
	// API token to use. Find it at https://cloud.webscraper.io/api
	APIToken   string      `json:"api_token"`
	sourceType WebScrapper `const:"web-scrapper" json:"sourceType"`
}

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

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

func (o *SourceWebScrapper) GetAPIToken() string {
	if o == nil {
		return ""
	}
	return o.APIToken
}

func (o *SourceWebScrapper) GetSourceType() WebScrapper {
	return WebScrapperWebScrapper
}
