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

const (
	OnepagecrmOnepagecrm Onepagecrm = "onepagecrm"
)

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

type SourceOnepagecrm struct {
	// Enter your API Key of your API app
	Password *string `json:"password,omitempty"`
	// Enter the user ID of your API app
	Username   string     `json:"username"`
	sourceType Onepagecrm `const:"onepagecrm" json:"sourceType"`
}

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

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

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

func (o *SourceOnepagecrm) GetUsername() string {
	if o == nil {
		return ""
	}
	return o.Username
}

func (o *SourceOnepagecrm) GetSourceType() Onepagecrm {
	return OnepagecrmOnepagecrm
}
