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

const (
	NocrmNocrm Nocrm = "nocrm"
)

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

type SourceNocrm struct {
	// API key to use. Generate it from the admin section of your noCRM.io account.
	APIKey string `json:"api_key"`
	// The subdomain specific to your noCRM.io account, e.g., 'yourcompany' in 'yourcompany.nocrm.io'.
	Subdomain  string `json:"subdomain"`
	sourceType Nocrm  `const:"nocrm" json:"sourceType"`
}

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

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

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

func (o *SourceNocrm) GetSubdomain() string {
	if o == nil {
		return ""
	}
	return o.Subdomain
}

func (o *SourceNocrm) GetSourceType() Nocrm {
	return NocrmNocrm
}
