- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - salespype #15525
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 - salespype #15525
Changes from all commits
      Commits
    
    
  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
        
          
          
            33 changes: 33 additions & 0 deletions
          
          33 
        
  components/salespype/actions/add-contact-to-campaign/add-contact-to-campaign.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,33 @@ | ||
| import salespype from "../../salespype.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "salespype-add-contact-to-campaign", | ||
| name: "Add Contact to Campaign", | ||
| description: "Adds a contact to a campaign. [See the documentation](https://documenter.getpostman.com/view/5101444/2s93Y3u1Eb#4b2f8b3e-155d-4485-9a25-4f7d98d04b53)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salespype, | ||
| campaignId: { | ||
| propDefinition: [ | ||
| salespype, | ||
| "campaignId", | ||
| ], | ||
| }, | ||
| contactId: { | ||
| propDefinition: [ | ||
| salespype, | ||
| "contactId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.salespype.addContactToCampaign({ | ||
| $, | ||
| campaignId: this.campaignId, | ||
| contactId: this.contactId, | ||
| }); | ||
| $.export("$summary", `Added contact ${this.contactId} to campaign ${this.campaignId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            88 changes: 88 additions & 0 deletions
          
          88 
        
  components/salespype/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,88 @@ | ||
| import salespype from "../../salespype.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "salespype-create-contact", | ||
| name: "Create Contact", | ||
| description: "Creates a new contact in Salespype. [See the documentation](https://documenter.getpostman.com/view/5101444/2s93Y3u1Eb#0a9f8441-c7fa-48dc-b02b-0117037d86ab)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salespype, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "The first name of the contact", | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "The last name of the contact", | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The email address of the contact", | ||
| }, | ||
| address: { | ||
| type: "string", | ||
| label: "Address", | ||
| description: "The address of the contact", | ||
| optional: true, | ||
| }, | ||
| city: { | ||
| type: "string", | ||
| label: "City", | ||
| description: "The city of the contact", | ||
| optional: true, | ||
| }, | ||
| state: { | ||
| type: "string", | ||
| label: "State", | ||
| description: "The state of the contact", | ||
| optional: true, | ||
| }, | ||
| zip: { | ||
| type: "string", | ||
| label: "ZIP Code", | ||
| description: "The ZIP code of the contact", | ||
| optional: true, | ||
| }, | ||
| country: { | ||
| type: "string", | ||
| label: "Country", | ||
| description: "The country of the contact", | ||
| optional: true, | ||
| }, | ||
| companyName: { | ||
| type: "string", | ||
| label: "Company Name", | ||
| description: "The company name of the contact", | ||
| optional: true, | ||
| }, | ||
| birthDate: { | ||
| type: "string", | ||
| label: "Birthdate", | ||
| description: "The birthdate of the contact", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const contact = await this.salespype.createContact({ | ||
| $, | ||
| data: { | ||
| firstName: this.firstName, | ||
| lastName: this.lastName, | ||
| email: this.email, | ||
| address: this.address, | ||
| city: this.city, | ||
| state: this.state, | ||
| zip: this.zip, | ||
| country: this.country, | ||
| companyName: this.companyName, | ||
| birthDate: this.birthDate, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Created contact ${this.firstName} ${this.lastName} (${this.email})`); | ||
| return contact; | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
  
    
      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,72 @@ | ||
