-
Notifications
You must be signed in to change notification settings - Fork 274
Salesforce custom object external #2485
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
seg-leonelsanches
wants to merge
9
commits into
main
Choose a base branch
from
salesforce-custom-object-external-id
base: main
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
96549af
Initial implementation.
seg-leonelsanches 231fa0f
- Moving upser custom object by id logic to the original class;
seg-leonelsanches c82872a
Stubbing unit tests for new Salesforce action.
seg-leonelsanches 9bb99c3
Merge remote-tracking branch 'origin/main' into salesforce-custom-obj…
seg-leonelsanches 295e887
Updating unit tests.
seg-leonelsanches 23b1fa5
Removing sync mode. This destination is not intended to be used as a …
seg-leonelsanches 60826ff
Interface exports are no longer necessary.
seg-leonelsanches 487f516
Merge remote-tracking branch 'origin/main' into salesforce-custom-obj…
seg-leonelsanches 2ec8f2f
Merge remote-tracking branch 'origin/main' into salesforce-custom-obj…
seg-leonelsanches 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
5 changes: 5 additions & 0 deletions
5
packages/destination-actions/src/destinations/optimizely-web/trackEvent/constants.ts
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 +1,6 @@ | ||
export const PAGE = 'page' | ||
|
||
export const TRACK = 'track' | ||
|
||
export const SUPPORTED_TYPES = [PAGE, TRACK] | ||
export const MAX_CUSTOM_PROPS_PER_EVENT = 15 |
2 changes: 1 addition & 1 deletion
2
packages/destination-actions/src/destinations/reddit-audiences/const.ts
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,2 +1,2 @@ | ||
export const EMAIL_SCHEMA_NAME = 'EMAIL_SHA256' | ||
export const MAID_SCHEMA_NAME = 'MAID_SHA256' | ||
export const MAID_SCHEMA_NAME = 'MAID_SHA256' |
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
23 changes: 11 additions & 12 deletions
23
packages/destination-actions/src/destinations/reddit-audiences/types.ts
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,23 +1,22 @@ | ||
|
||
import { MAID_SCHEMA_NAME, EMAIL_SCHEMA_NAME } from './const' | ||
|
||
export interface CreateAudienceResp { | ||
id: string | ||
id: string | ||
} | ||
|
||
export interface CreateAudienceReq { | ||
data: { | ||
name: string | ||
type: string | ||
} | ||
data: { | ||
name: string | ||
type: string | ||
} | ||
} | ||
|
||
export interface UpdateAudienceReq { | ||
data: { | ||
column_order: Columns | ||
user_data: string[][], | ||
action_type: 'ADD' | 'REMOVE' | ||
} | ||
data: { | ||
column_order: Columns | ||
user_data: string[][] | ||
action_type: 'ADD' | 'REMOVE' | ||
} | ||
} | ||
|
||
export type Columns = (typeof MAID_SCHEMA_NAME | typeof EMAIL_SCHEMA_NAME)[] | ||
export type Columns = (typeof MAID_SCHEMA_NAME | typeof EMAIL_SCHEMA_NAME)[] |
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
56 changes: 56 additions & 0 deletions
56
.../destination-actions/src/destinations/salesforce/__tests__/customObjectExternalId.test.ts
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,56 @@ | ||
import nock from 'nock' | ||
import { createTestEvent, createTestIntegration } from '@segment/actions-core' | ||
import Destination from '../index' | ||
import { API_VERSION } from '../sf-operations' | ||
|
||
const testDestination = createTestIntegration(Destination) | ||
|
||
const settings = { | ||
instanceUrl: 'https://test.salesforce.com' | ||
} | ||
|
||
describe('Salesforce', () => { | ||
describe('Custom Object by External Id', () => { | ||
it('Should end events successfully', async () => { | ||
const customObjectName = 'TestCustom__c' | ||
const objectExternalId = 'Prospect__c' | ||
const externalIdValue = '123456-7890-ABCD-0123-45678901234567' | ||
const event = createTestEvent({ | ||
type: 'track', | ||
event: 'Create Custom Object', | ||
properties: { | ||
email: 'sponge@seamail.com', | ||
company: 'Krusty Krab', | ||
last_name: 'Squarepants', | ||
object_type: objectExternalId | ||
}, | ||
userId: externalIdValue | ||
}) | ||
|
||
nock(`${settings.instanceUrl}/services/data/${API_VERSION}/sobjects`) | ||
.patch(`/${customObjectName}/${objectExternalId}/${externalIdValue}`) | ||
.reply(200, {}) | ||
|
||
const responses = await testDestination.testAction('customObjectExternalId', { | ||
event, | ||
settings, | ||
mapping: { | ||
operation: 'create', | ||
customObjectName: customObjectName, | ||
externalIdField: { | ||
'@path': '$.properties.object_type' | ||
}, | ||
externalIdValue: { | ||
'@path': '$.userId' | ||
}, | ||
customFields: { | ||
'@path': '$.properties' | ||
} | ||
} | ||
}) | ||
|
||
expect(responses.length).toBe(1) | ||
expect(responses[0].status).toBe(200) | ||
}) | ||
}) | ||
}) |
33 changes: 33 additions & 0 deletions
33
...destination-actions/src/destinations/salesforce/customObjectExternalId/generated-types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
packages/destination-actions/src/destinations/salesforce/customObjectExternalId/index.ts
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,52 @@ | ||
import type { ActionDefinition, ExecuteInput, RequestClient } from '@segment/actions-core' | ||
import type { Settings } from '../generated-types' | ||
import type { Payload } from './generated-types' | ||
import { customFields, operation } from '../sf-properties' | ||
import Salesforce, { generateSalesforceRequest } from '../sf-operations' | ||
|
||
const action: ActionDefinition<Settings, Payload> = { | ||
title: 'Custom Object by External Id', | ||
description: | ||
'Create, update, or upsert records in any custom or standard object in Salesforce, using its External ID.', | ||
fields: { | ||
operation: operation, | ||
customObjectName: { | ||
label: 'Salesforce Object', | ||
description: | ||
'The API name of the Salesforce object that records will be added or updated within. This can be a standard or custom object. Custom objects must be predefined in your Salesforce account and should end with "__c".', | ||
type: 'string', | ||
required: true, | ||
dynamic: true | ||
}, | ||
externalIdField: { | ||
label: 'External ID Field', | ||
description: 'The name of the field that will be used as the External ID.', | ||
type: 'string', | ||
required: true | ||
}, | ||
externalIdValue: { | ||
label: 'External Id Value', | ||
description: 'The external id field value that will be used to update the record.', | ||
type: 'string', | ||
required: true | ||
}, | ||
customFields: customFields | ||
}, | ||
dynamicFields: { | ||
customObjectName: async (request: RequestClient, data: ExecuteInput<Settings, Payload, any, any, any>) => { | ||
const salesforceInstance: Salesforce = new Salesforce( | ||
data.settings.instanceUrl, | ||
await generateSalesforceRequest(data.settings, request) | ||
) | ||
|
||
return salesforceInstance.customObjectName() | ||
} | ||
}, | ||
perform: async (request, { settings, payload }) => { | ||
const sf: Salesforce = new Salesforce(settings.instanceUrl, await generateSalesforceRequest(settings, request)) | ||
|
||
return sf.upsertCustomObject(payload, payload.customObjectName) | ||
} | ||
} | ||
|
||
export default action |
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
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.