Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Dec 11, 2024
1 parent 592e6c0 commit ba96c66
Show file tree
Hide file tree
Showing 5 changed files with 409 additions and 20 deletions.
17 changes: 0 additions & 17 deletions core/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package core
import (
"encoding/json"
"fmt"
"time"
)

// Optional is a wrapper used to distinguish zero values from
Expand Down Expand Up @@ -35,19 +34,3 @@ 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: 2 additions & 3 deletions issue_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ package api
import (
json "encoding/json"
fmt "fmt"
time "time"

core "github.com/hookdeck/hookdeck-go-sdk/core"
time "time"
)

type IssueTriggerCreateRequest struct {
Expand Down Expand Up @@ -311,7 +310,7 @@ func (i *IssueTriggerUpdateRequest) MarshalJSON() ([]byte, error) {
DisabledAt *core.DateTime `json:"disabled_at,omitempty"`
}{
embed: embed(*i),
DisabledAt: core.NewDateTimeFromOptional(i.DisabledAt),
DisabledAt: core.NewOptionalDateTime(i.DisabledAt),

Check failure on line 313 in issue_trigger.go

View workflow job for this annotation

GitHub Actions / test

cannot use i.DisabledAt (variable of type *core.Optional[time.Time]) as *time.Time value in argument to core.NewOptionalDateTime

Check failure on line 313 in issue_trigger.go

View workflow job for this annotation

GitHub Actions / compile

cannot use i.DisabledAt (variable of type *core.Optional[time.Time]) as *time.Time value in argument to core.NewOptionalDateTime
}
return json.Marshal(marshaler)
}
Expand Down
42 changes: 42 additions & 0 deletions transformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,48 @@ type TransformationRunRequest struct {
EventId *core.Optional[string] `json:"event_id,omitempty" url:"-"`
}

type TransformationDeleteResponse struct {
// ID of the Transformation
Id string `json:"id" url:"id"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
}

func (t *TransformationDeleteResponse) GetExtraProperties() map[string]interface{} {
return t.extraProperties
}

func (t *TransformationDeleteResponse) UnmarshalJSON(data []byte) error {
type unmarshaler TransformationDeleteResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*t = TransformationDeleteResponse(value)

extraProperties, err := core.ExtractExtraProperties(data, *t)
if err != nil {
return err
}
t.extraProperties = extraProperties

t._rawJSON = json.RawMessage(data)
return nil
}

func (t *TransformationDeleteResponse) String() string {
if len(t._rawJSON) > 0 {
if value, err := core.StringifyJSON(t._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(t); err == nil {
return value
}
return fmt.Sprintf("%#v", t)
}

type TransformationListExecutionRequestDir string

const (
Expand Down
57 changes: 57 additions & 0 deletions transformation/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,63 @@ func (c *Client) Update(
return response, nil
}

func (c *Client) Delete(
ctx context.Context,
id string,
opts ...option.RequestOption,
) (*hookdeckgosdk.TransformationDeleteResponse, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.hookdeck.com/2024-09-01"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := core.EncodeURL(baseURL+"/transformations/%v", id)

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 404:
value := new(hookdeckgosdk.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *hookdeckgosdk.TransformationDeleteResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodDelete,
MaxAttempts: options.MaxAttempts,
Headers: headers,
BodyProperties: options.BodyProperties,
QueryParameters: options.QueryParameters,
Client: options.HTTPClient,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}

func (c *Client) Run(
ctx context.Context,
request *hookdeckgosdk.TransformationRunRequest,
Expand Down
Loading

0 comments on commit ba96c66

Please sign in to comment.