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

// GoCardlessAPIEnvironment - Environment you are trying to connect to.
type GoCardlessAPIEnvironment string

const (
	GoCardlessAPIEnvironmentSandbox GoCardlessAPIEnvironment = "sandbox"
	GoCardlessAPIEnvironmentLive    GoCardlessAPIEnvironment = "live"
)

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

type Gocardless string

const (
	GocardlessGocardless Gocardless = "gocardless"
)

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

type SourceGocardless struct {
	// Gocardless API TOKEN
	AccessToken string `json:"access_token"`
	// Environment you are trying to connect to.
	GocardlessEnvironment *GoCardlessAPIEnvironment `default:"sandbox" json:"gocardless_environment"`
	// GoCardless version. This is a date. You can find the latest here:
	// https://developer.gocardless.com/api-reference/#api-usage-making-requests
	//
	GocardlessVersion string `json:"gocardless_version"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Any data
	// before this date will not be replicated.
	//
	StartDate  string     `json:"start_date"`
	sourceType Gocardless `const:"gocardless" json:"sourceType"`
}

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

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

func (o *SourceGocardless) GetAccessToken() string {
	if o == nil {
		return ""
	}
	return o.AccessToken
}

func (o *SourceGocardless) GetGocardlessEnvironment() *GoCardlessAPIEnvironment {
	if o == nil {
		return nil
	}
	return o.GocardlessEnvironment
}

func (o *SourceGocardless) GetGocardlessVersion() string {
	if o == nil {
		return ""
	}
	return o.GocardlessVersion
}

func (o *SourceGocardless) GetStartDate() string {
	if o == nil {
		return ""
	}
	return o.StartDate
}

func (o *SourceGocardless) GetSourceType() Gocardless {
	return GocardlessGocardless
}
