feat(nango): add integration.rs with list/get/create/update/delete endpoints#3712
feat(nango): add integration.rs with list/get/create/update/delete endpoints#3712
Conversation
…dpoints Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Deploy Preview for hyprnote-storybook canceled.
|
✅ Deploy Preview for hyprnote canceled.
|
| ) -> Result<Vec<Integration>, crate::Error> { | ||
| let mut url = self.api_base.clone(); | ||
| url.set_path("/integrations"); | ||
|
|
||
| let response = self.client.post(url).json(&req).send().await?; | ||
| let wrapper: DataWrapper<Vec<Integration>> = parse_response(response).await?; | ||
| Ok(wrapper.data) |
There was a problem hiding this comment.
🔴 create_integration deserializes response as Vec<Integration> but API returns a single object
The create_integration method at line 138 deserializes the response as DataWrapper<Vec<Integration>>, expecting the data field to be an array. However, the Nango POST /integrations API endpoint returns a single integration object in the data field ({ data: { ... } }), not an array.
Root Cause
All other create/mutate endpoints in this crate return a single object wrapped in DataWrapper<T> — for example, create_connect_session at crates/nango/src/connect_session.rs:84 uses DataWrapper<ConnectSession>, and update_integration at line 151 of the same file uses DataWrapper<Integration>. The Nango API consistently returns { data: <single_object> } for create operations.
Using DataWrapper<Vec<Integration>> will cause serde deserialization to fail at runtime with a type mismatch error (expecting array, got object), making create_integration completely non-functional.
Impact: Every call to create_integration will fail with a deserialization error, even when the API request itself succeeds.
| ) -> Result<Vec<Integration>, crate::Error> { | |
| let mut url = self.api_base.clone(); | |
| url.set_path("/integrations"); | |
| let response = self.client.post(url).json(&req).send().await?; | |
| let wrapper: DataWrapper<Vec<Integration>> = parse_response(response).await?; | |
| Ok(wrapper.data) | |
| ) -> Result<Integration, crate::Error> { | |
| let mut url = self.api_base.clone(); | |
| url.set_path("/integrations"); | |
| let response = self.client.post(url).json(&req).send().await?; | |
| let wrapper: DataWrapper<Integration> = parse_response(response).await?; | |
| Ok(wrapper.data) |
Was this helpful? React with 👍 or 👎 to provide feedback.
feat(nango): add integration.rs with CRUD endpoints
Summary
Adds
integration.rstocrates/nangoimplementing the 5 Nango Integration API endpoints:list_integrations—GET /integrationsget_integration—GET /integrations/{uniqueKey}(with optionalincludequery param forwebhook/credentials)create_integration—POST /integrationsupdate_integration—PATCH /integrations/{uniqueKey}delete_integration—DELETE /integrations/{uniqueKey}Types added:
Integration,IntegrationFull,IntegrationCredentials(tagged enum with OAuth1/OAuth2/TBA/App/Custom variants),CreateIntegrationRequest,UpdateIntegrationRequest.Follows the same patterns as the existing
connection.rsandconnect_session.rsmodules (usescommon_derives!,DataWrapper,parse_response/check_response).Review & Testing Checklist for Human
create_integrationreturn type: the OpenAPI spec saysdatais an array ofIntegration, so this returnsVec<Integration>. Confirm this matches actual Nango API behavior — if it actually returns a single object, this will fail to deserialize.includequery param encoding forget_integration: currently sent as repeated params (?include=webhook&include=credentials). Confirm Nango accepts this format vs comma-separated.IntegrationCredentialsserde tagged enum round-trips correctly against real Nango API responses (especially edge cases like missing optional fields).Notes
#[ignore]'d).cargo check -p nangopasses.dprint fmtapplied.Link to Devin run: https://app.devin.ai/sessions/26afac3fc8774170b99186e3faa4e03d
Requested by: @yujonglee