// 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 SourceNylasUpdateAPIServer string

const (
	SourceNylasUpdateAPIServerUs SourceNylasUpdateAPIServer = "us"
	SourceNylasUpdateAPIServerEu SourceNylasUpdateAPIServer = "eu"
)

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

type SourceNylasUpdate struct {
	APIKey    string                     `json:"api_key"`
	APIServer SourceNylasUpdateAPIServer `json:"api_server"`
	EndDate   time.Time                  `json:"end_date"`
	StartDate time.Time                  `json:"start_date"`
}

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

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

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

func (o *SourceNylasUpdate) GetAPIServer() SourceNylasUpdateAPIServer {
	if o == nil {
		return SourceNylasUpdateAPIServer("")
	}
	return o.APIServer
}

func (o *SourceNylasUpdate) GetEndDate() time.Time {
	if o == nil {
		return time.Time{}
	}
	return o.EndDate
}

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