Repository navigation
Expand file tree
/
Copy pathfeedback.go
More file actions
132 lines (118 loc) · 5.15 KB
/
Copy pathfeedback.go
File metadata and controls
132 lines (118 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package contextdev
import (
"context"
"net/http"
"slices"
"github.com/context-dot-dev/context-go-sdk/v2/internal/apijson"
"github.com/context-dot-dev/context-go-sdk/v2/internal/requestconfig"
"github.com/context-dot-dev/context-go-sdk/v2/option"
"github.com/context-dot-dev/context-go-sdk/v2/packages/param"
"github.com/context-dot-dev/context-go-sdk/v2/packages/respjson"
)
// Report API issues and documentation mismatches.
//
// FeedbackService contains methods and other services that help with interacting
// with the context.dev 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
}
// Report an API issue or documentation mismatch, including request IDs when
// available.
func (r *FeedbackService) Submit(ctx context.Context, body FeedbackSubmitParams, opts ...option.RequestOption) (res *FeedbackSubmitResponse, err error) {
opts = slices.Concat(r.options, opts)
path := "feedback"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
type FeedbackSubmitResponse struct {
// True when feedback for this request_id was already recorded; the original
// feedback_id is returned.
AlreadySubmitted bool `json:"already_submitted" api:"required"`
// ID of the stored feedback.
FeedbackID string `json:"feedback_id" api:"required"`
// Unique ID of this request, also in `X-Request-Id`. Include it when contacting
// support.
RequestID string `json:"request_id" api:"required" format:"uuid"`
// Credits this request used and your remaining balance.
KeyMetadata FeedbackSubmitResponseKeyMetadata `json:"key_metadata"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
AlreadySubmitted respjson.Field
FeedbackID respjson.Field
RequestID respjson.Field
KeyMetadata respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FeedbackSubmitResponse) RawJSON() string { return r.JSON.raw }
func (r *FeedbackSubmitResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Credits this request used and your remaining balance.
type FeedbackSubmitResponseKeyMetadata struct {
// Credits charged for this request.
CreditsConsumed int64 `json:"credits_consumed" api:"required"`
// Credits remaining for your organization.
CreditsRemaining int64 `json:"credits_remaining" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CreditsConsumed respjson.Field
CreditsRemaining respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FeedbackSubmitResponseKeyMetadata) RawJSON() string { return r.JSON.raw }
func (r *FeedbackSubmitResponseKeyMetadata) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type FeedbackSubmitParams struct {
// Kind of issue.
//
// Any of "bug", "docs_mismatch", "friction", "feature_gap", "quality_degradation",
// "other".
Category FeedbackSubmitParamsCategory `json:"category,omitzero" api:"required"`
// What went wrong and what you expected instead.
Note string `json:"note" api:"required"`
// The request_id of the API call the feedback is about, from its response body or
// X-Request-Id header.
RequestID param.Opt[string] `json:"request_id,omitzero" format:"uuid"`
// The page the feedback is about, such as one page of a crawl or a docs page.
URL param.Opt[string] `json:"url,omitzero" format:"uri"`
// Labels for filtering usage in the dashboard.
Tags []string `json:"tags,omitzero"`
paramObj
}
func (r FeedbackSubmitParams) MarshalJSON() (data []byte, err error) {
type shadow FeedbackSubmitParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FeedbackSubmitParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Kind of issue.
type FeedbackSubmitParamsCategory string
const (
FeedbackSubmitParamsCategoryBug FeedbackSubmitParamsCategory = "bug"
FeedbackSubmitParamsCategoryDocsMismatch FeedbackSubmitParamsCategory = "docs_mismatch"
FeedbackSubmitParamsCategoryFriction FeedbackSubmitParamsCategory = "friction"
FeedbackSubmitParamsCategoryFeatureGap FeedbackSubmitParamsCategory = "feature_gap"
FeedbackSubmitParamsCategoryQualityDegradation FeedbackSubmitParamsCategory = "quality_degradation"
FeedbackSubmitParamsCategoryOther FeedbackSubmitParamsCategory = "other"
)