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

const (
	OnfleetOnfleet Onfleet = "onfleet"
)

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

type SourceOnfleet struct {
	// API key to use for authenticating requests. You can create and manage your API keys in the API section of the Onfleet dashboard.
	APIKey string `json:"api_key"`
	// Placeholder for basic HTTP auth password - should be set to empty string
	Password   *string `default:"x" json:"password"`
	sourceType Onfleet `const:"onfleet" json:"sourceType"`
}

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

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

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

func (o *SourceOnfleet) GetPassword() *string {
	if o == nil {
		return nil
	}
	return o.Password
}

func (o *SourceOnfleet) GetSourceType() Onfleet {
	return OnfleetOnfleet
}
