@pipedream/click2mail2 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Overview
2
+
3
+ The Click2Mail API enables automated mailing solutions, letting you integrate direct mail processes within your digital workflows. On Pipedream, you can harness this API to craft serverless workflows that interact with other apps and services. Create, manage, and send postal mail without leaving your digital ecosystem. Automate mail for marketing, invoicing, or any correspondence that requires a physical mail presence.
4
+
5
+ # Example Use Cases
6
+
7
+ - **Automated Invoice Mailing**: When a new invoice is created in your accounting software, such as QuickBooks, trigger a Pipedream workflow that sends the invoice details to Click2Mail. Click2Mail then prints and mails the invoice to the customer, streamlining the billing process.
8
+
9
+ - **Postcard Marketing Campaign Trigger**: Use a CRM platform like HubSpot to trigger a Pipedream workflow when a new lead is added to a specific stage in your sales pipeline. The workflow then sends a custom postcard via Click2Mail, providing a personal touch to potential customers.
10
+
11
+ - **Customer Thank You Notes**: After an order is marked as delivered in an e-commerce platform like Shopify, trigger a Pipedream workflow that sends a thank you note through Click2Mail. This gesture can enhance customer satisfaction and encourage repeat business.
@@ -1,26 +1,16 @@
1
1
  import FormData from "form-data";
2
- import fs from "fs";
2
+ import { getFileStreamAndMetadata } from "@pipedream/platform";
3
3
  import click2mail2 from "../../click2mail2.app.mjs";
4
4
  import { FORMATS } from "../../common/constants.mjs";
5
5
 
6
6
  export default {
7
7
  key: "click2mail2-create-document",
8
8
  name: "Create Document",
9
- version: "0.0.1",
9
+ version: "1.0.0",
10
10
  description: "Creates a new document in your account from an uploaded file or a URL. [See the documentation for file](https://developers.click2mail.com/reference/createdocument_1). [See the documentation for URL](https://developers.click2mail.com/reference/createdocumentfromurl)",
11
11
  type: "action",
12
12
  props: {
13
13
  click2mail2,
14
- uploadType: {
15
- type: "string",
16
- label: "Upload Type",
17
- description: "The type of the upload.",
18
- reloadProps: true,
19
- options: [
20
- "URL",
21
- "File",
22
- ],
23
- },
24
14
  documentName: {
25
15
  type: "string",
26
16
  label: "Document Name",
@@ -39,49 +29,54 @@ export default {
39
29
  "documentClass",
40
30
  ],
41
31
  },
42
- },
43
- async additionalProps() {
44
- const props = {};
45
- if (this.uploadType === "URL") {
46
- props.url = {
47
- type: "string",
48
- label: "URL",
49
- description: "Document url",
50
- };
51
- } else {
52
- props.file = {
53
- type: "string",
54
- label: "File",
55
- description: "Path of the file in /tmp folder. To upload a file to /tmp folder, please follow the [doc here](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
56
- };
57
- }
58
- return props;
32
+ file: {
33
+ type: "string",
34
+ label: "File Path Or Url",
35
+ description: "Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.pdf`).",
36
+ },
59
37
  },
60
38
  async run({ $ }) {
61
39
  const {
62
40
  click2mail2,
63
- uploadType,
64
41
  file,
65
- ...params
42
+ documentName,
43
+ documentFormat,
44
+ documentClass,
66
45
  } = this;
67
46
 
68
- let objToSend = {};
47
+ const isUrl = file.startsWith("http://") || file.startsWith("https://");
48
+
49
+ const objToSend = {
50
+ params: {
51
+ documentName,
52
+ documentFormat,
53
+ documentClass,
54
+ },
55
+ };
69
56
 
70
- if (uploadType === "File") {
57
+ if (!isUrl) {
58
+ const {
59
+ stream, metadata,
60
+ } = await getFileStreamAndMetadata(file);
71
61
  const formData = new FormData();
72
- formData.append("file", fs.createReadStream(file));
62
+ formData.append("file", stream, {
63
+ contentType: metadata.contentType,
64
+ knownLength: metadata.size,
65
+ filename: metadata.name,
66
+ });
73
67
 
74
- objToSend = {
75
- data: formData,
76
- headers: formData.getHeaders(),
77
- };
68
+ objToSend.data = formData;
69
+ objToSend.headers = formData.getHeaders();
70
+
71
+ } else {
72
+ objToSend.params.url = file;
78
73
  }
74
+
79
75
  const response = await click2mail2.create({
80
76
  $,
81
- path: `${uploadType === "File"
77
+ path: `${!isUrl
82
78
  ? "documents"
83
79
  : "documents/url"}`,
84
- params,
85
80
  ...objToSend,
86
81
  });
87
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/click2mail2",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "Pipedream Click2Mail Components",
5
5
  "main": "click2mail2.app.mjs",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^1.5.1",
16
+ "@pipedream/platform": "^3.1.0",
17
17
  "form-data": "^4.0.0",
18
18
  "fs": "^0.0.1-security"
19
19
  }