// 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"
	"time"
)

type Algolia string

const (
	AlgoliaAlgolia Algolia = "algolia"
)

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

type SourceAlgolia struct {
	APIKey string `json:"api_key"`
	// The application ID for your application found in settings
	ApplicationID string `json:"application_id"`
	// Object ID within index for search queries
	ObjectID *string `default:"ecommerce-sample-data-9999996" json:"object_id"`
	// Search query to be used with indexes_query stream with format defined in `https://www.algolia.com/doc/rest-api/search/#tag/Search/operation/searchSingleIndex`
	SearchQuery *string   `default:"hitsPerPage=2&getRankingInfo=1" json:"search_query"`
	StartDate   time.Time `json:"start_date"`
	sourceType  Algolia   `const:"algolia" json:"sourceType"`
}

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

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

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

func (o *SourceAlgolia) GetApplicationID() string {
	if o == nil {
		return ""
	}
	return o.ApplicationID
}

func (o *SourceAlgolia) GetObjectID() *string {
	if o == nil {
		return nil
	}
	return o.ObjectID
}

func (o *SourceAlgolia) GetSearchQuery() *string {
	if o == nil {
		return nil
	}
	return o.SearchQuery
}

func (o *SourceAlgolia) GetStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate
}

func (o *SourceAlgolia) GetSourceType() Algolia {
	return AlgoliaAlgolia
}
