Skip to content

Commit

Permalink
feat: add 'config' field to proxy request for v0 (#4352)
Browse files Browse the repository at this point in the history
* feat: add 'config' field to proxy request for v0

* chore: remove logger

---------

Co-authored-by: Dilip Kola <33080863+koladilip@users.noreply.github.com>
Co-authored-by: Akash Chetty <achetty.iitr@gmail.com>
  • Loading branch information
3 people committed Feb 1, 2024
1 parent f5d8de3 commit 4fdd81c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions router/transformer/transformer_proxy_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type transformerProxyAdapter interface {

type ProxyRequestPayloadV0 struct {
integrations.PostParametersT
Metadata ProxyRequestMetadata `json:"metadata"`
Metadata ProxyRequestMetadata `json:"metadata"`
DestinationConfig map[string]interface{} `json:"destinationConfig"`
}

type ProxyResponseV0 struct {
Expand Down Expand Up @@ -64,8 +65,9 @@ type (

func (v0 *v0Adapter) getPayload(proxyReqParams *ProxyRequestParams) ([]byte, error) {
proxyReqPayload := &ProxyRequestPayloadV0{
PostParametersT: proxyReqParams.ResponseData.PostParametersT,
Metadata: proxyReqParams.ResponseData.Metadata[0],
PostParametersT: proxyReqParams.ResponseData.PostParametersT,
Metadata: proxyReqParams.ResponseData.Metadata[0],
DestinationConfig: proxyReqParams.ResponseData.DestinationConfig,
}
return jsonfast.Marshal(proxyReqPayload)
}
Expand Down
6 changes: 5 additions & 1 deletion router/transformer/transformer_proxy_adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ func TestV0Adapter(t *testing.T) {
JobID: 2,
},
},
DestinationConfig: map[string]interface{}{
"key_1": "val_1",
"key_2": "val_2",
},
},
DestName: "testDestType",
}
expectedPayload := `{"type":"a","endpoint":"a.com","method":"","userId":"","headers":null,"params":null,"body":{"jobId":1},"files":null,"metadata":{"jobId":1,"attemptNum":0,"userId":"","sourceId":"","destinationId":"","workspaceId":"","secret":null,"dontBatch":true}}`
expectedPayload := `{"type":"a","endpoint":"a.com","method":"","userId":"","headers":null,"params":null,"body":{"jobId":1},"files":null,"metadata":{"jobId":1,"attemptNum":0,"userId":"","sourceId":"","destinationId":"","workspaceId":"","secret":null,"dontBatch":true},"destinationConfig":{"key_1":"val_1","key_2":"val_2"}}`

payload, err := v0Adapter.getPayload(proxyReqParms)
require.Nil(t, err)
Expand Down

0 comments on commit 4fdd81c

Please sign in to comment.