Skip to content

Commit

Permalink
feat: Add support for Bondsmith and Fiserv source verification
Browse files Browse the repository at this point in the history
  • Loading branch information
alexluong committed May 5, 2024
1 parent 78faa23 commit 7ba0682
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/provider/sourceverification/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ type sourceVerification struct {
Adyen *adyenSourceVerification `tfsdk:"adyen"`
Akeneo *akeneoSourceVerification `tfsdk:"akeneo"`
AWSSNS *awsSNSSourceVerification `tfsdk:"aws_sns"`
Bondsmith *bondsmithSourceVerification `tfsdk:"bondsmith"`
Cloudsignal *cloudsignalSourceVerification `tfsdk:"cloudsignal"`
Commercelayer *commercelayerSourceVerification `tfsdk:"commercelayer"`
Courier *courierSourceVerification `tfsdk:"courier"`
Ebay *ebaySourceVerification `tfsdk:"ebay"`
Enode *enodeSourceVerification `tfsdk:"enode"`
Favro *favroSourceVerification `tfsdk:"favro"`
Fiserv *fiservSourceVerification `tfsdk:"fiserv"`
FrontApp *frontAppSourceVerification `tfsdk:"frontapp"`
GitHub *githubSourceVerification `tfsdk:"github"`
GitLab *gitlabSourceVerification `tfsdk:"gitlab"`
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/sourceverification/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ func (r *sourceVerificationResource) Schema(_ context.Context, _ resource.Schema
"adyen": adyenConfigSchema(),
"akeneo": akeneoConfigSchema(),
"aws_sns": awsSNSConfigSchema(),
"bondsmith": bondsmithConfigSchema(),
"cloudsignal": cloudsignalConfigSchema(),
"commercelayer": commercelayerConfigSchema(),
"courier": courierConfigSchema(),
"ebay": ebayConfigSchema(),
"enode": enodeConfigSchema(),
"favro": favroConfigSchema(),
"fiserv": fiservConfigSchema(),
"frontapp": frontAppConfigSchema(),
"github": githubConfigSchema(),
"gitlab": gitlabConfigSchema(),
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/sourceverification/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func (m *sourceVerificationResourceModel) ToUpdatePayload() *hookdeck.SourceUpda
verification = m.Verification.Akeneo.toPayload()
} else if m.Verification.AWSSNS != nil {
verification = m.Verification.AWSSNS.toPayload()
} else if m.Verification.Bondsmith != nil {
verification = m.Verification.Bondsmith.toPayload()
} else if m.Verification.Cloudsignal != nil {
verification = m.Verification.Cloudsignal.toPayload()
} else if m.Verification.Commercelayer != nil {
Expand All @@ -43,6 +45,8 @@ func (m *sourceVerificationResourceModel) ToUpdatePayload() *hookdeck.SourceUpda
verification = m.Verification.Enode.toPayload()
} else if m.Verification.Favro != nil {
verification = m.Verification.Favro.toPayload()
} else if m.Verification.Fiserv != nil {
verification = m.Verification.Fiserv.toPayload()
} else if m.Verification.FrontApp != nil {
verification = m.Verification.FrontApp.toPayload()
} else if m.Verification.GitHub != nil {
Expand Down
32 changes: 32 additions & 0 deletions internal/provider/sourceverification/verification_bondsmith.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sourceverification

import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
hookdeck "github.com/hookdeck/hookdeck-go-sdk"
)

func bondsmithConfigSchema() schema.SingleNestedAttribute {
return schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"webhook_secret_key": schema.StringAttribute{
Required: true,
Sensitive: true,
},
},
}
}

type bondsmithSourceVerification struct {
WebhookSecretKey types.String `tfsdk:"webhook_secret_key"`
}

func (m *bondsmithSourceVerification) toPayload() *hookdeck.VerificationConfig {
return hookdeck.NewVerificationConfigFromVerificationBondsmith(&hookdeck.VerificationBondsmith{
Type: hookdeck.VerificationBondsmithTypeBondsmith,
Configs: &hookdeck.VerificationBondsmithConfigs{
WebhookSecretKey: m.WebhookSecretKey.ValueString(),
},
})
}
32 changes: 32 additions & 0 deletions internal/provider/sourceverification/verification_fiserv.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sourceverification

import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
hookdeck "github.com/hookdeck/hookdeck-go-sdk"
)

func fiservConfigSchema() schema.SingleNestedAttribute {
return schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"webhook_secret_key": schema.StringAttribute{
Required: true,
Sensitive: true,
},
},
}
}

type fiservSourceVerification struct {
WebhookSecretKey types.String `tfsdk:"webhook_secret_key"`
}

func (m *fiservSourceVerification) toPayload() *hookdeck.VerificationConfig {
return hookdeck.NewVerificationConfigFromVerificationFiserv(&hookdeck.VerificationFiserv{
Type: hookdeck.VerificationFiservTypeFiserv,
Configs: &hookdeck.VerificationFiservConfigs{
WebhookSecretKey: m.WebhookSecretKey.ValueString(),
},
})
}

0 comments on commit 7ba0682

Please sign in to comment.