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

const (
	GridlyGridly Gridly = "gridly"
)

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

type SourceGridly struct {
	APIKey string `json:"api_key"`
	// ID of a grid, or can be ID of a branch
	GridID     string `json:"grid_id"`
	sourceType Gridly `const:"gridly" json:"sourceType"`
}

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

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

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

func (o *SourceGridly) GetGridID() string {
	if o == nil {
		return ""
	}
	return o.GridID
}

func (o *SourceGridly) GetSourceType() Gridly {
	return GridlyGridly
}
