-
Notifications
You must be signed in to change notification settings - Fork 5.5k
14645 components zoho books #14866
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
Open
luancazarine
wants to merge
10
commits into
master
Choose a base branch
from
14645-components-zoho-books
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
14645 components zoho books #14866
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bb67812
[Components] zoho-books #14645
luancazarine ebe7054
pnpm update
luancazarine 0629d53
some adjusts
luancazarine 74c0ff0
some adjusts
luancazarine 21b5042
Improve description
vunguyenhung 424a86c
change polling to webhooks
luancazarine 8f1a24a
Merge branch 'master' into 14645-components-zoho-books
luancazarine 64da116
bump versions
luancazarine 83daab7
bump versions
luancazarine abf5f16
fix branch
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,45 @@ | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
| import zohoBooks from "../../zoho_books.app.mjs"; | ||
|
|
||
| export default { | ||
| props: { | ||
| zohoBooks, | ||
| http: "$.interface.http", | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| webhookName: { | ||
| type: "string", | ||
| label: "Webhook Name", | ||
| description: "A name to identify the webhook.", | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastDate() { | ||
| return this.db.get("lastDate") || 0; | ||
| _getHookId() { | ||
| return this.db.get("hookId"); | ||
| }, | ||
| _setLastDate(lastDate) { | ||
| this.db.set("lastDate", lastDate); | ||
| }, | ||
| async emitEvent(maxResults = false) { | ||
| const lastDate = this._getLastDate(); | ||
|
|
||
| const response = this.zohoBooks.paginate({ | ||
| fn: this.getFunction(), | ||
| fieldName: this.getFieldName(), | ||
| }); | ||
|
|
||
| let responseArray = []; | ||
| for await (const item of response) { | ||
| if (item.created_time <= lastDate) break; | ||
| responseArray.push(item); | ||
| } | ||
|
|
||
| if (responseArray.length) { | ||
| if (maxResults && (responseArray.length > maxResults)) { | ||
| responseArray.length = maxResults; | ||
| } | ||
| this._setLastDate(Date.parse(responseArray[0].created_time)); | ||
| } | ||
|
|
||
| for (const item of responseArray.reverse()) { | ||
| this.$emit(item, { | ||
| id: item[this.getFieldId()], | ||
| summary: this.getSummary(item), | ||
| ts: Date.parse(item.created_time), | ||
| }); | ||
| } | ||
| _setHookId(hookId) { | ||
| this.db.set("hookId", hookId); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.emitEvent(25); | ||
| async activate() { | ||
| const { webhook } = await this.zohoBooks.createWebhook({ | ||
| data: { | ||
| webhook_name: this.webhookName, | ||
| url: this.http.endpoint, | ||
| entity: this.getEntity(), | ||
| method: "POST", | ||
| body_type: "application/json", | ||
| raw_data: "${JSONString}", | ||
| }, | ||
| }); | ||
| this._setHookId(webhook.webhook_id); | ||
| }, | ||
| async deactivate() { | ||
| const webhookId = this._getHookId(); | ||
| await this.zohoBooks.deleteWebhook(webhookId); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.emitEvent(); | ||
| async run({ body }) { | ||
| if (body.payload === "") return true; | ||
| this.$emit(body, this.generateMeta(body)); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/zoho_books/sources/new-customer-instant/new-customer-instant.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import common from "../common/base.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "zoho_books-new-customer-instant", | ||
| name: "New Customer (Instant)", | ||
| description: "Emit new event when a new customer is created.", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEntity() { | ||
| return "customer"; | ||
| }, | ||
| generateMeta({ contact }) { | ||
| return { | ||
| id: contact.contact_id, | ||
| summary: `New Customer: ${contact.contact_name}`, | ||
| ts: Date.parse(contact.created_time), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; |
114 changes: 114 additions & 0 deletions
114
components/zoho_books/sources/new-customer-instant/test-event.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| export default { | ||
| "contact": { | ||
| "contact_id": 460000000026049, | ||
| "contact_name": "Bowman and Co", | ||
| "company_name": "Bowman and Co", | ||
| "has_transaction": true, | ||
| "contact_type": "customer", | ||
| "customer_sub_type": "business", | ||
| "credit_limit": 1000, | ||
| "is_taxable": true, | ||
| "tax_id": 11149000000061058, | ||
| "tax_name": "CGST", | ||
| "tax_percentage": 12, | ||
| "tax_authority_id": 11149000000061052, | ||
| "tax_exemption_id": 11149000000061054, | ||
| "tax_authority_name": "string", | ||
| "tax_exemption_code": "string", | ||
| "place_of_contact": "TN", | ||
| "gst_no": "22AAAAA0000A1Z5", | ||
| "tax_treatment": "string", | ||
| "tax_regime": "general_legal_person", | ||
| "legal_name": "ESCUELA KEMPER URGATE", | ||
| "is_tds_registered": true, | ||
| "vat_treatment": "string", | ||
| "gst_treatment": "business_gst", | ||
| "is_linked_with_zohocrm": false, | ||
| "website": "www.bowmanfurniture.com", | ||
| "owner_id": 460000000016051, | ||
| "primary_contact_id": 460000000026051, | ||
| "payment_terms": 15, | ||
| "payment_terms_label": "Net 15", | ||
| "currency_id": 460000000000097, | ||
| "currency_code": "USD", | ||
| "currency_symbol": "$", | ||
| "opening_balance_amount": 1200, | ||
| "exchange_rate": 1, | ||
| "outstanding_receivable_amount": 250, | ||
| "outstanding_receivable_amount_bcy": 250, | ||
| "unused_credits_receivable_amount": 1369.66, | ||
| "unused_credits_receivable_amount_bcy": 1369.66, | ||
| "status": "active", | ||
| "facebook": "zoho", | ||
| "twitter": "zoho", | ||
| "payment_reminder_enabled": true, | ||
| "custom_fields": [ | ||
| { | ||
| "index": 1, | ||
| "value": "GBGD078", | ||
| "label": "VAT ID" | ||
| } | ||
| ], | ||
| "billing_address": { | ||
| "attention": "Mr.John", | ||
| "address": "4900 Hopyard Rd", | ||
| "street2": "Suite 310", | ||
| "state_code": "CA", | ||
| "city": "Pleasanton", | ||
| "state": "CA", | ||
| "zip": 94588, | ||
| "country": "U.S.A", | ||
| "fax": "+1-925-924-9600", | ||
| "phone": "+1-925-921-9201" | ||
| }, | ||
| "shipping_address": { | ||
| "attention": "Mr.John", | ||
| "address": "4900 Hopyard Rd", | ||
| "street2": "Suite 310", | ||
| "state_code": "CA", | ||
| "city": "Pleasanton", | ||
| "state": "CA", | ||
| "zip": 94588, | ||
| "country": "U.S.A", | ||
| "fax": "+1-925-924-9600", | ||
| "phone": "+1-925-921-9201" | ||
| }, | ||
| "contact_persons": [ | ||
| { | ||
| "contact_person_id": 460000000026051, | ||
| "salutation": "Mr", | ||
| "first_name": "Will", | ||
| "last_name": "Smith", | ||
| "email": "[email protected]", | ||
| "phone": "+1-925-921-9201", | ||
| "mobile": "+1-4054439562", | ||
| "designation": "Sales Executive", | ||
| "department": "Sales and Marketing", | ||
| "skype": "Zoho", | ||
| "is_primary_contact": true, | ||
| "enable_portal": true | ||
| } | ||
| ], | ||
| "default_templates": { | ||
| "invoice_template_id": 460000000052069, | ||
| "estimate_template_id": 460000000000179, | ||
| "creditnote_template_id": 460000000000211, | ||
| "purchaseorder_template_id": 460000000000213, | ||
| "salesorder_template_id": 460000000000214, | ||
| "retainerinvoice_template_id": 460000000000215, | ||
| "paymentthankyou_template_id": 460000000000216, | ||
| "retainerinvoice_paymentthankyou_template_id": 460000000000217, | ||
| "invoice_email_template_id": 460000000052071, | ||
| "estimate_email_template_id": 460000000052073, | ||
| "creditnote_email_template_id": 460000000052075, | ||
| "purchaseorder_email_template_id": 460000000000218, | ||
| "salesorder_email_template_id": 460000000000219, | ||
| "retainerinvoice_email_template_id": 460000000000220, | ||
| "paymentthankyou_email_template_id": 460000000000221, | ||
| "retainerinvoice_paymentthankyou_email_template_id": 460000000000222 | ||
| }, | ||
| "notes": "Payment option : Through check", | ||
| "created_time": "2013-08-05T12:06:10+0530", | ||
| "last_modified_time": "2013-10-07T18:24:51+0530" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.