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

type Easypost string

const (
	EasypostEasypost Easypost = "easypost"
)

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

type SourceEasypost struct {
	StartDate time.Time `json:"start_date"`
	// The API Key from your easypost settings
	Username   string   `json:"username"`
	sourceType Easypost `const:"easypost" json:"sourceType"`
}

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

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

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

func (o *SourceEasypost) GetUsername() string {
	if o == nil {
		return ""
	}
	return o.Username
}

func (o *SourceEasypost) GetSourceType() Easypost {
	return EasypostEasypost
}
