// 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"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/types"
)

// PlaidEnvironment - The Plaid environment.
type PlaidEnvironment string

const (
	PlaidEnvironmentSandbox     PlaidEnvironment = "sandbox"
	PlaidEnvironmentDevelopment PlaidEnvironment = "development"
	PlaidEnvironmentProduction  PlaidEnvironment = "production"
)

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

type Plaid string

const (
	PlaidPlaid Plaid = "plaid"
)

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

type SourcePlaid struct {
	// The end-user's Link access token.
	AccessToken string `json:"access_token"`
	// The Plaid API key to use to hit the API.
	APIKey string `json:"api_key"`
	// The Plaid client id.
	ClientID string `json:"client_id"`
	// The Plaid environment.
	PlaidEnv PlaidEnvironment `json:"plaid_env"`
	// The date from which you'd like to replicate data for Plaid in the format YYYY-MM-DD. All data generated after this date will be replicated.
	StartDate  *types.Date `json:"start_date,omitempty"`
	sourceType Plaid       `const:"plaid" json:"sourceType"`
}

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

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

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

func (o *SourcePlaid) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

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

func (o *SourcePlaid) GetPlaidEnv() PlaidEnvironment {
	if o == nil {
		return PlaidEnvironment("")
	}
	return o.PlaidEnv
}

func (o *SourcePlaid) GetStartDate() *types.Date {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourcePlaid) GetSourceType() Plaid {
	return PlaidPlaid
}
