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

// SourcePhylloEnvironment - The environment for the API (e.g., 'api.sandbox', 'api.staging', 'api')
type SourcePhylloEnvironment string

const (
	SourcePhylloEnvironmentAPISandbox SourcePhylloEnvironment = "api.sandbox"
	SourcePhylloEnvironmentAPIStaging SourcePhylloEnvironment = "api.staging"
	SourcePhylloEnvironmentAPI        SourcePhylloEnvironment = "api"
)

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

type Phyllo string

const (
	PhylloPhyllo Phyllo = "phyllo"
)

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

type SourcePhyllo struct {
	// Your Client ID for the Phyllo API. You can find this in the Phyllo Developer Dashboard under API credentials.
	ClientID string `json:"client_id"`
	// Your Client Secret for the Phyllo API. You can find this in the Phyllo Developer Dashboard under API credentials.
	ClientSecret string `json:"client_secret"`
	// The environment for the API (e.g., 'api.sandbox', 'api.staging', 'api')
	Environment *SourcePhylloEnvironment `default:"api" json:"environment"`
	StartDate   time.Time                `json:"start_date"`
	sourceType  Phyllo                   `const:"phyllo" json:"sourceType"`
}

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

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

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

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

func (o *SourcePhyllo) GetEnvironment() *SourcePhylloEnvironment {
	if o == nil {
		return nil
	}
	return o.Environment
}

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

func (o *SourcePhyllo) GetSourceType() Phyllo {
	return PhylloPhyllo
}
