Skip to content

Commit d728bcc

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix: support array query parameters (#89)
1 parent c8ddc6b commit d728bcc

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

betamessage.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func NewBetaMessageService(opts ...option.RequestOption) (r *BetaMessageService)
4545
//
4646
// Note: If you choose to set a timeout for this request, we recommend 10 minutes.
4747
func (r *BetaMessageService) New(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (res *BetaMessage, err error) {
48-
if params.Betas.Present {
49-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", params.Betas)))
48+
for _, v := range params.Betas.Value {
49+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
5050
}
5151
opts = append(r.Options[:], opts...)
5252
path := "v1/messages?beta=true"
@@ -66,8 +66,8 @@ func (r *BetaMessageService) NewStreaming(ctx context.Context, params BetaMessag
6666
raw *http.Response
6767
err error
6868
)
69-
if params.Betas.Present {
70-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", params.Betas)))
69+
for _, v := range params.Betas.Value {
70+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
7171
}
7272
opts = append(r.Options[:], opts...)
7373
opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...)
@@ -81,8 +81,8 @@ func (r *BetaMessageService) NewStreaming(ctx context.Context, params BetaMessag
8181
// The Token Count API can be used to count the number of tokens in a Message,
8282
// including tools, images, and documents, without creating it.
8383
func (r *BetaMessageService) CountTokens(ctx context.Context, params BetaMessageCountTokensParams, opts ...option.RequestOption) (res *BetaMessageTokensCount, err error) {
84-
if params.Betas.Present {
85-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", params.Betas)))
84+
for _, v := range params.Betas.Value {
85+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
8686
}
8787
opts = append(r.Options[:], opts...)
8888
path := "v1/messages/count_tokens?beta=true"

betamessagebatch.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func NewBetaMessageBatchService(opts ...option.RequestOption) (r *BetaMessageBat
4545
// once. Once a Message Batch is created, it begins processing immediately. Batches
4646
// can take up to 24 hours to complete.
4747
func (r *BetaMessageBatchService) New(ctx context.Context, params BetaMessageBatchNewParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error) {
48-
if params.Betas.Present {
49-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", params.Betas)))
48+
for _, v := range params.Betas.Value {
49+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
5050
}
5151
opts = append(r.Options[:], opts...)
5252
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "message-batches-2024-09-24")}, opts...)
@@ -59,8 +59,8 @@ func (r *BetaMessageBatchService) New(ctx context.Context, params BetaMessageBat
5959
// completion. To access the results of a Message Batch, make a request to the
6060
// `results_url` field in the response.
6161
func (r *BetaMessageBatchService) Get(ctx context.Context, messageBatchID string, query BetaMessageBatchGetParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error) {
62-
if query.Betas.Present {
63-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", query.Betas)))
62+
for _, v := range query.Betas.Value {
63+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
6464
}
6565
opts = append(r.Options[:], opts...)
6666
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "message-batches-2024-09-24")}, opts...)
@@ -77,8 +77,8 @@ func (r *BetaMessageBatchService) Get(ctx context.Context, messageBatchID string
7777
// returned first.
7878
func (r *BetaMessageBatchService) List(ctx context.Context, params BetaMessageBatchListParams, opts ...option.RequestOption) (res *pagination.Page[BetaMessageBatch], err error) {
7979
var raw *http.Response
80-
if params.Betas.Present {
81-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", params.Betas)))
80+
for _, v := range params.Betas.Value {
81+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
8282
}
8383
opts = append(r.Options[:], opts...)
8484
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "message-batches-2024-09-24"), option.WithResponseInto(&raw)}, opts...)
@@ -105,8 +105,8 @@ func (r *BetaMessageBatchService) ListAutoPaging(ctx context.Context, params Bet
105105
// completion. To access the results of a Message Batch, make a request to the
106106
// `results_url` field in the response.
107107
func (r *BetaMessageBatchService) Delete(ctx context.Context, messageBatchID string, body BetaMessageBatchDeleteParams, opts ...option.RequestOption) (res *BetaDeletedMessageBatch, err error) {
108-
if body.Betas.Present {
109-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", body.Betas)))
108+
for _, v := range body.Betas.Value {
109+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
110110
}
111111
opts = append(r.Options[:], opts...)
112112
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "message-batches-2024-09-24")}, opts...)
@@ -129,8 +129,8 @@ func (r *BetaMessageBatchService) Delete(ctx context.Context, messageBatchID str
129129
// Note that cancellation may not result in any canceled requests if they were
130130
// non-interruptible.
131131
func (r *BetaMessageBatchService) Cancel(ctx context.Context, messageBatchID string, body BetaMessageBatchCancelParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error) {
132-
if body.Betas.Present {
133-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", body.Betas)))
132+
for _, v := range body.Betas.Value {
133+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
134134
}
135135
opts = append(r.Options[:], opts...)
136136
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "message-batches-2024-09-24")}, opts...)
@@ -149,8 +149,8 @@ func (r *BetaMessageBatchService) Cancel(ctx context.Context, messageBatchID str
149149
// in the Message Batch. Results are not guaranteed to be in the same order as
150150
// requests. Use the `custom_id` field to match results to requests.
151151
func (r *BetaMessageBatchService) Results(ctx context.Context, messageBatchID string, query BetaMessageBatchResultsParams, opts ...option.RequestOption) (res *http.Response, err error) {
152-
if query.Betas.Present {
153-
opts = append(opts, option.WithHeader("betas", fmt.Sprintf("%s", query.Betas)))
152+
for _, v := range query.Betas.Value {
153+
opts = append(opts, option.WithHeaderAdd("betas", fmt.Sprintf("%s", v)))
154154
}
155155
opts = append(r.Options[:], opts...)
156156
opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "message-batches-2024-09-24"), option.WithHeader("Accept", "application/binary")}, opts...)

0 commit comments

Comments
 (0)