Skip to content

Commit a4d6c21

Browse files
committed
bugfix in triggers
1 parent 326e73e commit a4d6c21

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

connect/trigger.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"github.com/cloudsquid/pipedream-go-sdk/internal"
98
"net/http"
109
"net/url"
1110
"path"
11+
12+
"github.com/cloudsquid/pipedream-go-sdk/internal"
1213
)
1314

1415
type Trigger struct {
@@ -24,6 +25,10 @@ type Trigger struct {
2425
NameSlug string `json:"name_slug"`
2526
}
2627

28+
type GetTriggerResponse struct {
29+
Data Trigger `json:"data"`
30+
}
31+
2732
type PageInfo struct {
2833
TotalCount int `json:"total_count,omitempty"`
2934
Count int `json:"count,omitempty"`
@@ -98,7 +103,8 @@ func (c *Client) DeployTrigger(
98103
workflowID string, // OPTIONAL
99104
) (map[string]any, error) {
100105
baseURL := c.ConnectURL().ResolveReference(&url.URL{
101-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "triggers", "deploy")})
106+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "triggers", "deploy"),
107+
})
102108

103109
trigger := DeployTriggerRequest{
104110
ComponentKey: componentKey,
@@ -140,7 +146,8 @@ func (c *Client) ListDeployedTriggers(
140146
externalUserID string,
141147
) (*TriggerList, error) {
142148
baseURL := c.ConnectURL().ResolveReference(&url.URL{
143-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers")})
149+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers"),
150+
})
144151

145152
queryParams := url.Values{}
146153
internal.AddQueryParams(queryParams, "external_user_id", externalUserID)
@@ -170,7 +177,8 @@ func (c *Client) GetDeployedTrigger(
170177
externalUserId string,
171178
) (*Trigger, error) {
172179
baseURL := c.ConnectURL().ResolveReference(&url.URL{
173-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID)})
180+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID),
181+
})
174182

175183
queryParams := url.Values{}
176184
internal.AddQueryParams(queryParams, "external_user_id", externalUserId)
@@ -186,12 +194,12 @@ func (c *Client) GetDeployedTrigger(
186194
return nil, fmt.Errorf("executing request to retrieve trigger: %w", err)
187195
}
188196

189-
var trigger Trigger
197+
var trigger GetTriggerResponse
190198
if err := internal.UnmarshalResponse(response, &trigger); err != nil {
191199
return nil, fmt.Errorf("unmarshalling response to retrieve trigger: %w", err)
192200
}
193201

194-
return &trigger, nil
202+
return &trigger.Data, nil
195203
}
196204

197205
func (c *Client) DeleteDeployedTrigger(
@@ -200,7 +208,8 @@ func (c *Client) DeleteDeployedTrigger(
200208
externalUserID string,
201209
) error {
202210
baseURL := c.ConnectURL().ResolveReference(&url.URL{
203-
Path: path.Join(c.ConnectURL().Path, c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedTriggerID)})
211+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedTriggerID),
212+
})
204213

205214
queryParams := url.Values{}
206215
internal.AddQueryParams(queryParams, "external_user_id", externalUserID)
@@ -231,7 +240,8 @@ func (c *Client) RetrieveTriggerEvents(
231240
numberOfEvents int,
232241
) (*TriggerEventList, error) {
233242
baseURL := c.ConnectURL().ResolveReference(&url.URL{
234-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "events")})
243+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "events"),
244+
})
235245

236246
queryParams := url.Values{}
237247
internal.AddQueryParams(queryParams, "external_user_id", externalUserID)
@@ -262,7 +272,8 @@ func (c *Client) ListTriggerWebhooks(
262272
externalUserID string,
263273
) (*TriggerWebhookURLs, error) {
264274
baseURL := c.ConnectURL().ResolveReference(&url.URL{
265-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "webhooks")})
275+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "webhooks"),
276+
})
266277

267278
queryParams := url.Values{}
268279
internal.AddQueryParams(queryParams, "external_user_id", externalUserID)
@@ -294,7 +305,8 @@ func (c *Client) UpdateTriggerWebhooks(
294305
webhookURLs []string,
295306
) (*TriggerWebhookURLs, error) {
296307
baseURL := c.ConnectURL().ResolveReference(&url.URL{
297-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "webhooks")})
308+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "webhooks"),
309+
})
298310

299311
body := UpdateTriggerWebhooksRequest{
300312
ExternalUserID: externalUserID,
@@ -331,7 +343,8 @@ func (c *Client) RetrieveTriggerWorkflows(
331343
externalUserID string,
332344
) (*TriggerWorkflowIDs, error) {
333345
baseURL := c.ConnectURL().ResolveReference(&url.URL{
334-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "workflows")})
346+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "workflows"),
347+
})
335348

336349
queryParams := url.Values{}
337350
internal.AddQueryParams(queryParams, "external_user_id", externalUserID)
@@ -363,7 +376,8 @@ func (c *Client) UpdateTriggerWorkflows(
363376
workflowIDs []string,
364377
) (*TriggerWorkflowIDs, error) {
365378
baseURL := c.ConnectURL().ResolveReference(&url.URL{
366-
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "workflows")})
379+
Path: path.Join(c.ConnectURL().Path, c.ProjectID(), "deployed-triggers", deployedComponentID, "workflows"),
380+
})
367381

368382
body := UpdateTriggerWorkflowsRequest{
369383
ExternalUserID: externalUserID,

0 commit comments

Comments
 (0)