// 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"
	"time"
)

// SourceDwollaEnvironment - The environment for the Dwolla API, either 'api-sandbox' or 'api'.
type SourceDwollaEnvironment string

const (
	SourceDwollaEnvironmentAPI        SourceDwollaEnvironment = "api"
	SourceDwollaEnvironmentAPISandbox SourceDwollaEnvironment = "api-sandbox"
)

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

type Dwolla string

const (
	DwollaDwolla Dwolla = "dwolla"
)

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

type SourceDwolla struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	// The environment for the Dwolla API, either 'api-sandbox' or 'api'.
	Environment *SourceDwollaEnvironment `default:"api" json:"environment"`
	StartDate   time.Time                `json:"start_date"`
	sourceType  Dwolla                   `const:"dwolla" json:"sourceType"`
}

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

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

func (o *SourceDwolla) GetClientID() string {
	if o == nil {
		return ""
	}
	return o.ClientID
}

func (o *SourceDwolla) GetClientSecret() string {
	if o == nil {
		return ""
	}
	return o.ClientSecret
}

func (o *SourceDwolla) GetEnvironment() *SourceDwollaEnvironment {
	if o == nil {
		return nil
	}
	return o.Environment
}

func (o *SourceDwolla) GetStartDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.StartDate
}

func (o *SourceDwolla) GetSourceType() Dwolla {
	return DwollaDwolla
}
