-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Components] remote_retrieval #12998 #13716
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from all commits
4175f31
de7e522
ea6be31
5f8b0c0
9b029bf
d3f634d
339d4f5
b9276cf
2723091
a2eabaf
e758e3a
c6d0022
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
import app from "../../remote_retrieval.app.mjs"; | ||
|
||
export default { | ||
key: "remote_retrieval-create-order", | ||
name: "Create Order", | ||
description: "Create order in Remote Retrieval. [See the documentation](https://www.remoteretrieval.com/api-integration/#create-order)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
typeOfEquipment: { | ||
propDefinition: [ | ||
app, | ||
"typeOfEquipment", | ||
], | ||
}, | ||
orderType: { | ||
propDefinition: [ | ||
app, | ||
"orderType", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
addressLine1: { | ||
propDefinition: [ | ||
app, | ||
"addressLine1", | ||
], | ||
}, | ||
addressLine2: { | ||
propDefinition: [ | ||
app, | ||
"addressLine2", | ||
], | ||
}, | ||
addressCity: { | ||
propDefinition: [ | ||
app, | ||
"addressCity", | ||
], | ||
}, | ||
addressState: { | ||
propDefinition: [ | ||
app, | ||
"addressState", | ||
], | ||
}, | ||
addressCountry: { | ||
propDefinition: [ | ||
app, | ||
"addressCountry", | ||
], | ||
}, | ||
addressZip: { | ||
propDefinition: [ | ||
app, | ||
"addressZip", | ||
], | ||
}, | ||
phone: { | ||
propDefinition: [ | ||
app, | ||
"phone", | ||
], | ||
}, | ||
returnPersonName: { | ||
propDefinition: [ | ||
app, | ||
"returnPersonName", | ||
], | ||
}, | ||
returnCompanyName: { | ||
propDefinition: [ | ||
app, | ||
"returnCompanyName", | ||
], | ||
}, | ||
returnAddressLine1: { | ||
propDefinition: [ | ||
app, | ||
"returnAddressLine1", | ||
], | ||
}, | ||
returnAddressLine2: { | ||
propDefinition: [ | ||
app, | ||
"returnAddressLine2", | ||
], | ||
}, | ||
returnAddressCity: { | ||
propDefinition: [ | ||
app, | ||
"returnAddressCity", | ||
], | ||
}, | ||
returnAddressState: { | ||
propDefinition: [ | ||
app, | ||
"returnAddressState", | ||
], | ||
}, | ||
returnAddressCountry: { | ||
propDefinition: [ | ||
app, | ||
"returnAddressCountry", | ||
], | ||
}, | ||
returnAddressZip: { | ||
propDefinition: [ | ||
app, | ||
"returnAddressZip", | ||
], | ||
}, | ||
companyEmail: { | ||
propDefinition: [ | ||
app, | ||
"companyEmail", | ||
], | ||
}, | ||
companyPhone: { | ||
propDefinition: [ | ||
app, | ||
"companyPhone", | ||
], | ||
}, | ||
}, | ||
|
||
async run({ $ }) { | ||
const response = await this.app.createOrder({ | ||
$, | ||
data: { | ||
orders: [ | ||
{ | ||
type_of_equipment: this.typeOfEquipment, | ||
order_type: this.orderType, | ||
employee_info: { | ||
email: this.email, | ||
name: this.name, | ||
address_line_1: this.addressLine1, | ||
address_line_2: this.addressLine2 || "", | ||
address_city: this.addressCity, | ||
address_state: this.addressState, | ||
address_country: this.addressCountry, | ||
address_zip: this.addressZip, | ||
phone: this.phone, | ||
}, | ||
company_info: { | ||
return_person_name: this.returnPersonName, | ||
return_company_name: this.returnCompanyName, | ||
return_address_line_1: this.returnAddressLine1, | ||
return_address_line_2: this.returnAddressLine2 || "", | ||
return_address_city: this.returnAddressCity, | ||
return_address_state: this.returnAddressState, | ||
return_address_country: this.returnAddressCountry, | ||
return_address_zip: this.returnAddressZip, | ||
email: this.companyEmail, | ||
phone: this.companyPhone, | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
$.export("$summary", "Successfully created order"); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import app from "../../remote_retrieval.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
key: "remote_retrieval-get-order-details", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: "Get Order Details", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "Get the details of the specified order. [See the documentation](https://www.remoteretrieval.com/api-integration/#order-detail)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
orderId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"orderId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const response = await this.app.getOrderDetails({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
params: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ORDER_ID: this.orderId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$.export("$summary", `Successfully retrieved details of order with ID '${this.orderId}'`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+18
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling and input validation The run method needs proper error handling and input validation:
async run({ $ }) {
+ if (!this.orderId) {
+ throw new Error("Order ID is required");
+ }
+ try {
const response = await this.app.getOrderDetails({
$,
params: {
ORDER_ID: this.orderId,
},
});
$.export("$summary", `Successfully retrieved details of order with ID '${this.orderId}'`);
return response;
+ } catch (error) {
+ $.export("$summary", `Failed to retrieve order details: ${error.message}`);
+ throw error;
+ }
}, 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||||
import app from "../../remote_retrieval.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||||||||
key: "remote_retrieval-get-orders", | ||||||||||||||||||||||||||||||||||||||||
name: "Get Orders", | ||||||||||||||||||||||||||||||||||||||||
description: "Get a list of all orders. [See the documentation](https://www.remoteretrieval.com/api-integration/#all-orders)", | ||||||||||||||||||||||||||||||||||||||||
version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||
type: "action", | ||||||||||||||||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||
const response = await this.app.getOrders({ | ||||||||||||||||||||||||||||||||||||||||
$, | ||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||
$.export("$summary", `Successfully retrieved ${response.results.length} orders`); | ||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+12
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling The run method should include proper error handling to provide meaningful feedback when API calls fail. async run({ $ }) {
+ try {
const response = await this.app.getOrders({
$,
});
$.export("$summary", `Successfully retrieved ${response.results.length} orders`);
return response;
+ } catch (error) {
+ $.export("$summary", `Failed to retrieve orders: ${error.message}`);
+ throw error;
+ }
}, 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
}; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
const BASE_URL = "https://remoteretrieval.com/RR-enterprise/remoteretrieval/public/index.php"; | ||
const VERSION_PATH = "/api/v1"; | ||
const DEFAULT_MAX = 600; | ||
|
||
export default { | ||
BASE_URL, | ||
VERSION_PATH, | ||
DEFAULT_MAX, | ||
export default { | ||
EQUIPMENT_TYPES: [ | ||
"Laptop", | ||
"Monitor", | ||
], | ||
ORDER_TYPES: [ | ||
"Return To Company", | ||
"Sell this Equipment", | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add input validation and error handling
The order creation lacks proper validation and error handling: