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

const (
	FlexmailFlexmail Flexmail = "flexmail"
)

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

type SourceFlexmail struct {
	// Your Flexmail account ID. You can find it in your Flexmail account settings.
	AccountID string `json:"account_id"`
	// A personal access token for API authentication. Manage your tokens in Flexmail under Settings > API > Personal access tokens.
	PersonalAccessToken string   `json:"personal_access_token"`
	sourceType          Flexmail `const:"flexmail" json:"sourceType"`
}

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

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

func (o *SourceFlexmail) GetAccountID() string {
	if o == nil {
		return ""
	}
	return o.AccountID
}

func (o *SourceFlexmail) GetPersonalAccessToken() string {
	if o == nil {
		return ""
	}
	return o.PersonalAccessToken
}

func (o *SourceFlexmail) GetSourceType() Flexmail {
	return FlexmailFlexmail
}
