Skip to content

Conversation

@j4rs
Copy link
Member

@j4rs j4rs commented Aug 6, 2025

Address issue #40

Summary by CodeRabbit

  • New Features

    • Added the ability to specify a separate API version for fields-related operations, allowing resources to use different API versions for general and fields operations.
    • Introduced methods to set and query the API version specifically for fields.
  • Bug Fixes

    • Ensured that the Activity resource uses the correct API version for fields operations, aligning with external API requirements.
  • Tests

    • Expanded and updated tests to verify correct API versioning behavior for both general and fields operations.
  • Documentation

    • Updated the changelog to reflect the new version and features.
  • Chores

    • Updated the app version to 2.1.0.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

This change introduces a mechanism to override the API version specifically for fields-related operations within the Fields module. Two new class methods, use_fields_version and fields_api_version, are added to manage and query the fields-specific API version. The fields method is modified to use a private helper that temporarily switches the API version to the fields-specific version for requests. The Activity resource is updated to use this new mechanism, specifying that its fields operations should use version v1 of the API, while its general operations continue using v2. The version constant is updated to 2.1.0, and the test suite is expanded to verify the new versioning behavior and method availability.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ActivityResource
    participant FieldsModule
    participant PipedriveAPI

    Client->>ActivityResource: Call general operation (e.g., list activities)
    ActivityResource->>PipedriveAPI: Request with API version v2
    PipedriveAPI-->>ActivityResource: Response
    ActivityResource-->>Client: Return data

    Client->>ActivityResource: Call fields operation (e.g., Activity.fields)
    ActivityResource->>FieldsModule: fields()
    FieldsModule->>PipedriveAPI: Request with API version v1 (overridden)
    PipedriveAPI-->>FieldsModule: Response
    FieldsModule-->>ActivityResource: Return fields data
    ActivityResource-->>Client: Return fields data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11aa762 and d4f8529.

