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

// SourceYousignSubdomain - The subdomain for the Yousign API environment, such as 'sandbox' or 'api'.
type SourceYousignSubdomain string

const (
	SourceYousignSubdomainAPISandbox SourceYousignSubdomain = "api-sandbox"
	SourceYousignSubdomainAPI        SourceYousignSubdomain = "api"
)

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

type Yousign string

const (
	YousignYousign Yousign = "yousign"
)

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

type SourceYousign struct {
	// API key or access token
	APIKey string `json:"api_key"`
	// Limit for each response objects
	Limit     *string   `default:"10" json:"limit"`
	StartDate time.Time `json:"start_date"`
	// The subdomain for the Yousign API environment, such as 'sandbox' or 'api'.
	Subdomain  *SourceYousignSubdomain `default:"api" json:"subdomain"`
	sourceType Yousign                 `const:"yousign" json:"sourceType"`
}

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

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

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

func (o *SourceYousign) GetLimit() *string {
	if o == nil {
		return nil
	}
	return o.Limit
}

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

func (o *SourceYousign) GetSubdomain() *SourceYousignSubdomain {
	if o == nil {
		return nil
	}
	return o.Subdomain
}

func (o *SourceYousign) GetSourceType() Yousign {
	return YousignYousign
}
