Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion components/remote_retrieval/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Overview

The Remote-Retriever API is tailored for automating the retrieval of contact information, enhancing your CRM data, or developing lead generation tools. By integrating it with Pipedream, you can efficiently extract valuable data and automate workflows for marketing, sales, or customer support. Pipedream’s serverless platform allows you to connect Retriever with numerous other apps, triggering actions based on new data, or updating systems instantly.
The Remote-Retrieval API is tailored for automating the retrieval of contact information, enhancing your CRM data, or developing lead generation tools. By integrating it with Pipedream, you can efficiently extract valuable data and automate workflows for marketing, sales, or customer support. Pipedream’s serverless platform allows you to connect Retrieval with numerous other apps, triggering actions based on new data, or updating systems instantly.
23 changes: 23 additions & 0 deletions components/remote_retrieval/actions/all-orders/all-orders.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import app from "../../remote_retrieval.app.mjs";

export default {
key: "remote_retrieval-get-all-orders",
name: "Get All Order",
description: "Retrieve a list of all orders.[See the documentation](https://www.remoteretrieval.com/api-documentation/#pending-orders)",
type: "action",
version: "0.1.0",
props: {
app,
},
methods: {
},
async run({ $: step }) {
const response = await this.app.allOrders({
step,
});

step.export("$summary", `Successfully retrieved ${response.results.length} order(s).`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import app from "../../remote_retrieval.app.mjs";

export default {
key: "remote_retrieval-create-device-order",
name: "Create Device Order",
description: "Creates a device return order. [See the documentation](https://www.remoteretrieval.com/api-documentation/#create-order)",
type: "action",
version: "0.1.0",
props: {
app,

employeeInfoEmail: {
type: "string",
label: "Employee Info Email",
description: "Used in email communications with the employee."
},
employeeInfoName: {
type: "string",
label: "Employee Info Name",
description: "Employee full name to print on the shipping label."
},
employeeInfoAdd_1: {
type: "string",
label: "Employee Info Address Line 1",
description: "The first line of the employee address"
},
employeeInfoAdd_2: {
type: "string",
label: "Employee Info Address Line 2",
description: "The second line is optional for employee address",
optional: true ,
},
employeeInfoCity: {
type: "string",
label: "Employee Info City",
description: "City of employee",
},
employeeInfoState: {
type: "string",
label: "Employee Info State",
description: "State of employee",
},
employeeInfoZip: {
type: "string",
label: "Employee Info Zip",
description: "Zip code of employee",
},
employeeInfoPhone: {
type: "string",
label: "Employee Info Phone",
description: "Phone of employee",
},
employeeInfoCountry: {
type: "string",
label: "Employee Info Country",
description: "This service is only for USA",
options: ["US"],
default: "US",
},

companyInfoPerson: {
type: "string",
label: "Company Info Person Name",
description: "Receipient Name"
},
companyInfoCompanyName: {
type: "string",
label: "Company Info Company Name",
description: "Company Name"
},
companyInfoAdd_1: {
type: "string",
label: "Company Info Address Line 1",
description: "The first line of the company address"
},
companyInfoAdd_2: {
type: "string",
label: "Company Info Address Line 2",
description: "The second line is optional for company address",
},
companyInfoCity: {
type: "string",
label: "Company Info City",
description: "Company city",
},
companyInfoState: {
type: "string",
label: "Company Info State",
description: "Company State(Example: TX,AL,NJ)",
},
companyInfoZip: {
type: "string",
label: "Company Info Zip",
description: "Company Zip",
},
companyInfoPhone: {
type: "string",
label: "Company Info Phone",
description: "Company Phone",
},
companyInfoEmail: {
type: "string",
label: "Company Info Email",
description: "Company Email",
},
typeOfEquipment: {
type: "string",
label: "Type of Equipment",
description: "You can choose 'Laptop' or 'Monitor'",
options: ['Laptop','Monitor'],
default: "Laptop"
},
orderType: {
type: "string",
label: "Order Type",
description: "You can choose 'Return to Company' or 'Sell this Equipment'",
options: ['Return to Company','Sell this Equipment'],
default: "Return to Company"
},
Comment on lines +9 to +119
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-structured properties with clear documentation.

The properties are well-defined with appropriate types, labels, and descriptions. The use of default values and options enhances user experience and input validation.

Suggestion for improvement:
Ensure consistency in marking optional fields. For example, employeeInfoAdd_2 and companyInfoAdd_2 are marked as optional, but it's not clear if other fields like companyInfoEmail are optional or required.

},

methods: {
createDeviceReturn(args = {}) {
return this.app.post({
path: "/create-order/",
...args,
});
},
},


async run({ $: step }) {
const {
employeeInfoEmail,
employeeInfoName,
employeeInfoAdd_1,
employeeInfoAdd_2,
employeeInfoCity,
employeeInfoState,
employeeInfoZip,
employeeInfoPhone,
companyInfoPerson,
companyInfoCompanyName,
companyInfoAdd_1,
companyInfoAdd_2,
companyInfoCity,
companyInfoState,
companyInfoZip,
companyInfoPhone,
companyInfoEmail,
typeOfEquipment,
orderType

} = this;

const response = await createDeviceReturn({
step,
data: {
type_of_equipment: typeOfEquipment,
order_type: orderType,
employee_info: {
email: employeeInfoEmail,
name: employeeInfoName,
address_line_1: employeeInfoAdd_1,
address_line_2: employeeInfoAdd_2,
address_city: employeeInfoCity,
address_state: employeeInfoState,
address_zip: employeeInfoZip,
phone: employeeInfoPhone,
},
company_info: {
return_person_name: companyInfoPerson,
return_company_name: companyInfoCompanyName,
return_address_line_1: companyInfoAdd_1,
return_address_line_2: companyInfoAdd_2,
return_address_city: companyInfoCity,
return_address_state: companyInfoState,
return_address_zip: companyInfoZip,
email: companyInfoEmail,
phone: companyInfoPhone,
},
},
});

step.export("$summary", `Successfully created device return order with ID \`${response.order}\``);

return response;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-implemented run function with clear process flow.

The run function is well-structured, using destructuring for clarity and handling the API response effectively. The feedback mechanism using step.export is appropriately used.

Suggestion for improvement:
Consider adding error handling for the API call to manage exceptions and provide error feedback to the user.




};

This file was deleted.

10 changes: 10 additions & 0 deletions components/remote_retrieval/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ async function streamIterator(stream) {
return resources;
}


function getParamFromUrl(url, key = "cursor") {
if (!url) {
return null;
}
const parsedUrl = new URL(url);
return parsedUrl.searchParams.get(key);
}
Comment on lines +10 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhance error handling in getParamFromUrl.

The getParamFromUrl function is a useful addition for extracting parameters from URLs. However, the current implementation does not handle exceptions that may be thrown by the URL constructor when given an invalid URL. This could lead to unhandled exceptions if the URL format is incorrect.

Consider adding a try-catch block around the URL constructor to handle these cases gracefully:

function getParamFromUrl(url, key = "cursor") {
  if (!url) {
    return null;
  }
+ try {
    const parsedUrl = new URL(url);
    return parsedUrl.searchParams.get(key);
+ } catch (error) {
+   console.error("Invalid URL provided:", url);
+   return null;
+ }
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function getParamFromUrl(url, key = "cursor") {
if (!url) {
return null;
}
const parsedUrl = new URL(url);
return parsedUrl.searchParams.get(key);
}
function getParamFromUrl(url, key = "cursor") {
if (!url) {
return null;
}
try {
const parsedUrl = new URL(url);
return parsedUrl.searchParams.get(key);
} catch (error) {
console.error("Invalid URL provided:", url);
return null;
}
}


export default {
streamIterator,
getParamFromUrl,
};
2 changes: 1 addition & 1 deletion components/remote_retrieval/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/remote_retrieval",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pipedream Remote Retrieval Components",
"main": "remote_retrieval.app.mjs",
"keywords": [
Expand Down
64 changes: 20 additions & 44 deletions components/remote_retrieval/remote_retrieval.app.mjs
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
import { axios } from "@pipedream/platform";
import utils from "./common/utils.mjs";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "remote_retrieval",
propDefinitions: {
oid: {
type: "string",
label: "Order ID",
description: "The ID of the order to retrieve.",
async options({ page }) {
const orders = await this.getDeviceReturnOrders({
params: {
page: page + 1,
},
});
if (orders.message === "Data not found!") {
return [];
}
return orders?.map(({
order_id: value, shipments,
}) => ({
value,
label: `Order ID: ${value} - ${shipments.device_type}`,
})) || [];
},
},
},
propDefinitions: { },
methods: {
getBaseUrl() {
return `${constants.BASE_URL}${constants.VERSION_PATH}`;
Expand Down Expand Up @@ -59,50 +38,40 @@ export default {
...args,
});
},
getOrder({
oid, ...args
} = {}) {
return this.makeRequest({
path: `/device_returns?oid=${oid}/`,
...args,
});
},
getDeviceReturnOrders(args = {}) {
return this.makeRequest({
path: "/device_returns",
...args,
});
},
getPendingOrders(args = {}) {
allOrders(args = {}) {
return this.makeRequest({
path: "/pending-orders/",
path: "/orders/",
...args,
});
},

async *getResourcesStream({
resourceFn,
resourceFnArgs,
resourceName,
max = constants.DEFAULT_MAX,
}) {
let page = 1;
let cursor;
let resourcesCount = 0;

while (true) {
const response =
await resourceFn({
...resourceFnArgs,
params: {
page,
cursor,
...resourceFnArgs?.params,
},
});

if (!response || response.message === "Data not found!") {
const nextResources = resourceName && response[resourceName] || response;

if (!nextResources?.length) {
console.log("No more resources found");
return;
}

for (const resource of response) {
for (const resource of nextResources) {
yield resource;
resourcesCount += 1;

Expand All @@ -111,8 +80,15 @@ export default {
}
}

page++;
if (!response.next) {
console.log("No next cursor found");
return;
}

cursor = utils.getParamFromUrl(response.next);
}
},


},
};
Loading