Skip to content

Commit

Permalink
Actions & Sources - RepairShopr (PipedreamHQ#4939)
Browse files Browse the repository at this point in the history
* repairshopr

* pnpm

* Update URL format

* Update mandatory fields

* Update object name

* Update object name

* Fix bug

* revert version

* removing action

* create lead

Co-authored-by: vunguyenhung <[email protected]>
  • Loading branch information
vellames and vunguyenhung authored Dec 15, 2022
1 parent 9987ddd commit 795558f
Show file tree
Hide file tree
Showing 12 changed files with 753 additions and 4 deletions.
17 changes: 17 additions & 0 deletions components/repairshopr/actions/common/enums.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
TICKET_PROBLEM_TYPE: [
"Virus",
"TuneUp",
"Software",
"Other",
],
TICKET_STATUS: [
"New",
"In Progress",
"Resolved",
"Waiting for Parts",
"Waiting on Customer",
"Scheduled",
"Customer Reply",
],
};
96 changes: 96 additions & 0 deletions components/repairshopr/actions/create-customer/create-customer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import app from "../../repairshopr.app.mjs";

export default {
key: "repairshopr-create-customer",
name: "Create Customer",
description: "Create a new customer. [See the docs here](https://api-docs.repairshopr.com/#/Customer/post_customers)",
version: "0.0.1",
type: "action",
props: {
app,
businessName: {
propDefinition: [
app,
"businessName",
],
},
firstName: {
propDefinition: [
app,
"firstName",
],
},
lastName: {
propDefinition: [
app,
"lastName",
],
},
email: {
propDefinition: [
app,
"email",
],
},
phone: {
propDefinition: [
app,
"phone",
],
},
mobile: {
propDefinition: [
app,
"mobile",
],
},
address: {
propDefinition: [
app,
"address",
],
},
address2: {
propDefinition: [
app,
"address2",
],
},
city: {
propDefinition: [
app,
"city",
],
},
state: {
propDefinition: [
app,
"state",
],
},
zip: {
propDefinition: [
app,
"zip",
],
},
},
async run({ $ }) {
const data = {
business_name: this.businessName,
firstname: this.firstName,
lastname: this.lastName,
email: this.email,
phone: this.phone,
mobile: this.mobile,
address: this.address,
address2: this.address2,
city: this.city,
state: this.state,
zip: this.zip,
};
const res = await this.app.createCustomer(data, $);
$.export("$summary", "Customer successfully created");
return res?.customer;
},
};
106 changes: 106 additions & 0 deletions components/repairshopr/actions/create-lead/create-lead.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import app from "../../repairshopr.app.mjs";

export default {
key: "repairshopr-create-lead",
name: "Create Lead",
description: "Create a new lead. [See the docs here](https://api-docs.repairshopr.com/#/Lead/post_leads)",
version: "0.0.1",
type: "action",
props: {
app,
businessName: {
propDefinition: [
app,
"businessName",
],
description: "The business name of the lead.",
},
firstName: {
propDefinition: [
app,
"firstName",
],
description: "The first name of the lead.",
},
lastName: {
propDefinition: [
app,
"lastName",
],
description: "The last name of the lead.",
},
email: {
propDefinition: [
app,
"email",
],
description: "The email address of the lead.",
},
phone: {
propDefinition: [
app,
"phone",
],
description: "The phone number of the lead.",
},
mobile: {
propDefinition: [
app,
"mobile",
],
description: "The mobile number of the lead.",
},
address: {
propDefinition: [
app,
"address",
],
description: "The address of the lead.",
},
city: {
propDefinition: [
app,
"city",
],
description: "The city of the lead.",
},
state: {
propDefinition: [
app,
"state",
],
description: "The state of the lead.",
},
zip: {
propDefinition: [
app,
"zip",
],
description: "The zip code of the lead.",
},
converted: {
type: "boolean",
label: "Converted",
description: "Whether the lead has been converted to a customer.",
optional: true,
},
},
async run({ $ }) {
const data = {
business_name: this.businessName,
first_name: this.firstName,
last_name: this.lastName,
email: this.email,
phone: this.phone,
mobile: this.mobile,
address: this.address,
city: this.city,
state: this.state,
zip: this.zip,
converted: this.converted,
};
const res = await this.app.createLead(data, this);
$.export("$summary", "Lead successfully created");
return res?.lead;
},
};
83 changes: 83 additions & 0 deletions components/repairshopr/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import app from "../../repairshopr.app.mjs";
import enums from "../common/enums.mjs";

