- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
[Components] textline - new components #15477
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
    
    
  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
        
          
          
            122 changes: 122 additions & 0 deletions
          
          122 
        
  components/textline/actions/create-update-contact/create-update-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,122 @@ | ||
| import app from "../../textline.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "textline-create-update-contact", | ||
| name: "Create Or Update Contact", | ||
| description: "Create or update a contact in the Textline address book. [See the documentation](https://textline.docs.apiary.io/#reference/customers/customers/create-a-customer).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| phoneNumber: { | ||
| propDefinition: [ | ||
| app, | ||
| "phoneNumber", | ||
| ], | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The email of the contact.", | ||
| optional: true, | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The name of the contact.", | ||
| optional: true, | ||
| }, | ||
| notes: { | ||
| type: "string", | ||
| label: "Notes", | ||
| description: "Notes about the contact.", | ||
| optional: true, | ||
| }, | ||
| tags: { | ||
| type: "string[]", | ||
| label: "Tags", | ||
| description: "Tags associated with the contact.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| updateCustomer({ | ||
| uuid, ...args | ||
| } = {}) { | ||
| return this.app.put({ | ||
| path: `/customer/${uuid}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| createCustomer(args = {}) { | ||
| return this.app.post({ | ||
| path: "/customers", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| updateCustomer, | ||
| createCustomer, | ||
| phoneNumber, | ||
| email, | ||
| name, | ||
| notes, | ||
| tags, | ||
| } = this; | ||
|  | ||
| let response; | ||
| let uuid; | ||
|  | ||
| try { | ||
| response = await createCustomer({ | ||
| $, | ||
| data: { | ||
| customer: { | ||
| phone_number: phoneNumber, | ||
| email, | ||
| name, | ||
| notes, | ||
| tags, | ||
| }, | ||
| }, | ||
| }); | ||
| } catch (error) { | ||
| if (error.response.status === 400 && error.response.data?.errors?.phone_number[0] === "Already in use") { | ||
|  | ||
| ({ customer: { uuid } } = await app.getCustomerByPhoneNumber({ | ||
| $, | ||
| params: { | ||
| phone_number: phoneNumber, | ||
| }, | ||
| })); | ||
|  | ||
| } else { | ||
| throw error; | ||
| } | ||
| } | ||
|  | ||
| if (!uuid) { | ||
| $.export("$summary", `Successfully created the contact with uuid \`${response.customer.uuid}\`.`); | ||
| return response; | ||
| } | ||
|  | ||
| response = await updateCustomer({ | ||
| $, | ||
| uuid, | ||
| data: { | ||
| customer: { | ||
| email, | ||
| name, | ||
| notes, | ||
| tags, | ||
| }, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully updated the contact with uuid \`${uuid}\`.`); | ||
| return response; | ||
| }, | ||
| }; | 
        
          
          
            119 changes: 119 additions & 0 deletions
          
          119 
        
  components/textline/actions/send-announcement/send-announcement.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,119 @@ | ||
| import app from "../../textline.app.mjs"; | ||
| import constants from "../../common/constants.mjs"; | ||
|  | ||
| export default { | ||
| key: "textline-send-announcement", | ||
| name: "Send Announcement", | ||
| description: "Send an announcement to a group of contacts. [See the documentation](https://textline.docs.apiary.io/#reference/messaging-tools/announcements/send-an-announcement).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| massTextGroupUuid: { | ||
| label: "Mass Text Group UUID", | ||
| description: "The UUID of the mass text group.", | ||
| propDefinition: [ | ||
| app, | ||
| "groupUuid", | ||
| ], | ||
| }, | ||
| massTextCommentBody: { | ||
| type: "string", | ||
| label: "Mass Text Comment Body", | ||
| description: "The content of the message to send.", | ||
| }, | ||
| massTextTitle: { | ||
| type: "string", | ||
| label: "Mass Text Title", | ||
| description: "The title of the message.", | ||
| }, | ||
| selectionType: { | ||
| type: "string", | ||
| label: "Selection Type", | ||
| description: "The type of the selection for the announcement.", | ||
| reloadProps: true, | ||
| options: Object.values(constants.SELECTION_TYPE), | ||
| }, | ||
| }, | ||
| additionalProps() { | ||
| const { selectionType } = this; | ||
|  | ||
| if (selectionType === constants.SELECTION_TYPE.TAGS.value) { | ||
| return { | ||
| tag: { | ||
| type: "string", | ||
| label: "Tag", | ||
| description: "Send to all contacts with this tag.", | ||
| }, | ||
| }; | ||
| } | ||
|  | ||
| if (selectionType === constants.SELECTION_TYPE.PHONE_NUMBERS.value) { | ||
| return { | ||
| phoneNumbers: { | ||
| type: "string[]", | ||
| label: "Phone Numbers", | ||
| description: "The phone numbers to send the announcement to.", | ||
| useQuery: true, | ||
| options: async ({ | ||
| page, query, | ||
| }) => { | ||
| const { customers } = await this.app.listCustomers({ | ||
| params: { | ||
| page, | ||
| page_size: 30, | ||
| query: query || "", | ||
| }, | ||
| }); | ||
| return customers.map(({ | ||
| name: label, phone_number: value, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|  | ||
| return {}; | ||
| }, | ||
| methods: { | ||
| sendAnnouncement(args = {}) { | ||
| return this.app.post({ | ||
| path: "/announcements", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| sendAnnouncement, | ||
| selectionType, | ||
| massTextGroupUuid, | ||
| massTextCommentBody, | ||
| massTextTitle, | ||
| tag, | ||
| phoneNumbers, | ||
| } = this; | ||
|  | ||
| const response = await sendAnnouncement({ | ||
| $, | ||
| data: { | ||
| selection_type: selectionType, | ||
| recipients: { | ||
| tag, | ||
| phone_numbers: phoneNumbers, | ||
| }, | ||
| mass_text: { | ||
| group_uuid: massTextGroupUuid, | ||
| comment_body: massTextCommentBody, | ||
| title: massTextTitle, | ||
| }, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", "Successfully sent the announcement."); | ||
| 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,51 @@ | ||
| import app from "../../textline.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "textline-send-message", | ||
| name: "Send Message", | ||
| description: "Send a new message directly to a contact. [See the documentation](https://textline.docs.apiary.io/#reference/conversations/group-conversations/message-a-phone-number).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| phoneNumber: { | ||
| propDefinition: [ | ||
| app, | ||
| "phoneNumber", | ||
| ], | ||
| }, | ||
| comment: { | ||
| type: "string", | ||
| label: "Message", | ||
| description: "The content of the message to send.", | ||
| }, | ||
| }, | ||
| methods: { | ||
| sendMessage(args = {}) { | ||
| return this.app.post({ | ||
| path: "/conversations", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| sendMessage, | ||
| phoneNumber, | ||
| comment, | ||
| } = this; | ||
| const response = await sendMessage({ | ||
| $, | ||
| data: { | ||
| phone_number: phoneNumber, | ||
| comment: { | ||
| body: comment, | ||
| }, | ||
| resolve: "1", | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully sent message to ${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,21 @@ | ||
| const BASE_URL = "https://application.textline.com"; | ||
| const VERSION_PATH = "/api"; | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| const DEFAULT_LIMIT = 30; | ||
|  | ||
| const SELECTION_TYPE = { | ||
| TAGS: { | ||
| label: "Tags", | ||
| value: "tags", | ||
| }, | ||
| PHONE_NUMBERS: { | ||
| label: "Phone Numbers", | ||
| value: "phone_numbers", | ||
| }, | ||
| }; | ||
|  | ||
| export default { | ||
| BASE_URL, | ||
| VERSION_PATH, | ||
| DEFAULT_LIMIT, | ||
| SELECTION_TYPE, | ||
| }; | ||
  
    
      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/textline", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Textline Components", | ||
| "main": "textline.app.mjs", | ||
| "keywords": [ | ||
|  | @@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
      
      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.