Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
$,
payload,
});
response && $.export("$summary", "Company sucessfully created");
response && $.export("$summary", "Company successfully created");
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "freshdesk-create-contact",
name: "Create a Contact",
description: "Create a contact. [See docs here](https://developers.freshdesk.com/api/#create_contact)",
version: "0.0.1",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down
15 changes: 5 additions & 10 deletions components/freshdesk/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import freshdesk from "../../freshdesk.app.mjs";
import { removeNullEntries } from "../../common/utils.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "freshdesk-create-ticket",
name: "Create a Ticket",
description: "Create a ticket. [See docs here](https://developers.freshdesk.com/api/#tickets)",
version: "0.0.2",
version: "0.0.1",
type: "action",
props: {
freshdesk,
Expand Down Expand Up @@ -38,13 +39,6 @@ export default {
type: "string",
label: "Description",
description: "HTML content of the ticket.",
optional: true,
},
descriptionText: {
type: "string",
label: "Description text",
description: "Content of the ticket in plain text.",
optional: true,
},
phone: {
type: "string",
Expand All @@ -56,7 +50,6 @@ export default {
type: "string",
label: "Subject",
description: "Subject of the ticket.",
optional: true,
},
status: {
propDefinition: [
Expand All @@ -68,10 +61,12 @@ export default {
},
},
async run({ $ }) {
if (!this.email && !this.phone) {
throw new ConfigurationError("Please fill at least 1 of email and phone fields");
}
const data = removeNullEntries({
company_id: this.companyId && Number(this.companyId),
description: this.description,
description_text: this.descriptionText,
email: this.email,
phone: this.phone,
subject: this.subject,
Expand Down
20 changes: 6 additions & 14 deletions components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
// legacy_hash_id: a_A6i5zz
import { axios } from "@pipedream/platform";
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-list-all-tickets",
name: "List All Tickets",
description: "Use filters to view only specific tickets (those which match the criteria that you choose). By default, only tickets that have not been deleted or marked as spam will be returned, unless you use the 'deleted' filter.",
version: "0.1.1",
version: "0.1.2",
type: "action",
props: {
freshdesk: {
type: "app",
app: "freshdesk",
},
freshdesk,
},
async run({ $ }) {
return await axios($, {
url: `https://${this.freshdesk.$auth.domain}.freshdesk.com/api/v2/tickets`,
auth: {
username: `${this.freshdesk.$auth.api_key}:X`,
password: "",
},
});
const response = await this.freshdesk.getTickets($);
response?.length && $.export("$summary", "Tickets listed successfully");
return response;
},
};
1 change: 1 addition & 0 deletions components/freshdesk/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
BASE_PATH: "/api",
VERSION_PATH: "/v2",
PAGE_SIZE: 100,
DOMAIN: "freshdesk.com",
retriableStatusCodes: [
408,
429,
Expand Down
22 changes: 15 additions & 7 deletions components/freshdesk/freshdesk.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export default {
description: "The ID of the company",
async options() {
const response = await this.getCompanies();
return response.map((project) => ({
label: project.name,
value: project.id,
return response.map((company) => ({
label: company.name,
value: company.id,
}));
},
},
Expand All @@ -41,7 +41,7 @@ export default {
label: "Email",
description: "Contact Email.",
async options({ companyId }) {
const response = await this.getCompanies();
const response = await this.getContacts();
const contacts = response.filter((contact) => contact.company_id === Number(companyId));
return contacts.map((contact) => ({
label: contact?.email ?? contact?.name,
Expand All @@ -68,11 +68,12 @@ export default {
},
_getUrl(path) {
const {
DOMAIN,
HTTP_PROTOCOL,
BASE_PATH,
VERSION_PATH,
} = constants;
return `${HTTP_PROTOCOL}${this.$auth.domain}${BASE_PATH}${VERSION_PATH}${path}`;
return `${HTTP_PROTOCOL}${this.$auth.domain}.${DOMAIN}${BASE_PATH}${VERSION_PATH}${path}`;
},
async _makeRequest(args = {}) {
const {
Expand Down Expand Up @@ -167,13 +168,13 @@ export default {
async getCompanies($ = undefined) {
return this._makeRequest({
$,
path: "/contacts",
path: "/companies",
});
},
async getContacts($ = undefined) {
return this._makeRequest({
$,
path: "/companies",
path: "/contacts",
});
},
async createContact({
Expand Down Expand Up @@ -218,5 +219,12 @@ export default {
params,
});
},
async getTickets($, params = null) {
return this._makeRequest({
$,
path: "/tickets",
params,
});
},
},
};
1 change: 0 additions & 1 deletion components/freshdesk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
"moment":"2.29.2"
}
}

2 changes: 1 addition & 1 deletion components/freshdesk/sources/new-ticket/new-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
{
id: ticket.id,
summary: `Ticket number: ${ticket.id}`,
ts: Date.parse(ticket.created_at)
ts: Date.parse(ticket.created_at),
});
}
});
Expand Down
8 changes: 6 additions & 2 deletions components/google_drive/actions/upload-file/upload-file.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import googleDrive from "../../google_drive.app.mjs";
import path from "path";
import { getFileStream, streamToBuffer, byteToMB } from "../../utils.mjs";
import {
getFileStream, streamToBuffer, byteToMB,
} from "../../utils.mjs";
import { omitEmptyStringValues } from "../../utils.mjs";

export default {
Expand Down Expand Up @@ -88,7 +90,9 @@ export default {
try {
const fileBuffer = await streamToBuffer(file);
const bufferSize = byteToMB(Buffer.byteLength(fileBuffer));
uploadType = bufferSize > 5 ? "resumable" : "media";
uploadType = bufferSize > 5
? "resumable"
: "media";
console.log(`Upload type: ${uploadType}`);
} catch (err) {
console.log(err);
Expand Down
2 changes: 1 addition & 1 deletion components/google_drive/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const GOOGLE_DRIVE_UPLOAD_TYPES = [
"media",
"multipart",
"resumable",
]
];

export {
GOOGLE_DRIVE_NOTIFICATION_SYNC,
Expand Down
4 changes: 2 additions & 2 deletions components/google_drive/google_drive.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
GOOGLE_DRIVE_GRANTEE_TYPES,
GOOGLE_DRIVE_GRANTEE_ANYONE,
GOOGLE_DRIVE_ROLE_READER,
GOOGLE_DRIVE_UPLOAD_TYPES
GOOGLE_DRIVE_UPLOAD_TYPES,
} from "./constants.mjs";
import googleMimeTypes from "./actions/google-mime-types.mjs";

Expand Down Expand Up @@ -189,7 +189,7 @@ export default {
multipart - Multipart upload. Upload both the media and its metadata, in a single request.
resumable - Resumable upload. Upload the file in a resumable fashion, using a series of
at least two requests where the first request includes the metadata.`,
options: GOOGLE_DRIVE_UPLOAD_TYPES
options: GOOGLE_DRIVE_UPLOAD_TYPES,
},
useDomainAdminAccess: {
type: "boolean",
Expand Down
7 changes: 4 additions & 3 deletions components/google_drive/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ function streamToBuffer(stream) {
chunks.push(chunk);
}).on("end", () => {
resolve(Buffer.concat(chunks));
}).on("error", (err) => {
reject(err);
});
})
.on("error", (err) => {
reject(err);
});
});
}

Expand Down
8 changes: 5 additions & 3 deletions components/imgbb/actions/upload-picture/upload-picture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export default {
filePath: {
type: "string",
label: "File Path",
description: `The path to the file saved to the [\`/tmp\`directory](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory)(e.g. \`/tmp/image.png\`). Must specify either **File URL** or **File Path**.`,
description: "The path to the file saved to the [`/tmp`directory](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory)(e.g. `/tmp/image.png`). Must specify either **File URL** or **File Path**.",
optional: true,
},
fileUrl: {
type: "string",
label: "File URL",
description: `The URL of the file you want to upload to ImgBB. Must specify either **File URL** or **File Path**.`,
description: "The URL of the file you want to upload to ImgBB. Must specify either **File URL** or **File Path**.",
optional: true,
},
name: {
Expand All @@ -35,7 +35,9 @@ export default {
throw new ConfigurationError("Must specify either File Path or File Url");
}
if (this.filePath && !this.fileUrl) {
this.fileData = (await fs.promises.readFile(this.filePath, { encoding: "base64" }))
this.fileData = (await fs.promises.readFile(this.filePath, {
encoding: "base64",
}));
}
const data = {
image: this.fileUrl ?? this.fileData,
Expand Down