export default {
key: "repairshopr-create-ticket",
name: "Create Ticket",
description: "Create a new ticket. [See the docs here](https://api-docs.repairshopr.com/#/Ticket/post_tickets)",
version: "0.0.1",
type: "action",
props: {
app,
customerId: {
propDefinition: [
app,
"customerId",
],
},
ticketTypeId: {
type: "integer",
label: "Ticket Type ID",
description: "The ID of the ticket type.",
optional: true,
},
number: {
type: "string",
label: "Number",
description: "The ticket number.",
optional: true,
},
subject: {
type: "string",
label: "Subject",
description: "The subject of the ticket.",
},
dueDate: {
type: "string",
label: "Due Date",
description: "The due date of the ticket. Use the format `YYYY-MM-DD`.",
optional: true,
},
startAt: {
type: "string",
label: "Start At",
description: "The start date of the ticket. Use the format `YYYY-MM-DDTHH:MM:SS`.",
optional: true,
},
endAt: {
type: "string",
label: "End At",
description: "The end date of the ticket. Use the format `YYYY-MM-DDTHH:MM:SS`.",
optional: true,
},
problemType: {
type: "string",
label: "Problem Type",
description: "The problem type of the ticket.",
options: enums.TICKET_PROBLEM_TYPE,
},
status: {
type: "string",
label: "Status",
description: "The status of the ticket.",
options: enums.TICKET_STATUS,
optional: true,
},
},
async run({ $ }) {
const data = {
customer_id: this.customerId,
ticket_type_id: this.ticketTypeId,
number: this.number,
subject: this.subject,
due_date: this.dueDate,
start_at: this.startAt,
end_at: this.endAt,
problem_type: this.problemType,
status: this.status,
};
const res = await this.app.createTicket(data, $);
$.export("$summary", "Ticket successfully created");
return res?.ticket;
},
};
93 changes: 93 additions & 0 deletions components/repairshopr/actions/list-customers/list-customers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import app from "../../repairshopr.app.mjs";

export default {
key: "repairshopr-list-customers",
name: "List Customers",
description: "List Customers. [See the docs here](https://api-docs.repairshopr.com/#/Customer/get_customers)",
version: "0.0.1",
type: "action",
props: {
app,
sort: {
type: "string",
label: "Sort",
description: "A customer field to order by. Examples `firstname ASC`, `city DESC`",
optional: true,
},
query: {
type: "string",
label: "Query",
description: "Search Query",
optional: true,
},
firstName: {
type: "string",
label: "First Name",
description: "Any customers with a first name like the parameter",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "Any customers with a last name like the parameter",
optional: true,
},
businessName: {
type: "string",
label: "Business Name",
description: "Any customers with a business name like the parameter",
optional: true,
},
id: {
type: "integer[]",
label: "ID",
description: "Any customers with an ID in the list",
optional: true,
},
notId: {
type: "integer[]",
label: "Not ID",
description: "Any customers with an ID not in the list",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "Any customers with an email like the parameter",
optional: true,
},
includeDisabled: {
type: "boolean",
label: "Include Disabled",
description: "Whether or not the returned list of customers includes disabled customers",
optional: true,
},
},
async run({ $ }) {
const params = {
sort: this.sort,
query: this.query,
firstname: this.firstName,
lastname: this.lastName,
business_name: this.businessName,
id: this.id,
not_id: this.notId,
email: this.email,
include_disabled: this.includeDisabled,
};
const data = [];
let page = 1;
while (true) {
const { customers } = await this.app.listCustomers(page, params);
for (const customer of customers) {
data.push(customer);
}
if (customers.length === 0) {
break;
}
page++;
}
$.export("$summary", `Fetched ${data.length} customer(s)`);
return data;
},
};
Loading

0 comments on commit 795558f

Please sign in to comment.