From 09271db683002ecb6603f2aefee1a22e6bf0aa66 Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Thu, 10 Oct 2024 15:51:01 +0100 Subject: [PATCH] chore: temp fix for code generation --- .fernignore | 4 +++- core/optional.go | 17 +++++++++++++++++ issue_trigger.go | 5 +++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.fernignore b/.fernignore index b703cb4..bca19bd 100644 --- a/.fernignore +++ b/.fernignore @@ -1,8 +1,10 @@ # Specify files that shouldn't be modified by Fern - README.md LICENSE # Temporarily ignored for the OptionalOrNull helper. optional.go optional_test.go + +# Temporarily ignored to fix core.Optional -> core.DateTime mapping. +issue_trigger.go diff --git a/core/optional.go b/core/optional.go index 85ab541..6e5e1eb 100644 --- a/core/optional.go +++ b/core/optional.go @@ -3,6 +3,7 @@ package core import ( "encoding/json" "fmt" + "time" ) // Optional is a wrapper used to distinguish zero values from @@ -34,3 +35,19 @@ func (o *Optional[T]) MarshalJSON() ([]byte, error) { } return json.Marshal(&o.Value) } + +// NewDateFromOptional returns a new *DateTime from the given optional. +func NewDateFromOptional(optional *Optional[time.Time]) *Date { + if optional == nil { + return nil + } + return &Date{t: &optional.Value} +} + +// NewDateTimeFromOptional returns a new *DateTime from the given optional. +func NewDateTimeFromOptional(optional *Optional[time.Time]) *DateTime { + if optional == nil { + return nil + } + return &DateTime{t: &optional.Value} +} diff --git a/issue_trigger.go b/issue_trigger.go index f23826c..7b5ef83 100644 --- a/issue_trigger.go +++ b/issue_trigger.go @@ -5,8 +5,9 @@ package api import ( json "encoding/json" fmt "fmt" - core "github.com/hookdeck/hookdeck-go-sdk/core" time "time" + + core "github.com/hookdeck/hookdeck-go-sdk/core" ) type IssueTriggerCreateRequest struct { @@ -310,7 +311,7 @@ func (i *IssueTriggerUpdateRequest) MarshalJSON() ([]byte, error) { DisabledAt *core.DateTime `json:"disabled_at,omitempty"` }{ embed: embed(*i), - DisabledAt: core.NewOptionalDateTime(i.DisabledAt), + DisabledAt: core.NewDateTimeFromOptional(i.DisabledAt), } return json.Marshal(marshaler) }