Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14645 components zoho books #14866

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Dec 5, 2024

Resolves #14645

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced webhook management methods: createWebhook and deleteWebhook for enhanced integration capabilities.
    • New modules for handling "New Customer," "New Expense," and "New Sales Order" events, including metadata generation and event emission.
  • Improvements

    • Transitioned to a webhook-based approach for event handling, improving responsiveness and efficiency.
  • Data Structures

    • Added detailed representations for customer, expense, and sales order records, encapsulating all relevant information for seamless processing.

luancazarine and others added 6 commits November 28, 2024 14:05
- Component refactoring

Sources
 - New Customer
 - New Expense
 - New Sales Invoice

Actions
 - Create Customer
 - Create Estimate
Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 9:54pm
pipedream-docs ⬜️ Ignored (Inspect) Dec 5, 2024 9:54pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Dec 5, 2024 9:54pm

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Warning

Rate limit exceeded

@luancazarine has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1a24a and abf5f16.

Walkthrough

The changes involve significant updates to the Zoho Books integration modules, particularly in the handling of webhook functionality. The existing base module has been modified to include properties for HTTP and webhook naming, while methods for managing hook IDs have been introduced. New modules for "New Customer," "New Expense," and "New Sales Order" events have been added, each implementing specific methods for generating metadata and handling events. Additionally, the main application module now includes methods for creating and deleting webhooks.

Changes

File Path Change Summary
components/zoho_books/sources/common/base.mjs Added properties http, webhookName; replaced _getLastDate with _getHookId; added activate and deactivate hooks; modified run method.
components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs Introduced new module for handling "New Customer" events; added methods getEntity and generateMeta.
components/zoho_books/sources/new-customer-instant/test-event.mjs New module for customer contact data structure.
components/zoho_books/sources/new-expense-instant/new-expense-instant.mjs Introduced new module for handling "New Expense" events; added methods getEntity and generateMeta.
components/zoho_books/sources/new-expense-instant/test-event.mjs New module for expense record data structure.
components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs Introduced new module for handling "New Sales Order" events; added methods getEntity and generateMeta.
components/zoho_books/sources/new-sales-order-instant/test-event.mjs New module for sales order data structure.
components/zoho_books/zoho_books.app.mjs Added methods createWebhook and deleteWebhook for managing webhooks.

Assessment against linked issues

