Skip to content

Latest commit

 

History

History
executable file
·
314 lines (242 loc) · 13.9 KB

README.md

File metadata and controls

executable file
·
314 lines (242 loc) · 13.9 KB

Transformation

Available Operations

  • Create - Create a transformation
  • Get - Get a transformation
  • Test - Test a transformation code
  • Update - Update a transformation
  • Upsert - Update or create a transformation

Create

Create a transformation

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Transformation.Create(ctx, operations.CreateTransformationRequestBody{
        Code: "quod",
        Env: map[string]interface{}{
            "qui": "dolorum",
            "a": "esse",
            "harum": "iusto",
            "ipsum": "quisquam",
        },
        Name: "Marvin Renner",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.Transformation != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CreateTransformationRequestBody ✔️ The request object to use for the request.

Response

*operations.CreateTransformationResponse, error

Get

Get a transformation

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )
    id := "enim"

    ctx := context.Background()
    res, err := s.Transformation.Get(ctx, id)
    if err != nil {
        log.Fatal(err)
    }

    if res.Transformation != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A

Response

*operations.GetTransformationResponse, error

Test

Test a transformation code

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Transformation.Test(ctx, operations.TestTransformationRequestBody{
        Code: hookdeck.String("dolorem"),
        Env: &operations.TestTransformationRequestBodyEnv{},
        EventID: hookdeck.String("sapiente"),
        Request: &operations.TestTransformationRequestBodyRequest{
            Body: &operations.TestTransformationRequestBodyRequestBody{},
            Headers: map[string]string{
                "nihil": "sit",
                "expedita": "neque",
                "sed": "vel",
            },
            ParsedQuery: &operations.TestTransformationRequestBodyRequestParsedQuery{},
            Path: hookdeck.String("libero"),
            Query: hookdeck.String("voluptas"),
        },
        TransformationID: hookdeck.String("deserunt"),
        WebhookID: hookdeck.String("quam"),
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.TransformationExecutorOutput != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.TestTransformationRequestBody ✔️ The request object to use for the request.

Response

*operations.TestTransformationResponse, error

Update

Update a transformation

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )
    requestBody := operations.UpdateTransformationRequestBody{
        Code: hookdeck.String("ipsum"),
        Env: map[string]interface{}{
            "qui": "cupiditate",
            "maxime": "pariatur",
        },
        Name: hookdeck.String("Keith Padberg"),
    }
    id := "aspernatur"

    ctx := context.Background()
    res, err := s.Transformation.Update(ctx, requestBody, id)
    if err != nil {
        log.Fatal(err)
    }

    if res.Transformation != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
requestBody operations.UpdateTransformationRequestBody ✔️ N/A
id string ✔️ N/A

Response

*operations.UpdateTransformationResponse, error

Upsert

Update or create a transformation

Example Usage

package main

import(
	"context"
	"log"
	"github.com/speakeasy-sdks/hookdeck-go"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/shared"
	"github.com/speakeasy-sdks/hookdeck-go/pkg/models/operations"
)

func main() {
    s := hookdeck.New(
        hookdeck.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Transformation.Upsert(ctx, operations.UpsertTransformationRequestBody{
        Code: "dolores",
        Env: map[string]interface{}{
            "facilis": "aliquid",
            "quam": "molestias",
            "temporibus": "qui",
        },
        Name: "Beverly Cummerata II",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.Transformation != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.UpsertTransformationRequestBody ✔️ The request object to use for the request.

Response

*operations.UpsertTransformationResponse, error