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

const (
	ChargifyChargify Chargify = "chargify"
)

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

type SourceChargify struct {
	// Maxio Advanced Billing/Chargify API Key.
	APIKey string `json:"api_key"`
	// Chargify domain. Normally this domain follows the following format
	Domain     string   `json:"domain"`
	Password   *string  `json:"password,omitempty"`
	Username   string   `json:"username"`
	sourceType Chargify `const:"chargify" json:"sourceType"`
}

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

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

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

func (o *SourceChargify) GetDomain() string {
	if o == nil {
		return ""
	}
	return o.Domain
}

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

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

func (o *SourceChargify) GetSourceType() Chargify {
	return ChargifyChargify
}
