Skip to content

Commit

Permalink
chore: temp fix for code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
leggetter committed Oct 10, 2024
1 parent f5f8dd6 commit 09271db
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .fernignore
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions core/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"encoding/json"
"fmt"
"time"
)

// Optional is a wrapper used to distinguish zero values from
Expand Down Expand Up @@ -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}
}
5 changes: 3 additions & 2 deletions issue_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 09271db

Please sign in to comment.