Repository navigation
feat: migrate deals_list and deals_list_all_auto to Pipedrive API v2 - #68
Merged
Merged
Conversation
- Switch deals_list and deals_list_all_auto from the deprecated GET /deals (v1) to GET /api/v2/deals, following the existing v2 pattern already used by stages, deals/convert and installments - Map the legacy v1 filter surface onto v2 params so callers don't need to change: user_id and owned_by_you=1 both resolve to owner_id (the latter via a cached GET /users/me lookup); sort (field) + sort_by (direction) become sort_by (field) + sort_direction; status=all_not_deleted is dropped since v2 has no equivalent value - Replace start/limit offset pagination with v2's cursor pagination: deals_list accepts an optional cursor and returns additional_data.next_cursor; deals_list_all_auto loops on the cursor until it comes back null instead of using the start/limit PaginationHelper; start is kept in the schema but deprecated/ignored for backward compatibility - Teach buildResolvedCustomFields to also read custom field values nested under a v2-style custom_fields object (v1's flat, hash-keyed-at-root layout still takes priority when both are present), so custom_fields_resolved keeps working on v2 responses - Add unit tests for the v2 param mapping, cursor pagination in deals_list_all_auto, and nested custom_fields normalization; verified manually against the live API (open deals on pipeline 1 return data with a next_cursor and no deprecation_warning)
…ilters - Add a hard page cap (MAX_PAGES=1000) and a repeated-cursor guard to deals_list_all_auto's pagination loop, throwing a descriptive error instead of looping forever when the API returns a non-advancing next_cursor (including an empty page that echoes back the same cursor it was given) - Trim the requested limit on the final page to max_items - fetched, avoiding an unnecessary over-fetch when max_items isn't a multiple of pageSize - Document in both tools' inputSchema that owned_by_you=1 takes precedence over user_id when both are supplied - Omit sort_direction when no sort field is provided, since ListDealsSchema's sort_by (direction) defaults to 'asc' even when the caller never passed it — sending a direction without a field to sort by is meaningless to the v2 API - Add tests covering the repeated-cursor guard, the empty-page/same- cursor case, the page cap, the trimmed last-page limit, and the new sort_direction omission behavior
iamsamuelfraga
force-pushed
the
feat/deals-list-api-v2
branch
from
September 11, 2026 13:54
0386080 to
7e7d3c1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivación
El endpoint v1
/dealsestá deprecado por Pipedrive y devuelve errores 500 intermitentes al combinar los filtrospipeline_id+status. Esta PR migradeals_listydeals_list_all_autoal endpoint v2 (/api/v2/deals), que es estable y es la vía recomendada por Pipedrive para listados de deals.Cambios
/api/v2/dealsen lugar de/deals(v1) paradeals_listydeals_list_all_auto.start/limita cursor (cursor/limit), acorde al modelo de paginación de v2.user_id→owner_id(nomenclatura v2).owned_by_youresuelto vía/users/me, con cacheado para evitar llamadas repetidas.custom_fieldscompatible tanto con la respuesta de v1 como con la de v2, para no romper consumidores existentes de las tools.Tests
Verificación manual
Verificado manualmente contra la API v2 real de Pipedrive: respuestas correctas, sin
deprecation_warningen las respuestas (a diferencia del endpoint v1).Open points
package-lock.jsonya estaba desincronizado enmainantes de esta rama (no introducido por esta PR).sort_byen v2 solo admiteid,add_timeoupdate_time(v1 admitía más campos); cualquier consumidor que dependa de ordenar por otros campos debe revisarse.