- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - zendesk_sell #14583
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
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            3 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
        
          
          
            91 changes: 91 additions & 0 deletions
          
          91 
        
  components/zendesk_sell/actions/create-contact/create-contact.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,91 @@ | ||
| import zendeskSell from "../../zendesk_sell.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "zendesk_sell-create-contact", | ||
| name: "Create Contact", | ||
| description: "Creates a new contact. [See the documentation](https://developer.zendesk.com/api-reference/sales-crm/resources/contacts/#create-a-contact).", | ||
| type: "action", | ||
| version: "0.0.1", | ||
| props: { | ||
| zendeskSell, | ||
| isOrganization: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "isOrganization", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| status: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "status", | ||
| ], | ||
| }, | ||
| title: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "title", | ||
| ], | ||
| }, | ||
| description: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "description", | ||
| ], | ||
| }, | ||
| email: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "email", | ||
| ], | ||
| }, | ||
| phone: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "phone", | ||
| ], | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (this.isOrganization) { | ||
| props.name = { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the contact", | ||
| }; | ||
| } else { | ||
| props.firstName = { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "First name of the contact", | ||
| }; | ||
| props.lastName = { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "Last name of the contact", | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.zendeskSell.createContact({ | ||
| $, | ||
| data: { | ||
| data: { | ||
| is_organization: this.isOrganization, | ||
| name: this.name, | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| customer_status: this.status, | ||
| title: this.title, | ||
| description: this.description, | ||
| email: this.email, | ||
| phone: this.phone, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created contact with ID ${response.data.id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            96 changes: 96 additions & 0 deletions
          
          96 
        
  components/zendesk_sell/actions/create-lead/create-lead.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,96 @@ | ||
| import zendeskSell from "../../zendesk_sell.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "zendesk_sell-create-lead", | ||
| name: "Create Lead", | ||
| description: "Creates a new lead. [See the documentation](https://developer.zendesk.com/api-reference/sales-crm/resources/leads/#create-a-lead).", | ||
| type: "action", | ||
| version: "0.0.1", | ||
| props: { | ||
| zendeskSell, | ||
| isOrganization: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "isOrganization", | ||
| ], | ||
| description: "Indicator of whether or not this lead refers to an organization or an individual", | ||
| reloadProps: true, | ||
| }, | ||
| status: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "status", | ||
| ], | ||
| description: "The status of the lead", | ||
| }, | ||
| title: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "title", | ||
| ], | ||
| description: "The lead’s job title", | ||
| }, | ||
| description: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "description", | ||
| ], | ||
| description: "The lead’s description", | ||
| }, | ||
| email: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "email", | ||
| ], | ||
| description: "The lead’s email address", | ||
| }, | ||
| phone: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "phone", | ||
| ], | ||
| description: "The lead’s phone number", | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (this.isOrganization) { | ||
| props.name = { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "Name of the lead", | ||
| }; | ||
| } else { | ||
| props.firstName = { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "First name of the lead", | ||
| }; | ||
| props.lastName = { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "Last name of the lead", | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| async run({ $ }) { | ||
| const response = await this.zendeskSell.createLead({ | ||
| $, | ||
| data: { | ||
| data: { | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| organization_name: this.name, | ||
| status: this.status, | ||
| title: this.title, | ||
| description: this.description, | ||
| email: this.email, | ||
| phone: this.phone, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created lead with ID ${response.data.id}`); | ||
| return response; | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
        
          
          
            86 changes: 86 additions & 0 deletions
          
          86 
        
  components/zendesk_sell/actions/create-task/create-task.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 zendeskSell from "../../zendesk_sell.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "zendesk_sell-create-task", | ||
| name: "Create Task", | ||
| description: "Creates a new task. [See the documentation](https://developer.zendesk.com/api-reference/sales-crm/resources/tasks/#create-a-task).", | ||
| type: "action", | ||
| version: "0.0.1", | ||
| props: { | ||
| zendeskSell, | ||
| resourceType: { | ||
| type: "string", | ||
| label: "Resource Type", | ||
| description: "Name of the resource type the task is attached to", | ||
| options: [ | ||
| "contact", | ||
| "lead", | ||
| "deal", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| contactId: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "contactId", | ||
| ], | ||
| hidden: true, | ||
| }, | ||
| leadId: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "leadId", | ||
| ], | ||
| hidden: true, | ||
| }, | ||
| dealId: { | ||
| propDefinition: [ | ||
| zendeskSell, | ||
| "dealId", | ||
| ], | ||
| hidden: true, | ||
| }, | ||
| content: { | ||
| type: "string", | ||
| label: "Content", | ||
| description: "Content of the task", | ||
| }, | ||
| completed: { | ||
| type: "boolean", | ||
| label: "Completed", | ||
| description: "Indicator of whether the task is completed or not", | ||
| optional: true, | ||
| }, | ||
| dueDate: { | ||
| type: "string", | ||
| label: "Due Date", | ||
| description: "Date and time the task is due in UTC (ISO8601 format)", | ||
| optional: true, | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }, | ||
| async additionalProps(props) { | ||
| props.contactId.hidden = this.resourceType !== "contact"; | ||
| props.leadId.hidden = this.resourceType !== "lead"; | ||
| props.dealId.hidden = this.resourceType !== "deal"; | ||
| return {}; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.zendeskSell.createTask({ | ||
| $, | ||
| data: { | ||
| data: { | ||
| resource_type: this.resourceType, | ||
| resource_id: this.resourceType === "contact" | ||
| ? this.contactId | ||
| : this.resourceType === "lead" | ||
| ? this.leadId | ||
| : this.dealId, | ||
| content: this.content, | ||
| completed: this.completed, | ||
| due_date: this.dueDate, | ||
| }, | ||
| }, | ||
| }); | ||
| 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 | 
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/zendesk_sell", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Zendesk Sell Components", | ||
| "main": "zendesk_sell.app.mjs", | ||
| "keywords": [ | ||
|  | @@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
  
    
      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 zendeskSell from "../../zendesk_sell.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|  | ||
| export default { | ||
| props: { | ||
| zendeskSell, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.processEvent(25); | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastTs() { | ||
| return this.db.get("lastTs") || 0; | ||
| }, | ||
| _setLastTs(lastTs) { | ||
| this.db.set("lastTs", lastTs); | ||
| }, | ||
| getTsField() { | ||
| return "created_at"; | ||
| }, | ||
| getParams() { | ||
| return { | ||
| sort_by: `${this.getTsField()}:desc`, | ||
| }; | ||
| }, | ||
| generateMeta(item) { | ||
| return { | ||
| id: item.id, | ||
| summary: this.getSummary(item), | ||
| ts: Date.parse(item[this.getTsField()]), | ||
| }; | ||
| }, | ||
| getResourceFn() { | ||
| throw new Error("getResourceFn is not implemented"); | ||
| }, | ||
| getSummary() { | ||
| throw new Error("getSummary is not implemented"); | ||
| }, | ||
| async processEvent(max) { | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| const lastTs = this._getLastTs(); | ||
| const fn = this.getResourceFn(); | ||
| const params = this.getParams(); | ||
| const tsField = this.getTsField(); | ||
|  | ||
| const results = this.zendeskSell.paginate({ | ||
| fn, | ||
| params, | ||
| max, | ||
| }); | ||
|  | ||
| const items = []; | ||
| for await (const result of results) { | ||
| const { data: item } = result; | ||
| const ts = Date.parse(item[tsField]); | ||
| if (ts >= lastTs) { | ||
| items.push(item); | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
|  | ||
| if (!items?.length) { | ||
| return; | ||
| } | ||
|  | ||
| this._setLastTs(Date.parse(items[0][tsField])); | ||
|  | ||
| items.forEach((item) => { | ||
| const meta = this.generateMeta(item); | ||
| this.$emit(item, meta); | ||
| }); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.processEvent(); | ||
| }, | ||
| }; | ||
      
      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.