diff --git a/components/intelliprint/README.md b/components/intelliprint/README.md deleted file mode 100644 index 50ae497253ee4..0000000000000 --- a/components/intelliprint/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Overview - -The Intelliprint API offers a suite of printing solutions, enabling developers to automate the process of sending documents for print. With this API, you can create workflows in Pipedream to programmatically manage print jobs, customize printing options, and track the status of each task. It's ideal for businesses looking to integrate print capabilities into their services without the overhead of managing printers and supplies. - -# Example Use Cases - -- **Automated Invoice Printing**: Trigger a Pipedream workflow to send invoices for print automatically whenever a new sale is recorded in your e-commerce platform. This can ensure that all paperwork is printed and ready for dispatch without manual intervention. - -- **Custom Business Cards on Demand**: Set up a Pipedream workflow that listens for a webhook from a CRM app when new employees are added. The workflow can then use the Intelliprint API to print business cards with the employee's details, streamlining the onboarding process. - -- **Print Job Status Tracking**: Construct a Pipedream workflow that periodically checks the status of print jobs submitted through Intelliprint. When a job is complete, the workflow could send a notification via apps like Slack or email, keeping relevant teams informed. diff --git a/components/intelliprint/actions/create-a-print-job/create-a-print-job.mjs b/components/intelliprint/actions/create-a-print-job/create-a-print-job.mjs new file mode 100644 index 0000000000000..ba25b3c7fd2af --- /dev/null +++ b/components/intelliprint/actions/create-a-print-job/create-a-print-job.mjs @@ -0,0 +1,203 @@ +/* eslint-disable no-unused-vars */ +import { + ConfigurationError, + getFileStreamAndMetadata, +} from "@pipedream/platform"; +import FormData from "form-data"; +import { + DOUBLE_SIDED_OPTIONS, + IDEAL_ENVELOPE_OPTIONS, + POSTAGE_SERVICE_OPTIONS, + SPLITTING_METHOD_OPTIONS, +} from "../../common/constants.mjs"; +import { camelCaseToSnakeCase } from "../../common/utils.mjs"; +import intelliprint from "../../intelliprint.app.mjs"; + +export default { + key: "intelliprint-create-a-print-job", + name: "Create a Print Job", + description: "Creates a new print job in the Intelliprint API. [See the documentation](https://api-docs.intelliprint.net/?_gl=1*19r3k2k*_gcl_au*MTU2NDU2MDgzMS4xNzY0MDIwNDQx#print_jobs-create)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + intelliprint, + filePath: { + type: "string", + label: "File Path", + description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)", + }, + reference: { + type: "string", + label: "Reference", + description: "An user-provided reference for this Print Job.", + optional: true, + }, + confirmed: { + type: "boolean", + label: "Confirmed", + description: "Whether to confirm this Print Job immediately, or to leave it as a draft.", + optional: true, + }, + testmode: { + type: "boolean", + label: "Test Mode", + description: "Whether to mark this Print Job as a test.", + optional: true, + }, + splittingMethod: { + type: "string", + label: "Splitting Method", + description: "The method to use to split the Print Job into multiple Print Jobs.", + options: SPLITTING_METHOD_OPTIONS, + optional: true, + }, + splitOnPhrase: { + type: "string", + label: "Split On Phrase", + description: "The word or phrase to split letters using. Only used when **Splitting Method** is set to `split_on_phrase`.", + optional: true, + }, + splitOnPage: { + type: "integer", + label: "Split On Page", + description: "The number of pages each letter should be. Only used when **Splitting Method** is set to `split_on_page`.", + optional: true, + }, + doubleSided: { + type: "string", + label: "Double Sided", + description: "Whether to print these letters double sided.", + options: DOUBLE_SIDED_OPTIONS, + optional: true, + }, + doubleSidedSpecificPages: { + type: "string", + label: "Double Sided Specific Pages", + description: "The array of pages to print double sided. Only used when **Double Sided** is set to `mixed`. Example: **[[1, 3], [6, 7]]**.", + optional: true, + }, + premiumQuality: { + type: "boolean", + label: "Premium Quality", + description: "Whether to print these letters in premium quality.", + optional: true, + }, + postageService: { + type: "string", + label: "Postage Service", + description: "The postage service to use for this Print Job.", + options: POSTAGE_SERVICE_OPTIONS, + optional: true, + }, + idealEnvelope: { + type: "string", + label: "Ideal Envelope", + description: "The ideal envelope size for these letters.", + options: IDEAL_ENVELOPE_OPTIONS, + optional: true, + }, + mailDate: { + type: "string", + label: "Mail Date", + description: "The date to send this letter out on. Format: **YYYY-MM-DD**", + optional: true, + }, + backgroundFirstPage: { + type: "string", + label: "Background First Page", + description: "The ID of the Background to apply to the first page of these letters.", + optional: true, + }, + backgroundOtherPages: { + type: "string", + label: "Background Other Pages", + description: "The ID of the Background to apply to the other pages of these letters.", + optional: true, + }, + confidential: { + type: "boolean", + label: "Confidential", + description: "Whether to mark letters of this Print Job as confidential.", + optional: true, + }, + removeLetters: { + type: "string", + label: "Remove Letters", + description: "Remove letter objects that have this phrase in their content.", + optional: true, + }, + nudgeX: { + type: "integer", + label: "Nudge X", + description: "What amount in mm to move the first page of each letter horizontally. A positive number moves the page right, a negative number moves the page left.", + optional: true, + }, + nudgeY: { + type: "integer", + label: "Nudge Y", + description: "What amount in mm to move the first page of each letter vertically. A positive number moves the page down, a negative number moves the page up.", + optional: true, + }, + confirmationEmail: { + type: "string", + label: "Confirmation Email", + description: "Whether a confirmation email should be sent to the user or account's email address when this letter is confirmed.", + optional: true, + }, + metadata: { + type: "object", + label: "Metadata", + description: "A key-value object for storing any information you want to along with this Print Job.", + optional: true, + }, + syncDir: { + type: "dir", + accessMode: "read", + sync: true, + optional: false, + }, + }, + async run({ $ }) { + try { + const { + intelliprint, + filePath, + syncDir, + ...data + } = this; + + const { + stream, metadata, + } = await getFileStreamAndMetadata(filePath); + + const formData = new FormData(); + formData.append("file", stream, { + contentType: metadata.contentType, + knownLength: metadata.size, + filename: metadata.name, + }); + for (const [ + key, + value, + ] of Object.entries(data)) { + formData.append(camelCaseToSnakeCase(key), `${value}`); + } + + const response = await intelliprint.createPrintJob({ + $, + data: formData, + headers: formData.getHeaders(), + }); + + $.export("$summary", `Successfully created print job with ID: ${response.id}`); + return response; + } catch (error) { + throw new ConfigurationError(`Error creating print job: ${error.response.data.error.message}`); + } + }, +}; diff --git a/components/intelliprint/common/constants.mjs b/components/intelliprint/common/constants.mjs new file mode 100644 index 0000000000000..81b5ac39dd665 --- /dev/null +++ b/components/intelliprint/common/constants.mjs @@ -0,0 +1,27 @@ +export const SPLITTING_METHOD_OPTIONS = [ + "none", + "split_on_phrase", + "split_on_page", +]; + +export const DOUBLE_SIDED_OPTIONS = [ + "no", + "yes", + "mixed", +]; + +export const POSTAGE_SERVICE_OPTIONS = [ + "uk_first_class", + "uk_second_class", + "uk_first_class_signed_for", + "uk_second_class_signed_for", + "uk_special_delivery", + "international", +]; + +export const IDEAL_ENVELOPE_OPTIONS = [ + "c4", + "c5", + "c4_plus", + "a4_box", +]; diff --git a/components/intelliprint/common/utils.mjs b/components/intelliprint/common/utils.mjs new file mode 100644 index 0000000000000..b2f765ba42e54 --- /dev/null +++ b/components/intelliprint/common/utils.mjs @@ -0,0 +1,3 @@ +export const camelCaseToSnakeCase = (str) => { + return str?.replace(/([A-Z])/g, "_$1").toLowerCase(); +}; diff --git a/components/intelliprint/intelliprint.app.mjs b/components/intelliprint/intelliprint.app.mjs index 70daa1172ea63..0ce9fbdf851ba 100644 --- a/components/intelliprint/intelliprint.app.mjs +++ b/components/intelliprint/intelliprint.app.mjs @@ -1,11 +1,34 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "intelliprint", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _apiUrl() { + return "https://api.rnbdata.uk/v1"; + }, + _getAuth() { + return { + "username": this.$auth.api_key, + "password": "", + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: `${this._apiUrl()}/${path}`, + auth: this._getAuth(), + ...opts, + }); + }, + createPrintJob(args = {}) { + return this._makeRequest({ + method: "POST", + path: "prints", + ...args, + }); }, }, }; diff --git a/components/intelliprint/package.json b/components/intelliprint/package.json index dabe9e4eda77b..d24c569f1aa7e 100644 --- a/components/intelliprint/package.json +++ b/components/intelliprint/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/intelliprint", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Intelliprint Components", "main": "intelliprint.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a89f72da8aa97..f3b8a4459be3b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2043,8 +2043,7 @@ importers: components/braintree: {} - components/brand_dev: - specifiers: {} + components/brand_dev: {} components/brandblast: {} @@ -3588,8 +3587,7 @@ importers: components/currents_api: {} - components/cursor: - specifiers: {} + components/cursor: {} components/customer_fields: dependencies: @@ -5669,8 +5667,7 @@ importers: components/funnelcockpit: {} - components/fynk: - specifiers: {} + components/fynk: {} components/gagelist: dependencies: @@ -6736,8 +6733,7 @@ importers: components/helcim: {} - components/helicone: - specifiers: {} + components/helicone: {} components/helium: dependencies: @@ -7434,7 +7430,11 @@ importers: specifier: ^1.6.8 version: 1.6.8 - components/intelliprint: {} + components/intelliprint: + dependencies: + '@pipedream/platform': + specifier: ^3.1.1 + version: 3.1.1 components/intercom: dependencies: @@ -8649,8 +8649,7 @@ importers: specifier: ^1.6.8 version: 1.6.8 - components/magicalapi: - specifiers: {} + components/magicalapi: {} components/magileads: {} @@ -12280,8 +12279,7 @@ importers: specifier: ^3.1.1 version: 3.1.1 - components/relationcity: - specifiers: {} + components/relationcity: {} components/relavate: dependencies: @@ -14054,8 +14052,7 @@ importers: components/socialkit: {} - components/socket: - specifiers: {} + components/socket: {} components/softledger: {} @@ -15438,8 +15435,7 @@ importers: components/turbohire: {} - components/turbosmtp: - specifiers: {} + components/turbosmtp: {} components/turbot_pipes: dependencies: @@ -15871,8 +15867,7 @@ importers: specifier: ^3.1.1 version: 3.1.1 - components/validemail: - specifiers: {} + components/validemail: {} components/vapi: dependencies: @@ -15976,8 +15971,7 @@ importers: components/verticalresponse: {} - components/veryfi: - specifiers: {} + components/veryfi: {} components/vestaboard: dependencies: @@ -39125,7 +39119,6 @@ snapshots: transitivePeerDependencies: - rolldown - rollup - - supports-color '@putout/operator-parens@2.0.0(rolldown@1.0.0-beta.9)(rollup@4.53.2)': dependencies: