|
| 1 | +import app from "../../remote_retrieval.app.mjs"; |
| 2 | + |
| 3 | +export default { |
| 4 | + key: "remote_retrieval-create-device-order", |
| 5 | + name: "Create Device Order", |
| 6 | + description: "Creates a device return order. [See the documentation](https://www.remoteretrieval.com/api-documentation/#create-order)", |
| 7 | + type: "action", |
| 8 | + version: "0.1.0", |
| 9 | + props: { |
| 10 | + app, |
| 11 | + |
| 12 | + employeeInfoEmail: { |
| 13 | + type: "string", |
| 14 | + label: "Employee Info Email", |
| 15 | + description: "Used in email communications with the employee." |
| 16 | + }, |
| 17 | + employeeInfoName: { |
| 18 | + type: "string", |
| 19 | + label: "Employee Info Name", |
| 20 | + description: "Employee full name to print on the shipping label." |
| 21 | + }, |
| 22 | + employeeInfoAdd_1: { |
| 23 | + type: "string", |
| 24 | + label: "Employee Info Address Line 1", |
| 25 | + description: "The first line of the employee address" |
| 26 | + }, |
| 27 | + employeeInfoAdd_2: { |
| 28 | + type: "string", |
| 29 | + label: "Employee Info Address Line 2", |
| 30 | + description: "The second line is optional for employee address", |
| 31 | + optional: true , |
| 32 | + }, |
| 33 | + employeeInfoCity: { |
| 34 | + type: "string", |
| 35 | + label: "Employee Info City", |
| 36 | + description: "City of employee", |
| 37 | + }, |
| 38 | + employeeInfoState: { |
| 39 | + type: "string", |
| 40 | + label: "Employee Info State", |
| 41 | + description: "State of employee", |
| 42 | + }, |
| 43 | + employeeInfoZip: { |
| 44 | + type: "string", |
| 45 | + label: "Employee Info Zip", |
| 46 | + description: "Zip code of employee", |
| 47 | + }, |
| 48 | + employeeInfoPhone: { |
| 49 | + type: "string", |
| 50 | + label: "Employee Info Phone", |
| 51 | + description: "Phone of employee", |
| 52 | + }, |
| 53 | + employeeInfoCountry: { |
| 54 | + type: "string", |
| 55 | + label: "Employee Info Country", |
| 56 | + description: "This service is only for USA", |
| 57 | + options: ["US"], |
| 58 | + default: "US", |
| 59 | + }, |
| 60 | + |
| 61 | + companyInfoPerson: { |
| 62 | + type: "string", |
| 63 | + label: "Company Info Person Name", |
| 64 | + description: "Receipient Name" |
| 65 | + }, |
| 66 | + companyInfoCompanyName: { |
| 67 | + type: "string", |
| 68 | + label: "Company Info Company Name", |
| 69 | + description: "Company Name" |
| 70 | + }, |
| 71 | + companyInfoAdd_1: { |
| 72 | + type: "string", |
| 73 | + label: "Company Info Address Line 1", |
| 74 | + description: "The first line of the company address" |
| 75 | + }, |
| 76 | + companyInfoAdd_2: { |
| 77 | + type: "string", |
| 78 | + label: "Company Info Address Line 2", |
| 79 | + description: "The second line is optional for company address", |
| 80 | + }, |
| 81 | + companyInfoCity: { |
| 82 | + type: "string", |
| 83 | + label: "Company Info City", |
| 84 | + description: "Company city", |
| 85 | + }, |
| 86 | + companyInfoState: { |
| 87 | + type: "string", |
| 88 | + label: "Company Info State", |
| 89 | + description: "Company State(Example: TX,AL,NJ)", |
| 90 | + }, |
| 91 | + companyInfoZip: { |
| 92 | + type: "string", |
| 93 | + label: "Company Info Zip", |
| 94 | + description: "Company Zip", |
| 95 | + }, |
| 96 | + companyInfoPhone: { |
| 97 | + type: "string", |
| 98 | + label: "Company Info Phone", |
| 99 | + description: "Company Phone", |
| 100 | + }, |
| 101 | + companyInfoEmail: { |
| 102 | + type: "string", |
| 103 | + label: "Company Info Email", |
| 104 | + description: "Company Email", |
| 105 | + }, |
| 106 | + typeOfEquipment: { |
| 107 | + type: "string", |
| 108 | + label: "Type of Equipment", |
| 109 | + description: "You can choose 'Laptop' or 'Monitor'", |
| 110 | + options: ['Laptop','Monitor'], |
| 111 | + default: "Laptop" |
| 112 | + }, |
| 113 | + orderType: { |
| 114 | + type: "string", |
| 115 | + label: "Order Type", |
| 116 | + description: "You can choose 'Return to Company' or 'Sell this Equipment'", |
| 117 | + options: ['Return to Company','Sell this Equipment'], |
| 118 | + default: "Return to Company" |
| 119 | + }, |
| 120 | + }, |
| 121 | + |
| 122 | + methods: { |
| 123 | + createDeviceReturn(args = {}) { |
| 124 | + return this.app.post({ |
| 125 | + path: "/create-order/", |
| 126 | + ...args, |
| 127 | + }); |
| 128 | + }, |
| 129 | + }, |
| 130 | + |
| 131 | + |
| 132 | + async run({ $: step }) { |
| 133 | + const { |
| 134 | + createDeviceReturn, |
| 135 | + employeeInfoEmail, |
| 136 | + employeeInfoName, |
| 137 | + employeeInfoAdd_1, |
| 138 | + employeeInfoAdd_2, |
| 139 | + employeeInfoCity, |
| 140 | + employeeInfoState, |
| 141 | + employeeInfoZip, |
| 142 | + employeeInfoPhone, |
| 143 | + companyInfoPerson, |
| 144 | + companyInfoCompanyName, |
| 145 | + companyInfoAdd_1, |
| 146 | + companyInfoAdd_2, |
| 147 | + companyInfoCity, |
| 148 | + companyInfoState, |
| 149 | + companyInfoZip, |
| 150 | + companyInfoPhone, |
| 151 | + companyInfoEmail, |
| 152 | + typeOfEquipment, |
| 153 | + orderType |
| 154 | + |
| 155 | + } = this; |
| 156 | + |
| 157 | + const response = await createDeviceReturn({ |
| 158 | + step, |
| 159 | + data: { |
| 160 | + type_of_equipment: typeOfEquipment, |
| 161 | + order_type: orderType, |
| 162 | + employee_info: { |
| 163 | + email: employeeInfoEmail, |
| 164 | + name: employeeInfoName, |
| 165 | + address_line_1: employeeInfoAdd_1, |
| 166 | + address_line_2: employeeInfoAdd_2, |
| 167 | + address_city: employeeInfoCity, |
| 168 | + address_state: employeeInfoState, |
| 169 | + address_zip: employeeInfoZip, |
| 170 | + phone: employeeInfoPhone, |
| 171 | + }, |
| 172 | + company_info: { |
| 173 | + return_person_name: companyInfoPerson, |
| 174 | + return_company_name: companyInfoCompanyName, |
| 175 | + return_address_line_1: companyInfoAdd_1, |
| 176 | + return_address_line_2: companyInfoAdd_2, |
| 177 | + return_address_city: companyInfoCity, |
| 178 | + return_address_state: companyInfoState, |
| 179 | + return_address_zip: companyInfoZip, |
| 180 | + email: companyInfoEmail, |
| 181 | + phone: companyInfoPhone, |
| 182 | + }, |
| 183 | + }, |
| 184 | + }); |
| 185 | + |
| 186 | + step.export("$summary", `Successfully created device return order with ID \`${response.order}\``); |
| 187 | + |
| 188 | + return response; |
| 189 | + }, |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | +}; |
0 commit comments