-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - copper #14294
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
Merged
Merged
New Components - copper #14294
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
53 changes: 53 additions & 0 deletions
53
components/copper/actions/associate-to-project/associate-to-project.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,53 @@ | ||
| import copper from "../../copper.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "copper-associate-to-project", | ||
| name: "Associate to Project", | ||
| description: "Relates an existing project with an existing CRM object. [See the documentation](https://developer.copper.com/related-items/relate-an-existing-record-to-an-entity.html)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| copper, | ||
| projectId: { | ||
| propDefinition: [ | ||
| copper, | ||
| "objectId", | ||
| () => ({ | ||
| objectType: "projects", | ||
| }), | ||
| ], | ||
| label: "Project ID", | ||
| description: "The ID of the project you wish to relate", | ||
| }, | ||
| objectType: { | ||
| propDefinition: [ | ||
| copper, | ||
| "objectType", | ||
| ], | ||
| }, | ||
| objectId: { | ||
| propDefinition: [ | ||
| copper, | ||
| "objectId", | ||
| (c) => ({ | ||
| objectType: c.objectType, | ||
| }), | ||
| ], | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.copper.relateProjectToCrmObject({ | ||
| $, | ||
| objectType: this.objectType, | ||
| objectId: this.objectId, | ||
| data: { | ||
| resource: { | ||
| id: this.projectId, | ||
| type: "project", | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully associated Project ID ${this.projectId} with CRM ID ${this.objectId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
126 changes: 126 additions & 0 deletions
126
components/copper/actions/create-update-person/create-update-person.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,126 @@ | ||
| import copper from "../../copper.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "copper-create-update-person", | ||
| name: "Create or Update Person", | ||
| description: "Creates a new person or updates an existing one based on email address. [See the documentation](https://developer.copper.com/people/create-a-new-person.html)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| copper, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "Email address of the person. If email already exists, the person will be updated", | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the contact. Required if creating a new person.", | ||
| optional: true, | ||
| }, | ||
| streetAddress: { | ||
| type: "string", | ||
| label: "Street Address", | ||
| description: "Street address of the person", | ||
| optional: true, | ||
| }, | ||
| city: { | ||
| type: "string", | ||
| label: "City", | ||
| description: "City address of the person", | ||
| optional: true, | ||
| }, | ||
| state: { | ||
| type: "string", | ||
| label: "State", | ||
| description: "State address of the person", | ||
| optional: true, | ||
| }, | ||
| postalCode: { | ||
| type: "string", | ||
| label: "Postal Code", | ||
| description: "Postal code of the person", | ||
| optional: true, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| country: { | ||
| type: "string", | ||
| label: "Country", | ||
| description: "Country of the person", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone", | ||
| description: "Phone number of the person", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| let response; | ||
| const hasAddress = this.streetAddress | ||
| || this.city | ||
| || this.state | ||
| || this.postalCode | ||
| || this.country; | ||
| const data = { | ||
| emails: [ | ||
| { | ||
| email: this.email, | ||
| category: "work", | ||
| }, | ||
| ], | ||
| name: this.name, | ||
| address: hasAddress && { | ||
| street: this.streetAddress, | ||
| city: this.city, | ||
| state: this.state, | ||
| postal_code: this.postalCode, | ||
| country: this.country, | ||
| }, | ||
| phone_numbers: this.phone && [ | ||
| { | ||
| number: this.phone, | ||
| category: "work", | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| // search for the person | ||
| const person = await this.copper.listObjects({ | ||
| $, | ||
| objectType: "people", | ||
| data: { | ||
| emails: [ | ||
| this.email, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| if (!person?.length && !this.name) { | ||
| throw new ConfigurationError(`Person with email ${this.email} not found. Name is required for creating a new person.`); | ||
| } | ||
|
|
||
| // create person if not found | ||
| if (!person?.length) { | ||
| response = await this.copper.createPerson({ | ||
| $, | ||
| data, | ||
| }); | ||
| } | ||
| // update person if found | ||
| else { | ||
| response = await this.copper.updatePerson({ | ||
| $, | ||
| personId: person[0].id, | ||
| data, | ||
| }); | ||
| } | ||
|
|
||
| $.export("$summary", `Successfully ${person?.length | ||
| ? "updated" | ||
| : "created"} person with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
86 changes: 86 additions & 0 deletions
86
components/copper/actions/create-update-project/create-update-project.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,86 @@ | ||
| import copper from "../../copper.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "copper-create-update-project", | ||
| name: "Create or Update Project", | ||
| description: "Creates a new project or updates an existing one based on the project name. [See the documentation](https://developer.copper.com/projects/create-a-new-project.html)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| copper, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the project. If a project with the specified name already exists, it will be updated", | ||
| }, | ||
| details: { | ||
| type: "string", | ||
| label: "Details", | ||
| description: "Description of the Project", | ||
| optional: true, | ||
| }, | ||
| assigneeId: { | ||
| propDefinition: [ | ||
| copper, | ||
| "objectId", | ||
| () => ({ | ||
| objectType: "users", | ||
| }), | ||
| ], | ||
| label: "Assignee ID", | ||
| description: "The ID of the User that will be the owner of the Project", | ||
| optional: true, | ||
| }, | ||
| status: { | ||
| propDefinition: [ | ||
| copper, | ||
| "status", | ||
| ], | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| tags: { | ||
| propDefinition: [ | ||
| copper, | ||
| "tags", | ||
| ], | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| let response; | ||
| const data = { | ||
| name: this.name, | ||
| assignee_id: this.assigneeId, | ||
| status: this.status, | ||
| tags: this.tags, | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // search for the project | ||
| const project = await this.copper.listObjects({ | ||
| $, | ||
| objectType: "projects", | ||
| data: { | ||
| name: this.name, | ||
| }, | ||
| }); | ||
|
|
||
| // create project if not found | ||
| if (!project?.length) { | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| response = await this.copper.createProject({ | ||
| $, | ||
| data, | ||
| }); | ||
| } | ||
| // update project if found | ||
| else { | ||
| response = await this.copper.updateProject({ | ||
| $, | ||
| projectId: project[0].id, | ||
| data, | ||
| }); | ||
| } | ||
|
|
||
| $.export("$summary", `Successfully ${project?.length | ||
| ? "updated" | ||
| : "created"} project with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
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,36 @@ | ||
| import copper from "../../copper.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "copper-get-object", | ||
| name: "Get Object", | ||
| description: "Retrieves an existing CRM object. [See the documentation](https://developer.copper.com/account-and-users/fetch-user-by-id.html)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| copper, | ||
| objectType: { | ||
| propDefinition: [ | ||
| copper, | ||
| "objectType", | ||
| ], | ||
| }, | ||
| objectId: { | ||
| propDefinition: [ | ||
| copper, | ||
| "objectId", | ||
| (c) => ({ | ||
| objectType: c.objectType, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.copper.getObject({ | ||
| objectType: this.objectType, | ||
| objectId: this.objectId, | ||
| $, | ||
| }); | ||
| $.export("$summary", `Successfully retrieved CRM object with ID ${this.objectId}`); | ||
| return response; | ||
| }, | ||
| }; |
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.