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

const (
	N8nN8n N8n = "n8n"
)

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

type SourceN8n struct {
	// Your API KEY. See <a href="https://docs.n8n.io/api/authentication">here</a>
	APIKey string `json:"api_key"`
	// Hostname of the n8n instance
	Host       string `json:"host"`
	sourceType N8n    `const:"n8n" json:"sourceType"`
}

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

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

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

func (o *SourceN8n) GetHost() string {
	if o == nil {
		return ""
	}
	return o.Host
}

func (o *SourceN8n) GetSourceType() N8n {
	return N8nN8n
}
