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

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

const (
	SourcePhylloUpdateEnvironmentAPISandbox SourcePhylloUpdateEnvironment = "api.sandbox"
	SourcePhylloUpdateEnvironmentAPIStaging SourcePhylloUpdateEnvironment = "api.staging"
	SourcePhylloUpdateEnvironmentAPI        SourcePhylloUpdateEnvironment = "api"
)

func (e SourcePhylloUpdateEnvironment) ToPointer() *SourcePhylloUpdateEnvironment {
	return &e
}
func (e *SourcePhylloUpdateEnvironment) 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 = SourcePhylloUpdateEnvironment(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourcePhylloUpdateEnvironment: %v", v)
	}
}

type SourcePhylloUpdate 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 *SourcePhylloUpdateEnvironment `default:"api" json:"environment"`
	StartDate   time.Time                      `json:"start_date"`
}

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

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

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

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

func (o *SourcePhylloUpdate) GetEnvironment() *SourcePhylloUpdateEnvironment {
	if o == nil {
		return nil
	}
	return o.Environment
}

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