- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - hullo #14271
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 - hullo #14271
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
        
          
          
            102 changes: 102 additions & 0 deletions
          
          102 
        
  components/hullo/actions/add-update-member/add-update-member.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,102 @@ | ||
| import hullo from "../../hullo.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "hullo-add-update-member", | ||
| name: "Add or Update Member", | ||
| description: "Adds a new member or updates an existing member's data in Hullo. [See the documentation](https://app.hullo.me/docs/index.html#?route=post-/endpoints/members)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| hullo, | ||
| phoneNumber: { | ||
| propDefinition: [ | ||
| hullo, | ||
| "phoneNumber", | ||
| ], | ||
| }, | ||
| fullName: { | ||
| type: "string", | ||
| label: "Full Name", | ||
| description: "The full name of the member. REQUIRED if creating a new member.", | ||
| optional: true, | ||
| }, | ||
| registrationDate: { | ||
| type: "string", | ||
| label: "Registration Date", | ||
| description: "The date the member was registered in ISO-8601 format. Example: `2000-01-23T04:56:07.000+00:00`", | ||
| optional: true, | ||
| }, | ||
| groups: { | ||
| type: "string[]", | ||
| label: "Groups", | ||
| description: "An array containing the names of groups this member belongs to", | ||
| optional: true, | ||
| }, | ||
| attributes: { | ||
| propDefinition: [ | ||
| hullo, | ||
| "attributes", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (!this.attributes?.length) { | ||
| return props; | ||
| } | ||
| for (const attribute of this.attributes) { | ||
| props[attribute] = { | ||
| type: "string", | ||
| label: attribute, | ||
| description: `Value for ${attribute}`, | ||
| }; | ||
| } | ||
| return props; | ||
| }, | ||
| methods: { | ||
| async formatAttributes(attributeKeys, attributeValues) { | ||
| const attributes = await this.hullo.listAttributes(); | ||
| const formattedAttributes = {}; | ||
| for (const key of attributeKeys) { | ||
| const { type } = attributes.find(({ name }) => name === key); | ||
| const value = type === "NUMBER" | ||
| ? +attributeValues[key] | ||
| : type === "LIST" | ||
| ? JSON.parse(attributeValues[key]) | ||
| : attributeValues[key]; | ||
| formattedAttributes[key] = [ | ||
| value, | ||
| ]; | ||
| } | ||
| return formattedAttributes; | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| hullo, | ||
| formatAttributes, | ||
| phoneNumber, | ||
| fullName, | ||
| registrationDate, | ||
| groups, | ||
| attributes, | ||
| ...attributeValues | ||
| } = this; | ||
|  | ||
| const response = await hullo.addOrUpdateMember({ | ||
| $, | ||
| data: { | ||
| phoneNumber, | ||
| fullName, | ||
| registrationDate, | ||
| groups, | ||
| attributes: attributes?.length | ||
| ? await formatAttributes(attributes, attributeValues) | ||
| : undefined, | ||
| }, | ||
| }); | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| $.export("$summary", `Successfully added or updated member with phone number ${this.phoneNumber}`); | ||
| 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,34 @@ | ||
| import hullo from "../../hullo.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "hullo-send-message", | ||
| name: "Send Message", | ||
| description: "Sends a personalized message to a Hullo member. [See the documentation](https://app.hullo.me/docs/index.html#?route=post-/endpoints/messages)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| hullo, | ||
| phoneNumber: { | ||
| propDefinition: [ | ||
| hullo, | ||
| "phoneNumber", | ||
| ], | ||
| }, | ||
| messageText: { | ||
| type: "string", | ||
| label: "Message Text", | ||
| description: "The message text to send. Min length: 1, Max length: 640", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.hullo.sendMessage({ | ||
| $, | ||
| data: { | ||
| phoneNumber: this.phoneNumber, | ||
| messageText: this.messageText, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully sent message to member with phone number: ${this.phoneNumber}`); | ||
| return response; | ||
| }, | ||
|         
                  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 | 
|---|---|---|
| @@ -1,11 +1,62 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|  | ||
| export default { | ||
| type: "app", | ||
| app: "hullo", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| attributes: { | ||
| type: "string[]", | ||
| label: "Attributes", | ||
| description: "The attributes that describe the member", | ||
| optional: true, | ||
| async options() { | ||
| const attributes = await this.listAttributes(); | ||
| return attributes?.map(({ name }) => name ) || []; | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }, | ||
| phoneNumber: { | ||
| type: "string", | ||
| label: "Phone Number", | ||
| description: "The phone number of the member", | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://app.hullo.me/api/endpoints"; | ||
| }, | ||
| _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| "X-API-KEY": `${this.$auth.api_key}`, | ||
| }, | ||
| }); | ||
| }, | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| listAttributes(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/attributes", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| sendMessage(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/messages", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| addOrUpdateMember(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/members", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
  
    
      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/hullo", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Hullo Components", | ||
| "main": "hullo.app.mjs", | ||
| "keywords": [ | ||
|  | @@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
      
      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.