-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: onboarding new destination zoho (#3555)
* feat: initial commit * feat: adding unit test for utils * feat: adding router tests * feat: editing batching logic * feat: adding data delivery test cases * fix: fixing the endpoint bugs * feat: zoho record deletion feature (#3566) * chore: binding issue code * fix: searchRecordId function * fix: adding record deletion implementation * fix: adding record deletion test cases --------- Co-authored-by: Dilip Kola <[email protected]> * chore: adding debug logs * fix: code refactor * fix: shortening the test cases * fix: error message edit * chore: missing comma in features file * fix: adding validation for inconsistent module choice * fix: extra fields and logs removed --------- Co-authored-by: Dilip Kola <[email protected]>
- Loading branch information
1 parent
e357141
commit 20aa7f3
Showing
16 changed files
with
3,183 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,61 @@ | ||
// https://www.zoho.com/crm/developer/docs/api/v6/access-refresh.html | ||
const DATA_CENTRE_BASE_ENDPOINTS_MAP = { | ||
US: 'https://www.zohoapis.com', | ||
AU: 'https://www.zohoapis.com.au', | ||
EU: 'https://www.zohoapis.eu', | ||
IN: 'https://www.zohoapis.in', | ||
CN: 'https://www.zohoapis.com.cn', | ||
JP: 'https://www.zohoapis.jp', | ||
CA: 'https://www.zohoapiscloud.ca', | ||
}; | ||
|
||
const getBaseEndpoint = (dataServer) => DATA_CENTRE_BASE_ENDPOINTS_MAP[dataServer]; | ||
const COMMON_RECORD_ENDPOINT = (dataCenter = 'US') => | ||
`${getBaseEndpoint(dataCenter)}/crm/v6/moduleType`; | ||
|
||
// ref: https://www.zoho.com/crm/developer/docs/api/v6/insert-records.html#:~:text=%2DX%20POST-,System%2Ddefined%20mandatory%20fields%20for%20each%20module,-While%20inserting%20records | ||
const MODULE_MANDATORY_FIELD_CONFIG = { | ||
Leads: ['Last_Name'], | ||
Contacts: ['Last_Name'], | ||
Accounts: ['Account_Name'], | ||
Deals: ['Deal_Name', 'Stage', 'Pipeline'], | ||
Tasks: ['Subject'], | ||
Calls: ['Subject', 'Call_Type', 'Call_Start_Time', 'Call_Duration'], | ||
Events: ['Event_Title', 'Start_DateTime', 'Remind_At', 'End_DateTime'], | ||
Products: ['Product_Name'], | ||
Quotes: ['Subject', 'Quoted_Items'], | ||
Invoices: ['Subject', 'Invoiced_Items'], | ||
Campaigns: ['Campaign_Name'], | ||
Vendors: ['Vendor_Name'], | ||
'Price Books': ['Price_Book_Name', 'Pricing_Details'], | ||
Cases: ['Case_Origin', 'Status', 'Subject'], | ||
Solutions: ['Solution_Title'], | ||
'Purchase Orders': ['Subject', 'Vendor_Name', 'Purchased_Items'], | ||
'Sales Orders': ['Subject', 'Ordered_Items'], | ||
}; | ||
|
||
const MODULE_WISE_DUPLICATE_CHECK_FIELD = { | ||
Leads: ['Email'], | ||
Accounts: ['Account_Name'], | ||
Contacts: ['Email'], | ||
Deals: ['Deal_Name'], | ||
Campaigns: ['Campaign_Name'], | ||
Cases: ['Subject'], | ||
Solutions: ['Solution_Title'], | ||
Products: ['Product_Name'], | ||
Vendors: ['Vendor_Name'], | ||
PriceBooks: ['Price_Book_Name'], | ||
Quotes: ['Subject'], | ||
SalesOrders: ['Subject'], | ||
PurchaseOrders: ['Subject'], | ||
Invoices: ['Subject'], | ||
CustomModules: ['Name'], | ||
}; | ||
|
||
module.exports = { | ||
MAX_BATCH_SIZE: 100, | ||
DATA_CENTRE_BASE_ENDPOINTS_MAP, | ||
COMMON_RECORD_ENDPOINT, | ||
MODULE_MANDATORY_FIELD_CONFIG, | ||
MODULE_WISE_DUPLICATE_CHECK_FIELD, | ||
}; |
This file contains 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,38 @@ | ||
bindings: | ||
- name: EventType | ||
path: ../../../../constants | ||
- name: processRecordInputs | ||
path: ./transformRecord | ||
- name: handleRtTfSingleEventError | ||
path: ../../../../v0/util/index | ||
- name: InstrumentationError | ||
path: '@rudderstack/integrations-lib' | ||
|
||
steps: | ||
- name: validateConfig | ||
template: | | ||
const config = ^[0].destination.Config | ||
$.assertConfig(config.region, "Datacentre Region is not present. Aborting") | ||
- name: validateInput | ||
template: | | ||
$.assert(Array.isArray(^) && ^.length > 0, "Invalid event array") | ||
- name: processRecordEvents | ||
template: | | ||
await $.processRecordInputs(^.{.message.type === $.EventType.RECORD}[], ^[0].destination) | ||
- name: failOtherEvents | ||
template: | | ||
const otherEvents = ^.{.message.type !== $.EventType.RECORD}[] | ||
let failedEvents = otherEvents.map( | ||
function(event) { | ||
const error = new $.InstrumentationError("Event type " + event.message.type + " is not supported"); | ||
$.handleRtTfSingleEventError(event, error, {}) | ||
} | ||
) | ||
failedEvents ?? [] | ||
- name: finalPayload | ||
template: | | ||
[...$.outputs.processRecordEvents, ...$.outputs.failOtherEvents] |
Oops, something went wrong.