- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - elastic_email #15692
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 3 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      57cd483
              
                elastic_email init
              
              
                luancazarine 6d87ca6
              
                [Components] elasticemail #15687
              
              
                luancazarine ab61557
              
                pnpm update
              
              
                luancazarine 61b54d2
              
                some adjusts
              
              
                luancazarine 1366923
              
                some adjusts
              
              
                luancazarine feca2d2
              
                fix template prop
              
              
                luancazarine 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
This file was deleted.
      
      Oops, something went wrong.
      
    
  
        
          
          
            84 changes: 84 additions & 0 deletions
          
          84 
        
  components/elastic_email/actions/add-contact/add-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,84 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { STATUS_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import app from "../../elastic_email.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "elastic_email-add-contact", | ||
| name: "Add Contact to Mailing List", | ||
| description: "Adds a new contact to a mailing list. [See the documentation]()", | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| email: { | ||
| propDefinition: [ | ||
| app, | ||
| "email", | ||
| ], | ||
| }, | ||
| listNames: { | ||
| propDefinition: [ | ||
| app, | ||
| "listNames", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| status: { | ||
| type: "string", | ||
| label: "Status", | ||
| description: "The initial status of the contact.", | ||
| options: STATUS_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "The contact's first name.", | ||
| optional: true, | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "The contact's last name.", | ||
| optional: true, | ||
| }, | ||
| customFields: { | ||
| type: "object", | ||
| label: "Custom Fields", | ||
| description: "A key-value collection of custom contact fields which can be used in the system. Only already existing custom fields will be saved.", | ||
| optional: true, | ||
| }, | ||
| consent: { | ||
| type: "object", | ||
| label: "Consent", | ||
| description: "An object with consent settings. **Example: \"ConsentIP\": \"192.168.0.1\", \"ConsentDate\": \"1/1/2015 0:00:00 AM\", \"ConsentTracking\": \"Unknown\"}**", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.addContact({ | ||
| $, | ||
| params: { | ||
| listnames: parseObject(this.listNames), | ||
| }, | ||
| data: [ | ||
| { | ||
| Email: this.email, | ||
| Status: this.status, | ||
| FirstName: this.firstName, | ||
| LastName: this.lastName, | ||
| CustomFields: parseObject(this.customFields), | ||
| Consent: parseObject(this.consent), | ||
| }, | ||
| ], | ||
| }); | ||
|  | ||
| if (("success" in response) && response.success === "false") { | ||
| throw new ConfigurationError(response.error); | ||
| } | ||
|  | ||
| $.export("$summary", `Successfully added contact ${this.email} to the mailing list`); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            127 changes: 127 additions & 0 deletions
          
          127 
        
  components/elastic_email/actions/send-email/send-email.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,127 @@ | ||
| import { ENCODING_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import app from "../../elastic_email.app.mjs"; | ||
|  | ||
| /**FALTA TESTAR */ | ||
| /**FALTA TESTAR */ | ||
| /**FALTA TESTAR */ | ||
| /**FALTA TESTAR */ | ||
| /**FALTA TESTAR */ | ||
| /**FALTA TESTAR */ | ||
| /**FALTA TESTAR */ | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| export default { | ||
| key: "elastic_email-send-email", | ||
| name: "Send Email", | ||
| description: "Sends an email to one or more recipients. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/emailsPost)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| recipients: { | ||
| type: "string[]", | ||
| label: "Recipients", | ||
| description: "List of recipients", | ||
| }, | ||
| from: { | ||
| type: "string", | ||
| label: "From", | ||
| description: "Your e-mail with an optional name (e.g.: [email protected])", | ||
| }, | ||
| body: { | ||
| type: "string[]", | ||
| label: "Body", | ||
| description: "List of e-mail body parts, with user-provided MIME types (text/html, text/plain etc). **Format: {\"ContentType\": \"HTML\", \"Content\": \"email content\", \"\": \"\"}**", | ||
| optional: true, | ||
| }, | ||
| merge: { | ||
| type: "object", | ||
| label: "Merge", | ||
| description: "A key-value collection of custom merge fields, shared between recipients. Should be used in e-mail body like so: {firstname}, {lastname} etc.", | ||
| optional: true, | ||
| }, | ||
| replyTo: { | ||
| type: "string", | ||
| label: "Reply To", | ||
| description: "To what address should the recipients reply to (e.g. [email protected])", | ||
| optional: true, | ||
| }, | ||
| subject: { | ||
| type: "string", | ||
| label: "Subject", | ||
| description: "Default subject of email.", | ||
| optional: true, | ||
| }, | ||
| templateName: { | ||
| propDefinition: [ | ||
| app, | ||
| "templateName", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| timeOffset: { | ||
| type: "integer", | ||
| label: "Time Offset", | ||
| description: "By how long should an e-mail be delayed (in minutes). Maximum is 35 days.", | ||
| optional: true, | ||
| }, | ||
| poolName: { | ||
| type: "string", | ||
| label: "Pool Name", | ||
| description: "Name of your custom IP Pool to be used in the sending process", | ||
| optional: true, | ||
| }, | ||
| channelName: { | ||
| type: "string", | ||
| label: "Channel Name", | ||
| description: "Name of selected channel.", | ||
| optional: true, | ||
| }, | ||
| encoding: { | ||
| type: "string", | ||
| label: "Encoding", | ||
| description: "Encoding type for the email headers", | ||
| options: ENCODING_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| trackOpens: { | ||
| type: "boolean", | ||
| label: "Track Opens", | ||
| description: "Should the opens be tracked? If no value has been provided, Account's default setting will be used.", | ||
| optional: true, | ||
| }, | ||
| trackClicks: { | ||
| type: "boolean", | ||
| label: "Track Clicks", | ||
| description: "Should the clicks be tracked? If no value has been provided, Account's default setting will be used.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.sendBulkEmails({ | ||
| $, | ||
| data: { | ||
| Recipients: parseObject(this.recipients)?.map((item) => ({ | ||
| Email: item, | ||
| })), | ||
|         
                  michelle0927 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| Content: { | ||
| From: this.from, | ||
| Body: this.body, | ||
| Merge: this.merge, | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ReplyTo: this.replyTo, | ||
| Subject: this.subject, | ||
| TemplateName: this.templateName, | ||
| }, | ||
| Options: { | ||
| TimeOffset: this.timeOffset, | ||
| PoolName: this.poolName, | ||
| ChannelName: this.channelName, | ||
| Encoding: this.encoding, | ||
| TrackOpens: this.trackOpens, | ||
| TrackClicks: this.trackClicks, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Emails sent successfully to ${this.recipients.join(", ")}`); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            28 changes: 28 additions & 0 deletions
          
          28 
        
  components/elastic_email/actions/unsubscribe-contact/unsubscribe-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,28 @@ | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import app from "../../elastic_email.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "elastic_email-unsubscribe-contact", | ||
| name: "Unsubscribe Contact", | ||
| description: "Unsubscribes a contact from future emails. [See the documentation]()", | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| unsubscribeEmails: { | ||
| propDefinition: [ | ||
| app, | ||
| "unsubscribeEmails", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const parsedEmails = parseObject(this.unsubscribeEmails); | ||
| const response = await this.app.unsubscribeContact({ | ||
| $, | ||
| data: parsedEmails, | ||
| }); | ||
| $.export("$summary", `Unsubscribed ${this.parsedEmails.length} contact(s) successfully`); | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| return response; | ||
| }, | ||
| }; | ||
This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      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,23 @@ | ||
| export const LIMIT = 100; | ||
|  | ||
| export const STATUS_OPTIONS = [ | ||
| "Transactional", | ||
| "Engaged", | ||
| "Active", | ||
| "Bounced", | ||
| "Unsubscribed", | ||
| "Abuse", | ||
| "Inactive", | ||
| "Stale", | ||
| "NotConfirmed", | ||
| ]; | ||
|  | ||
| export const ENCODING_OPTIONS = [ | ||
| "UserProvided", | ||
| "None", | ||
| "Raw7bit", | ||
| "Raw8bit", | ||
| "QuotedPrintable", | ||
| "Base64", | ||
| "Uue", | ||
| ]; | 
  
    
      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,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|  | ||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | 
      
      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.