Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 168
configured_endpoints: 169
2 changes: 1 addition & 1 deletion gosdk/.stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 168
configured_endpoints: 169
10 changes: 10 additions & 0 deletions gosdk/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,16 @@ Methods:
- <code title="get /digests/schedules/{schedule_id}/instances">client.Digests.Schedules.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#DigestScheduleService.ListInstances">ListInstances</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, scheduleID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4">courier</a>.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#DigestScheduleListInstancesParams">DigestScheduleListInstancesParams</a>) (\*<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4">courier</a>.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#DigestInstanceListResponse">DigestInstanceListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /digests/schedules/{schedule_id}/trigger">client.Digests.Schedules.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#DigestScheduleService.Release">Release</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, scheduleID <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>

# Feedback

Response Types:

- <a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4">courier</a>.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#FeedbackNewResponse">FeedbackNewResponse</a>

Methods:

- <code title="post /feedback">client.Feedback.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#FeedbackService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4">courier</a>.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#FeedbackNewParams">FeedbackNewParams</a>) (\*<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4">courier</a>.<a href="https://pkg.go.dev/github.com/trycourier/courier-go/v4#FeedbackNewResponse">FeedbackNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Inbound

Response Types:
Expand Down
4 changes: 4 additions & 0 deletions gosdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type Client struct {
// consistent look.
Brands BrandService
Digests DigestService
// Report suspected bugs, confusing behavior and missing features in Courier, from
// an AI agent, a developer tool or by hand.
Feedback FeedbackService
// Record an inbound event that triggers the journeys and automations mapped to it.
Inbound InboundService
// Manage static groups of users that you subscribe explicitly, and send to them by
Expand Down Expand Up @@ -124,6 +127,7 @@ func NewClient(opts ...option.RequestOption) (r Client) {
r.Bulk = NewBulkService(opts...)
r.Brands = NewBrandService(opts...)
r.Digests = NewDigestService(opts...)
r.Feedback = NewFeedbackService(opts...)
r.Inbound = NewInboundService(opts...)
r.Lists = NewListService(opts...)
r.Messages = NewMessageService(opts...)
Expand Down
138 changes: 138 additions & 0 deletions gosdk/feedback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package courier

import (
"context"
"net/http"
"slices"

"github.com/trycourier/courier-go/v4/internal/apijson"
"github.com/trycourier/courier-go/v4/internal/requestconfig"
"github.com/trycourier/courier-go/v4/option"
"github.com/trycourier/courier-go/v4/packages/param"
"github.com/trycourier/courier-go/v4/packages/respjson"
)

// Report suspected bugs, confusing behavior and missing features in Courier, from
// an AI agent, a developer tool or by hand.
//
// FeedbackService contains methods and other services that help with interacting
// with the Courier API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewFeedbackService] method instead.
type FeedbackService struct {
Options []option.RequestOption
}

// NewFeedbackService generates a new service that applies the given options to
// each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewFeedbackService(opts ...option.RequestOption) (r FeedbackService) {
r = FeedbackService{}
r.Options = opts
return
}

// Reports a suspected bug, confusing behavior or a missing feature in Courier. It
// is built for AI agents and developer tools to call when Courier does something
// unexpected, and people can call it too.
//
// A report is not a support ticket. A `201` means Courier stored the report; it
// does not promise a reply or a fix. For help with your account, contact Courier
// support.
//
// Never include secrets, API keys or customer data such as recipient names, email
// addresses or message content.
//
// Requires an API key with no scope restrictions; a JWT or a scoped API key is
// refused. Each workspace can submit 200 reports per UTC day, and requests that
// fail validation count toward that limit.
func (r *FeedbackService) New(ctx context.Context, body FeedbackNewParams, opts ...option.RequestOption) (res *FeedbackNewResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "feedback"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}

type FeedbackNewResponse struct {
// The ID of the stored report, `fbk_` followed by a ULID.
FeedbackID string `json:"feedback_id" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
FeedbackID respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r FeedbackNewResponse) RawJSON() string { return r.JSON.raw }
func (r *FeedbackNewResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type FeedbackNewParams struct {
// What kind of report this is: `possible_bug` for behavior that looks wrong,
// `confusing_behavior` for behavior that works but was hard to understand,
// `feature_request` for something Courier does not do yet, and `other`.
//
// Any of "possible_bug", "confusing_behavior", "feature_request", "other".
Category FeedbackNewParamsCategory `json:"category,omitzero" api:"required"`
// What happened, in enough detail for someone at Courier to follow it.
Description string `json:"description" api:"required"`
// Where you met the problem: the REST `api`, an `sdk`, the Courier `mcp` server,
// the Courier app `ui`, the `docs`, or `other`.
//
// Any of "api", "sdk", "mcp", "ui", "docs", "other".
Surface FeedbackNewParamsSurface `json:"surface,omitzero" api:"required"`
// A one-line summary of the report.
Title string `json:"title" api:"required"`
// What you expected to happen instead.
ExpectedBehavior param.Opt[string] `json:"expected_behavior,omitzero"`
// The agent or tool that submitted the report, such as `Claude Code`.
Harness param.Opt[string] `json:"harness,omitzero"`
// Where it happened, such as an endpoint (`POST /send`), an SDK method, an MCP
// tool name or a docs URL.
Location param.Opt[string] `json:"location,omitzero"`
// The AI model that submitted the report, such as `claude-opus-5-5`.
Model param.Opt[string] `json:"model,omitzero"`
// The request ID of an API call that shows the problem, if there is one.
RequestID param.Opt[string] `json:"request_id,omitzero"`
paramObj
}

func (r FeedbackNewParams) MarshalJSON() (data []byte, err error) {
type shadow FeedbackNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FeedbackNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// What kind of report this is: `possible_bug` for behavior that looks wrong,
// `confusing_behavior` for behavior that works but was hard to understand,
// `feature_request` for something Courier does not do yet, and `other`.
type FeedbackNewParamsCategory string

const (
FeedbackNewParamsCategoryPossibleBug FeedbackNewParamsCategory = "possible_bug"
FeedbackNewParamsCategoryConfusingBehavior FeedbackNewParamsCategory = "confusing_behavior"
FeedbackNewParamsCategoryFeatureRequest FeedbackNewParamsCategory = "feature_request"
FeedbackNewParamsCategoryOther FeedbackNewParamsCategory = "other"
)

// Where you met the problem: the REST `api`, an `sdk`, the Courier `mcp` server,
// the Courier app `ui`, the `docs`, or `other`.
type FeedbackNewParamsSurface string

const (
FeedbackNewParamsSurfaceAPI FeedbackNewParamsSurface = "api"
FeedbackNewParamsSurfaceSDK FeedbackNewParamsSurface = "sdk"
FeedbackNewParamsSurfaceMcp FeedbackNewParamsSurface = "mcp"
FeedbackNewParamsSurfaceUi FeedbackNewParamsSurface = "ui"
FeedbackNewParamsSurfaceDocs FeedbackNewParamsSurface = "docs"
FeedbackNewParamsSurfaceOther FeedbackNewParamsSurface = "other"
)
47 changes: 47 additions & 0 deletions gosdk/feedback_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package courier_test

import (
"context"
"errors"
"os"
"testing"

"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/internal/testutil"
"github.com/trycourier/courier-go/v4/option"
)

func TestFeedbackNewWithOptionalParams(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := courier.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
_, err := client.Feedback.New(context.TODO(), courier.FeedbackNewParams{
Category: courier.FeedbackNewParamsCategoryPossibleBug,
Description: "GET /lists/{list_id}/subscriptions returned items: [] with paging.more set to true, and following the cursor returned the remaining subscribers.",
Surface: courier.FeedbackNewParamsSurfaceAPI,
Title: "List subscriptions returns an empty page with a next cursor",
ExpectedBehavior: courier.String("Every page before the last one contains at least one item."),
Harness: courier.String("Claude Code"),
Location: courier.String("GET /lists/{list_id}/subscriptions"),
Model: courier.String("claude-opus-5-5"),
RequestID: courier.String("1-67f340b1-58b7b231d9485ef0cda0a38b"),
})
if err != nil {
var apierr *courier.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
8 changes: 8 additions & 0 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ func init() {
&digestsSchedulesRelease,
},
},
{
Name: "feedback",
Category: "API RESOURCE",
Suggest: true,
Commands: []*cli.Command{
&feedbackCreate,
},
},
{
Name: "inbound",
Category: "API RESOURCE",
Expand Down
115 changes: 115 additions & 0 deletions pkg/cmd/feedback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package cmd

import (
"context"
"fmt"

"github.com/tidwall/gjson"
"github.com/trycourier/courier-cli/v6/internal/apiquery"
"github.com/trycourier/courier-cli/v6/internal/requestflag"
"github.com/trycourier/courier-go/v4"
"github.com/trycourier/courier-go/v4/option"
"github.com/urfave/cli/v3"
)

var feedbackCreate = cli.Command{
Name: "create",
Usage: "Reports a suspected bug, confusing behavior or a missing feature in Courier. It\nis built for AI agents and developer tools to call when Courier does something\nunexpected, and people can call it too.",
Suggest: true,
Flags: []cli.Flag{
&requestflag.Flag[string]{
Name: "category",
Usage: "What kind of report this is: `possible_bug` for behavior that looks wrong, `confusing_behavior` for behavior that works but was hard to understand, `feature_request` for something Courier does not do yet, and `other`.",
Required: true,
BodyPath: "category",
},
&requestflag.Flag[string]{
Name: "description",
Usage: "What happened, in enough detail for someone at Courier to follow it.",
Required: true,
BodyPath: "description",
},
&requestflag.Flag[string]{
Name: "surface",
Usage: "Where you met the problem: the REST `api`, an `sdk`, the Courier `mcp` server, the Courier app `ui`, the `docs`, or `other`.",
Required: true,
BodyPath: "surface",
},
&requestflag.Flag[string]{
Name: "title",
Usage: "A one-line summary of the report.",
Required: true,
BodyPath: "title",
},
&requestflag.Flag[string]{
Name: "expected-behavior",
Usage: "What you expected to happen instead.",
BodyPath: "expected_behavior",
},
&requestflag.Flag[string]{
Name: "harness",
Usage: "The agent or tool that submitted the report, such as `Claude Code`.",
BodyPath: "harness",
},
&requestflag.Flag[string]{
Name: "location",
Usage: "Where it happened, such as an endpoint (`POST /send`), an SDK method, an MCP tool name or a docs URL.",
BodyPath: "location",
},
&requestflag.Flag[string]{
Name: "model",
Usage: "The AI model that submitted the report, such as `claude-opus-5-5`.",
BodyPath: "model",
},
&requestflag.Flag[string]{
Name: "request-id",
Usage: "The request ID of an API call that shows the problem, if there is one.",
BodyPath: "request_id",
},
},
Action: handleFeedbackCreate,
HideHelpCommand: true,
}

func handleFeedbackCreate(ctx context.Context, cmd *cli.Command) error {
client := courier.NewClient(getDefaultRequestOptions(cmd)...)
unusedArgs := cmd.Args().Slice()

if len(unusedArgs) > 0 {
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
}

options, err := flagOptions(
cmd,
apiquery.NestedQueryFormatBrackets,
apiquery.ArrayQueryFormatComma,
ApplicationJSON,
false,
)
if err != nil {
return err
}

params := courier.FeedbackNewParams{}

var res []byte
options = append(options, option.WithResponseBodyInto(&res))
_, err = client.Feedback.New(ctx, params, options...)
if err != nil {
return err
}

obj := gjson.ParseBytes(res)
format := cmd.Root().String("format")
explicitFormat := cmd.Root().IsSet("format")
transform := cmd.Root().String("transform")
return ShowJSON(obj, ShowJSONOpts{
ExplicitFormat: explicitFormat,
Format: format,
RawOutput: cmd.Root().Bool("raw-output"),
Title: "feedback create",
Transform: transform,
})
}
Loading
Loading