-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebhook.go
More file actions
78 lines (68 loc) · 2.74 KB
/
Copy pathwebhook.go
File metadata and controls
78 lines (68 loc) · 2.74 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package contextdev
import (
"encoding/json"
"github.com/context-dot-dev/context-go-sdk/v2/internal/apijson"
"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"
)
// WebhookService 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 [NewWebhookService] method instead.
type WebhookService struct {
options []option.RequestOption
// Inspect and retry batch and monitor webhook deliveries.
Deliveries WebhookDeliveryService
}
// NewWebhookService 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 NewWebhookService(opts ...option.RequestOption) (r WebhookService) {
r = WebhookService{}
r.options = opts
r.Deliveries = NewWebhookDeliveryService(opts...)
return
}
// Webhook retry settings. Use {} for the default schedule.
type RetryConfig struct {
// Retry delays in seconds, totaling at most 72 hours. Use [] to disable automatic
// retries.
DelaysSeconds []int64 `json:"delays_seconds"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
DelaysSeconds respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r RetryConfig) RawJSON() string { return r.JSON.raw }
func (r *RetryConfig) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// ToParam converts this RetryConfig to a RetryConfigParam.
//
// Warning: the fields of the param type will not be present. ToParam should only
// be used at the last possible moment before sending a request. Test for this with
// RetryConfigParam.Overrides()
func (r RetryConfig) ToParam() RetryConfigParam {
return param.Override[RetryConfigParam](json.RawMessage(r.RawJSON()))
}
// Webhook retry settings. Use {} for the default schedule.
type RetryConfigParam struct {
// Retry delays in seconds, totaling at most 72 hours. Use [] to disable automatic
// retries.
DelaysSeconds []int64 `json:"delays_seconds,omitzero"`
paramObj
}
func (r RetryConfigParam) MarshalJSON() (data []byte, err error) {
type shadow RetryConfigParam
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *RetryConfigParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}