📒 Files selected for processing (1)
  • lib/pipedrive/fields.rb (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: foomip
PR: getonbrd/pipedrive-connect#37
File: lib/pipedrive/api_operations/request.rb:11-13
Timestamp: 2025-04-01T14:03:34.481Z
Learning: For the Pipedrive Connect library, API version management should be implemented on a per-resource basis (by overriding the `api_version` method in individual resource classes) rather than using global configuration, to maintain consistency and ensure proper testing of each resource with newer API versions.
📚 Learning: for the pipedrive connect library, api version management should be implemented on a per-resource ba...
Learnt from: foomip
PR: getonbrd/pipedrive-connect#37
File: lib/pipedrive/api_operations/request.rb:11-13
Timestamp: 2025-04-01T14:03:34.481Z
Learning: For the Pipedrive Connect library, API version management should be implemented on a per-resource basis (by overriding the `api_version` method in individual resource classes) rather than using global configuration, to maintain consistency and ensure proper testing of each resource with newer API versions.

Applied to files:

  • lib/pipedrive/fields.rb
🧬 Code Graph Analysis (1)
lib/pipedrive/fields.rb (2)
lib/pipedrive/api_operations/request.rb (3)
  • api_version (16-18)
  • request (31-49)
  • request (73-75)
lib/pipedrive.rb (1)
  • api_version (47-49)
🔇 Additional comments (5)
lib/pipedrive/fields.rb (5)

13-16: LGTM! Clean implementation of fields version override.

The method provides a clear interface for setting fields-specific API versions, aligning with the per-resource API version management approach mentioned in the retrieved learnings.


18-24: Excellent version override implementation.

The method correctly prioritizes explicitly set versions while maintaining backward compatibility through the super fallback. This aligns well with the per-resource API version management strategy.


26-29: LGTM! Clear version resolution logic.

The fallback mechanism correctly prioritizes fields-specific versions while gracefully falling back to the general API version when needed.


39-39: Correct integration with fields-specific versioning.

The change to use fields_request ensures that fields operations use the appropriate API version without affecting other operations.


62-74: Excellent implementation of version-aware request handling.

The fields_request method correctly implements:

  • Temporary version switching using the fields-specific version
  • Proper exception handling with ensure block for guaranteed cleanup
  • Clean separation of concerns as a private helper method

This addresses the core requirement while maintaining robustness and following Ruby best practices.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch support-overriding-version-for-fields

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 152adb9 and 916b3ba.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • lib/pipedrive/fields.rb (3 hunks)
  • lib/pipedrive/resources/activity.rb (1 hunks)
  • lib/pipedrive/version.rb (1 hunks)
  • spec/lib/pipedrive/activity_spec.rb (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: foomip
PR: getonbrd/pipedrive-connect#37
File: lib/pipedrive/api_operations/request.rb:11-13
Timestamp: 2025-04-01T14:03:34.481Z
Learning: For the Pipedrive Connect library, API version management should be implemented on a per-resource basis (by overriding the `api_version` method in individual resource classes) rather than using global configuration, to maintain consistency and ensure proper testing of each resource with newer API versions.
📚 Learning: for the pipedrive connect library, api version management should be implemented on a per-resource ba...
Learnt from: foomip
PR: getonbrd/pipedrive-connect#37
File: lib/pipedrive/api_operations/request.rb:11-13
Timestamp: 2025-04-01T14:03:34.481Z
Learning: For the Pipedrive Connect library, API version management should be implemented on a per-resource basis (by overriding the `api_version` method in individual resource classes) rather than using global configuration, to maintain consistency and ensure proper testing of each resource with newer API versions.

Applied to files:

  • lib/pipedrive/version.rb
  • spec/lib/pipedrive/activity_spec.rb
  • lib/pipedrive/resources/activity.rb
  • CHANGELOG.md
  • lib/pipedrive/fields.rb
🧬 Code Graph Analysis (2)
lib/pipedrive/resources/activity.rb (1)
lib/pipedrive/fields.rb (1)
  • use_fields_version (14-16)
lib/pipedrive/fields.rb (5)
lib/pipedrive/api_operations/request.rb (4)
  • api_version (16-18)
  • supports_v2_api? (11-14)
  • request (31-49)
  • request (73-75)
lib/pipedrive.rb (1)
  • api_version (47-49)
lib/pipedrive/resources/activity.rb (1)
  • supports_v2_api? (13-15)
lib/pipedrive/resources/deal.rb (1)
  • supports_v2_api? (11-13)
lib/pipedrive/resources/product.rb (1)
  • supports_v2_api? (7-9)
🪛 LanguageTool
CHANGELOG.md

[grammar] ~8-~8: Use correct spacing
Context: ...p://keepachangelog.com/). ## [2.1.0] - 2025-08-06 ### Added - New use_fields_version method ...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~11-~11: There might be a mistake here.
Context: ...ide API version specifically for fields operations - Fields-specific version override functio...

(QB_NEW_EN_OTHER)


[grammar] ~12-~12: Use periods with abbreviations
Context: ...o use different API versions for fields vs general operations - `fields_api_versio...

(QB_NEW_EN_OTHER_ERROR_IDS_34)


[grammar] ~12-~12: There might be a mistake here.
Context: ...rent API versions for fields vs general operations - fields_api_version method to query the fields-specific API versio...

(QB_NEW_EN_OTHER)


[grammar] ~13-~13: There might be a problem here.
Context: ...method to query the fields-specific API version ### Changed - Activity resource now uses `use_field...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~16-~16: Make sure to use plural and singular nouns correctly
Context: ...rsion :v1` to override version only for fields operations - Activity general operations now use v2 A...

(QB_NEW_EN_OTHER_ERROR_IDS_10)


[grammar] ~17-~17: There might be a mistake here.
Context: ... Activity general operations now use v2 API while fields operations continue to use...

(QB_NEW_EN_OTHER)


[grammar] ~17-~17: Make sure to use plural and singular nouns correctly
Context: ...general operations now use v2 API while fields operations continue to use v1 API as re...

(QB_NEW_EN_OTHER_ERROR_IDS_10)


[grammar] ~17-~17: There might be a mistake here.
Context: ...s continue to use v1 API as required by Pipedrive ## [2.0.1] - 2025-04-17 - Fix bugs introdu...

(QB_NEW_EN_OTHER)

🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

10-10: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


11-11: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


15-15: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


16-16: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

🪛 RuboCop (1.76.1)
lib/pipedrive/fields.rb

[convention] 66-66: private should be inlined in method definitions.

(Style/AccessModifierDeclarations)

🔇 Additional comments (7)
lib/pipedrive/version.rb (1)

4-4: LGTM: Appropriate semantic version bump

The minor version increment correctly reflects the addition of new backward-compatible functionality for fields version overrides.

lib/pipedrive/resources/activity.rb (1)

6-10: Excellent implementation with clear documentation

The addition of use_fields_version :v1 with explanatory comments and API documentation reference makes the intent clear. This properly implements the new fields version override mechanism while maintaining v2 for general operations.

spec/lib/pipedrive/activity_spec.rb (1)

32-80: Excellent comprehensive test coverage

The test suite thoroughly validates the new fields version override functionality with proper coverage of:

  • API version behavior under different global settings
  • Independent fields version override
  • Method availability verification
  • Clear context separation and descriptive test names

This provides strong confidence in the implementation's correctness.

lib/pipedrive/fields.rb (4)

13-16: Well-implemented version override setter

The use_fields_version method provides a clean interface for setting fields-specific API versions, following established patterns in the codebase.


18-28: Solid API version override implementation

The api_version override maintains backward compatibility while allowing version customization. The fallback logic correctly handles different scenarios and preserves the original supports_v2_api? behavior.


30-33: Clean fields version query method

The fields_api_version method provides a clear interface for querying the fields-specific version, falling back appropriately to the general API version.


43-43: Good use of specialized request method

Using fields_request instead of direct request call properly implements the version override mechanism for fields operations.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/pipedrive/fields.rb (1)

63-63: Consider inlining the private modifier per Ruby conventions.

The private modifier should be inlined with the method definition according to Ruby style conventions.

Apply this diff to inline the private modifier:

-      # Fields-specific request method that uses fields_api_version
-      private def fields_request(method, url, params = {})
+      # Fields-specific request method that uses fields_api_version
+      private def fields_request(method, url, params = {})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 916b3ba and 11aa762.

📒 Files selected for processing (1)
  • lib/pipedrive/fields.rb (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: foomip
PR: getonbrd/pipedrive-connect#37
File: lib/pipedrive/api_operations/request.rb:11-13
Timestamp: 2025-04-01T14:03:34.481Z
Learning: For the Pipedrive Connect library, API version management should be implemented on a per-resource basis (by overriding the `api_version` method in individual resource classes) rather than using global configuration, to maintain consistency and ensure proper testing of each resource with newer API versions.
📚 Learning: for the pipedrive connect library, api version management should be implemented on a per-resource ba...
Learnt from: foomip
PR: getonbrd/pipedrive-connect#37
File: lib/pipedrive/api_operations/request.rb:11-13
Timestamp: 2025-04-01T14:03:34.481Z
Learning: For the Pipedrive Connect library, API version management should be implemented on a per-resource basis (by overriding the `api_version` method in individual resource classes) rather than using global configuration, to maintain consistency and ensure proper testing of each resource with newer API versions.

Applied to files:

  • lib/pipedrive/fields.rb
🔇 Additional comments (4)
lib/pipedrive/fields.rb (4)

13-16: LGTM! Clean implementation of fields version override.

The method provides a clear interface for setting fields-specific API versions, aligning with the per-resource version management approach mentioned in the retrieved learnings.


18-24: Well-designed version override with proper fallback.

The method correctly prioritizes explicit version settings while maintaining backward compatibility through the super fallback. This supports the flexible version management needed for the fields functionality.


26-29: Correct version resolution hierarchy.

The method appropriately prioritizes the fields-specific version over the general API version, providing clear and predictable behavior for version resolution.


39-39: Clean delegation to version-aware request method.

The change appropriately delegates to the specialized fields_request method while maintaining the same interface and behavior for the public API.

j4rs and others added 2 commits August 6, 2025 14:16
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@shesho shesho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@j4rs j4rs merged commit 1a29ee6 into master Aug 6, 2025
3 checks passed
@j4rs j4rs deleted the support-overriding-version-for-fields branch August 6, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants