24 KiB
V1
(Webhooks.V1)
Available Operations
- GetManyConfigs - Get many configs
- InsertConfig - Insert a new config
- DeleteConfig - Delete one config
- UpdateConfig - Update one config
- TestConfig - Test one config
- ActivateConfig - Activate one config
- DeactivateConfig - Deactivate one config
- ChangeConfigSecret - Change the signing secret of a config
GetManyConfigs
Sorted by updated date descending
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.GetManyConfigsRequest{
ID: client.String("4997257d-dfb6-445b-929c-cbe2ab182818"),
Endpoint: client.String("https://example.com"),
}
ctx := context.Background()
res, err := s.Webhooks.V1.GetManyConfigs(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ConfigsResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetManyConfigsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.GetManyConfigsResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
InsertConfig
Insert a new webhooks config.
The endpoint should be a valid https URL and be unique.
The secret is the endpoint's verification secret. If not passed or empty, a secret is automatically generated. The format is a random string of bytes of size 24, base64 encoded. (larger size after encoding)
All eventTypes are converted to lower-case when inserted.
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := components.ConfigUser{
Name: client.String("customer_payment"),
Endpoint: "https://example.com",
Secret: client.String("V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3"),
EventTypes: []string{
"TYPE1",
"TYPE2",
},
}
ctx := context.Background()
res, err := s.Webhooks.V1.InsertConfig(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ConfigResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.ConfigUser | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.InsertConfigResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
DeleteConfig
Delete a webhooks config by ID.
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.DeleteConfigRequest{
ID: "4997257d-dfb6-445b-929c-cbe2ab182818",
}
ctx := context.Background()
res, err := s.Webhooks.V1.DeleteConfig(ctx, request)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.DeleteConfigRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.DeleteConfigResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
UpdateConfig
Update a webhooks config by ID.
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.UpdateConfigRequest{
ID: "4997257d-dfb6-445b-929c-cbe2ab182818",
ConfigUser: components.ConfigUser{
Name: client.String("customer_payment"),
Endpoint: "https://example.com",
Secret: client.String("V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3"),
EventTypes: []string{
"TYPE1",
"TYPE2",
},
},
}
ctx := context.Background()
res, err := s.Webhooks.V1.UpdateConfig(ctx, request)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.UpdateConfigRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.UpdateConfigResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
TestConfig
Test a config by sending a webhook to its endpoint.
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.TestConfigRequest{
ID: "4997257d-dfb6-445b-929c-cbe2ab182818",
}
ctx := context.Background()
res, err := s.Webhooks.V1.TestConfig(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.AttemptResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.TestConfigRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.TestConfigResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
ActivateConfig
Activate a webhooks config by ID, to start receiving webhooks to its endpoint.
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.ActivateConfigRequest{
ID: "4997257d-dfb6-445b-929c-cbe2ab182818",
}
ctx := context.Background()
res, err := s.Webhooks.V1.ActivateConfig(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ConfigResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ActivateConfigRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.ActivateConfigResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
DeactivateConfig
Deactivate a webhooks config by ID, to stop receiving webhooks to its endpoint.
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.DeactivateConfigRequest{
ID: "4997257d-dfb6-445b-929c-cbe2ab182818",
}
ctx := context.Background()
res, err := s.Webhooks.V1.DeactivateConfig(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ConfigResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.DeactivateConfigRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.DeactivateConfigResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |
ChangeConfigSecret
Change the signing secret of the endpoint of a webhooks config.
If not passed or empty, a secret is automatically generated. The format is a random string of bytes of size 24, base64 encoded. (larger size after encoding)
Example Usage
package main
import(
"github.com/formancehq/webhooks/pkg/client/models/components"
"github.com/formancehq/webhooks/pkg/client"
"github.com/formancehq/webhooks/pkg/client/models/operations"
"context"
"log"
)
func main() {
s := client.New(
client.WithSecurity(components.Security{
ClientID: "",
ClientSecret: "",
}),
)
request := operations.ChangeConfigSecretRequest{
ID: "4997257d-dfb6-445b-929c-cbe2ab182818",
ConfigChangeSecret: &components.ConfigChangeSecret{
Secret: "V0bivxRWveaoz08afqjU6Ko/jwO0Cb+3",
},
}
ctx := context.Background()
res, err := s.Webhooks.V1.ChangeConfigSecret(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ConfigResponse != nil {
// handle response
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ChangeConfigSecretRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
Response
*operations.ChangeConfigSecretResponse, error
| Error Object | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorResponse | default | application/json |
| sdkerrors.SDKError | 4xx-5xx | / |