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

const (
	PrestashopPrestashop Prestashop = "prestashop"
)

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

type SourcePrestashop struct {
	// Your PrestaShop access key. See <a href="https://devdocs.prestashop.com/1.7/webservice/tutorials/creating-access/#create-an-access-key"> the docs </a> for info on how to obtain this.
	AccessKey string `json:"access_key"`
	// The Start date in the format YYYY-MM-DD.
	StartDate types.Date `json:"start_date"`
	// Shop URL without trailing slash.
	URL        string     `json:"url"`
	sourceType Prestashop `const:"prestashop" json:"sourceType"`
}

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

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

func (o *SourcePrestashop) GetAccessKey() string {
	if o == nil {
		return ""
	}
	return o.AccessKey
}

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

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

func (o *SourcePrestashop) GetSourceType() Prestashop {
	return PrestashopPrestashop
}