Objective Addressed Explanation
Emit new event when a new customer is created. (#14645)
Emit new event when a new expense is created. (#14645)
Emit new event when a new sales invoice is generated. (#14645) No changes related to sales invoice events were made.
Create a new customer with required props. (#14645) The implementation details for required props are unclear.
Initiate creation of a new estimate. (#14645) No changes related to estimate creation were made.

Possibly related PRs

Suggested labels

action, trigger / source

Suggested reviewers

  • jcortes

Poem

In the land of code where rabbits dwell,
New hooks and events, we weave a spell.
With customers and expenses, we take our flight,
Webhooks in hand, we're ready to write!
So hop along, let the changes unfold,
In the world of Zoho, new stories are told! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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: 4

🧹 Outside diff range and nitpick comments (4)
components/zoho_books/sources/new-expense-instant/test-event.mjs (1)

66-66: Provide valid date string for 'last_modified_time'

The last_modified_time field currently contains an empty string. To ensure accurate testing and avoid parsing errors, consider providing a valid date string.

components/zoho_books/sources/new-sales-order-instant/test-event.mjs (1)

1-110: LGTM! Test event structure is well-defined.

The test event provides comprehensive coverage of sales order fields and uses appropriate test data values. The structure aligns with Zoho Books API requirements.

Consider adding comments to document the purpose of this test event file and how it should be used in testing scenarios.

components/zoho_books/sources/new-customer-instant/test-event.mjs (1)

1-114: LGTM! Comprehensive test event structure with appropriate test data.

The test event includes all necessary fields for customer contacts and uses appropriate test values.

Consider:

  1. Adding a comment header explaining the purpose of this test event
  2. Using consistent example domains (e.g., example.com) for all email addresses instead of bowmanfurniture.com
components/zoho_books/zoho_books.app.mjs (1)

606-612: Consider adding parameter validation for webhook creation.

The createWebhook method should validate required webhook parameters before making the request.

Consider adding parameter validation:

 createWebhook(opts = {}) {
+  const { url, events } = opts.data || {};
+  if (!url || !events?.length) {
+    throw new Error('Webhook URL and at least one event are required');
+  }
   return this._makeRequest({
     method: "POST",
     path: "/settings/webhooks",
     ...opts,
   });
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cc7d7f6 and 8f1a24a.

📒 Files selected for processing (8)
  • components/zoho_books/sources/common/base.mjs (1 hunks)
  • components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs (1 hunks)
  • components/zoho_books/sources/new-customer-instant/test-event.mjs (1 hunks)
  • components/zoho_books/sources/new-expense-instant/new-expense-instant.mjs (1 hunks)
  • components/zoho_books/sources/new-expense-instant/test-event.mjs (1 hunks)
  • components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs (1 hunks)
  • components/zoho_books/sources/new-sales-order-instant/test-event.mjs (1 hunks)
  • components/zoho_books/zoho_books.app.mjs (1 hunks)
🔇 Additional comments (6)
components/zoho_books/sources/common/base.mjs (2)

6-11: Props are defined correctly

The added props http, db, and webhookName are correctly defined and consistent with best practices.


15-19: Private methods for hook ID management are well implemented

The _getHookId and _setHookId methods correctly manage the webhook ID in the database.

components/zoho_books/sources/new-expense-instant/new-expense-instant.mjs (1)

1-26: The "New Expense (Instant)" module is correctly implemented

The module correctly extends the common base, and methods getEntity and generateMeta are properly defined.

components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs (1)

1-26: The "New Customer (Instant)" module is correctly implemented

The module properly extends the common base, and methods getEntity and generateMeta are correctly defined.

components/zoho_books/sources/new-sales-order-instant/new-sales-order-instant.mjs (1)

1-26: The "New Sales Order (Instant)" module is implemented correctly

Except for the issue noted above, the module correctly extends the common base, and methods are properly defined.

components/zoho_books/zoho_books.app.mjs (1)

613-618: LGTM! Webhook deletion implementation is clean and follows existing patterns.

The deleteWebhook method is well-implemented and consistent with other deletion methods in the file.

@vunguyenhung
Copy link
Collaborator

Hello everyone, I have tested this PR and there're some test cases failed or needed improvement.

Please check the test report below for more information
https://vunguyenhung.notion.site/14645-components-zoho-books-158bf548bb5e81edaeedfe5754c6f7f9

@luancazarine
Copy link
Collaborator Author

Hello everyone, I have tested this PR and there're some test cases failed or needed improvement.

Please check the test report below for more information https://vunguyenhung.notion.site/14645-components-zoho-books-158bf548bb5e81edaeedfe5754c6f7f9

Hi @vunguyenhung, ZohoBooks has a way to test your webhook in their UI. You can try it by going to Settings -> Automation -> Workflow Actions -> Webhooks, then you select the webhook you want to test and at the bottom of the page click on run.
When you do this, the webhook receives the trigger, so as far as I know it is working correctly, but when you create a new expense manually, they do not send it, this is a bit strange behavior.
So I think the error is on their side.
What do you think is better to do? Remove this trigger?

@vunguyenhung
Copy link
Collaborator

vunguyenhung commented Dec 11, 2024

Hi @luancazarine, I think we could not release the sources if they don't work from end user perspective.

The next action I would say is to maybe ask @malexanderlim or @sergioeliot2039 to connect Zoho book team about this issue, because they already in contact with the Zoho book team (I assume so).

Then while waiting for updates, we can move this to Blocked.

@luancazarine luancazarine self-assigned this Dec 11, 2024
@malexanderlim
Copy link
Collaborator

@luancazarine @vunguyenhung I've added you to the thread with Zoho Books.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Components] zoho-books
4 participants