| import salespype from "../../salespype.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "salespype-create-task", | ||
| name: "Create Task", | ||
| description: "Creates a new task in Salespype. [See the documentation](https://documenter.getpostman.com/view/5101444/2s93Y3u1Eb#a9c6449a-b844-465c-a342-deea01e52c3f)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| salespype, | ||
| contactId: { | ||
| propDefinition: [ | ||
| salespype, | ||
| "contactId", | ||
| ], | ||
| }, | ||
| task: { | ||
| type: "string", | ||
| label: "Task", | ||
| description: "The task description", | ||
| }, | ||
| taskTypeId: { | ||
| propDefinition: [ | ||
| salespype, | ||
| "taskTypeId", | ||
| ], | ||
| }, | ||
| date: { | ||
| type: "string", | ||
| label: "Date", | ||
| description: "The date for the task. E.g. `2021-02-20`", | ||
| }, | ||
| time: { | ||
| type: "string", | ||
| label: "Time", | ||
| description: "The time for the task. E.g. `34:00:34`", | ||
| }, | ||
| duration: { | ||
| type: "string", | ||
| label: "Duration", | ||
| description: "The duration of the task. E.g. `34:00:34`", | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| note: { | ||
| type: "string", | ||
| label: "Note", | ||
| description: "Additional notes for the task", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| task, message, | ||
| } = await this.salespype.createTask({ | ||
| $, | ||
| contactId: this.contactId, | ||
| data: { | ||
| task: this.task, | ||
| taskTypeId: this.taskTypeId, | ||
| date: this.date, | ||
| time: this.time, | ||
| duration: this.duration, | ||
| note: this.note, | ||
| }, | ||
| }); | ||
|  | ||
| if (message) { | ||
| throw new Error(`${message}`); | ||
| } | ||
|  | ||
| $.export("$summary", `Created task '${this.task}' with ID ${task.id}`); | ||
| return task; | ||
| }, | ||
| }; | ||
  
    
      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/salespype", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Salespype Components", | ||
| "main": "salespype.app.mjs", | ||
| "keywords": [ | ||
|  | @@ -11,5 +11,9 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3", | ||
| "md5": "^2.3.0" | ||
| } | ||
| } | ||
| } | ||
  
    
      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,11 +1,142 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|  | ||
| export default { | ||
| type: "app", | ||
| app: "salespype", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| contactId: { | ||
| type: "string", | ||
| label: "Contact ID", | ||
| description: "The unique identifier of the contact", | ||
| async options({ page }) { | ||
| const { contacts } = await this.listContacts({ | ||
| params: { | ||
| page: page + 1, | ||
| }, | ||
| }); | ||
| return contacts?.map(({ | ||
| id: value, fullName: label, | ||
| }) => ({ | ||
| value, | ||
| label, | ||
| })) || []; | ||
| }, | ||
| }, | ||
| campaignId: { | ||
| type: "string", | ||
| label: "Campaign ID", | ||
| description: "The unique identifier of the campaign", | ||
| async options({ page }) { | ||
| const { campaigns } = await this.listCampaigns({ | ||
| params: { | ||
| page: page + 1, | ||
| }, | ||
| }); | ||
| return campaigns?.map(({ | ||
| id: value, title: label, | ||
| }) => ({ | ||
| value, | ||
| label, | ||
| })) || []; | ||
| }, | ||
| }, | ||
| taskTypeId: { | ||
| type: "string", | ||
| label: "Task Type ID", | ||
| description: "The unique identifier of the task type", | ||
| async options() { | ||
| const { taskTypes } = await this.listTaskTypes(); | ||
| return taskTypes?.map(({ | ||
| id: value, task: label, | ||
| }) => ({ | ||
| value, | ||
| label, | ||
| })) || []; | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.pypepro.io/crm/v1"; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, | ||
| path, | ||
| ...otherOpts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| apikey: this.$auth.api_token, | ||
| }, | ||
| ...otherOpts, | ||
| }); | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| listContacts(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/contacts/list", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listCampaigns(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/campaigns", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listTaskTypes(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/tasks/types", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createContact(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/contacts", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| addContactToCampaign({ | ||
| campaignId, contactId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/campaigns/${campaignId}/contacts/${contactId}`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createTask({ | ||
| contactId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: `/tasks/contacts/${contactId}`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| async *paginate({ | ||
| fn, params, resourceKey, max, | ||
| }) { | ||
| params = { | ||
| ...params, | ||
| page: 0, | ||
| }; | ||
| let totalPages, count = 0; | ||
| do { | ||
| params.page++; | ||
| const results = await fn({ | ||
| params, | ||
| }); | ||
| const items = results[resourceKey]; | ||
| for (const item of items) { | ||
| yield item; | ||
| if (max && ++count >= max) { | ||
| return; | ||
| } | ||
| } | ||
| totalPages = results.totalPages; | ||
| } while (params.page < totalPages); | ||
| }, | ||
| }, | ||
| }; | ||
      
      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.