Skip to content

Commit 5767ded

Browse files
committed
new components
1 parent 884ec80 commit 5767ded

File tree

8 files changed

+251
-4
lines changed

8 files changed

+251
-4
lines changed

components/jobber/actions/create-client/create-client.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "jobber-create-client",
66
name: "Create Client",
77
description: "Generates a new client within Jobber. [See the documentation](https://developer.getjobber.com/docs)",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "action",
1010
props: {
1111
jobber,

components/jobber/actions/create-quote/create-quote.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "jobber-create-quote",
55
name: "Create Quote",
66
description: "Generates a new quote for a client's property in Jobber. [See the documentation](https://developer.getjobber.com/docs/)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
jobber,

components/jobber/actions/create-request/create-request.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "jobber-create-request",
77
name: "Create Service Request",
88
description: "Creates a new service request for a client's first property within Jobber. [See the documentation](https://developer.getjobber.com/docs/)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
jobber,
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import jobber from "../../jobber.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "jobber-filter-quotes",
6+
name: "Filter Quotes",
7+
description: "Filter quotes by status, quote number, or cost in Jobber. [See the documentation](https://developer.getjobber.com/docs)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
jobber,
12+
status: {
13+
type: "string",
14+
label: "Status",
15+
description: "The status to filter quotes by",
16+
options: [
17+
"draft",
18+
"awaiting_response",
19+
"archived",
20+
"approved",
21+
"converted",
22+
"changes_requested",
23+
],
24+
optional: true,
25+
},
26+
clientId: {
27+
propDefinition: [
28+
jobber,
29+
"clientId",
30+
],
31+
description: "The client ID to filter quotes by",
32+
optional: true,
33+
},
34+
quoteNumber: {
35+
type: "string",
36+
label: "Quote Number",
37+
description: "The quote number to filter quotes by",
38+
optional: true,
39+
},
40+
cost: {
41+
type: "string",
42+
label: "Cost",
43+
description: "The cost to filter quotes by",
44+
optional: true,
45+
},
46+
maxResults: {
47+
type: "integer",
48+
label: "Max Results",
49+
description: "The maximum number of results to return",
50+
default: 100,
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
const query = `query FilterQuotes($first: Int, $after: String, $filter: QuoteFilterAttributes) {
56+
quotes(first: $first, after: $after, filter: $filter) {
57+
nodes {
58+
${constants.QUOTE_FIELDS}
59+
}
60+
pageInfo {
61+
endCursor
62+
hasNextPage
63+
}
64+
}
65+
}`;
66+
67+
const args = {
68+
filter: {
69+
status: this.status,
70+
clientId: this.clientId,
71+
quoteNumber: this.quoteNumber
72+
? {
73+
eq: +this.quoteNumber,
74+
}
75+
: undefined,
76+
cost: this.cost
77+
? {
78+
eq: +this.cost,
79+
}
80+
: undefined,
81+
},
82+
};
83+
console.log(args);
84+
const quotes = await this.jobber.getPaginatedResources({
85+
query,
86+
args,
87+
resourceKey: "quotes",
88+
max: this.maxResults,
89+
});
90+
$.export("$summary", `Successfully found ${quotes.length} quote${quotes.length === 1
91+
? ""
92+
: "s"}`);
93+
return quotes;
94+
},
95+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import jobber from "../../jobber.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "jobber-search-quotes",
6+
name: "Search Quotes",
7+
description: "Search for quotes using a search termin Jobber. [See the documentation](https://developer.getjobber.com/docs)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
jobber,
12+
searchTerm: {
13+
type: "string",
14+
label: "Search Term",
15+
description: "The search term to use to filter quotes",
16+
optional: true,
17+
},
18+
maxResults: {
19+
type: "integer",
20+
label: "Max Results",
21+
description: "The maximum number of results to return",
22+
default: 100,
23+
optional: true,
24+
},
25+
},
26+
async run({ $ }) {
27+
const query = `query SearchQuotes($first: Int, $after: String, $searchTerm: String) {
28+
quotes(first: $first, after: $after, searchTerm: $searchTerm) {
29+
nodes {
30+
${constants.QUOTE_FIELDS}
31+
}
32+
pageInfo {
33+
endCursor
34+
hasNextPage
35+
}
36+
}
37+
}`;
38+
39+
const args = {
40+
searchTerm: this.searchTerm,
41+
};
42+
const quotes = await this.jobber.getPaginatedResources({
43+
query,
44+
args,
45+
resourceKey: "quotes",
46+
max: this.maxResults,
47+
});
48+
$.export("$summary", `Successfully found ${quotes.length} quote${quotes.length === 1
49+
? ""
50+
: "s"}`);
51+
return quotes;
52+
},
53+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const QUOTE_FIELDS = `
2+
id
3+
title
4+
amounts {
5+
total
6+
}
7+
client {
8+
id
9+
name
10+
}
11+
clientHubUri
12+
clientHubViewedAt
13+
contractDisclaimer
14+
createdAt
15+
depositAmountUnallocated
16+
depositRecords {
17+
nodes {
18+
id
19+
}
20+
}
21+
jobberWebUri
22+
jobs {
23+
nodes {
24+
id
25+
title
26+
}
27+
}
28+
lineItems {
29+
nodes {
30+
id
31+
category
32+
name
33+
quantity
34+
totalPrice
35+
}
36+
}
37+
message
38+
quoteNumber
39+
quoteStatus
40+
request {
41+
id
42+
}
43+
salesperson {
44+
id
45+
}
46+
taxDetails {
47+
totalTaxAmount
48+
}
49+
transitionedAt
50+
updatedAt
51+
`;
52+
53+
export default {
54+
QUOTE_FIELDS,
55+
};

components/jobber/jobber.app.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,49 @@ export default {
8888
...opts,
8989
});
9090
},
91+
async *paginate({
92+
query,
93+
args = {},
94+
resourceKey,
95+
max,
96+
}) {
97+
let counter = 0;
98+
let hasNextPage;
99+
let endCursor;
100+
do {
101+
const variables = {
102+
after: endCursor,
103+
first: 1,
104+
...args,
105+
};
106+
const { data } = await this.post({
107+
data: {
108+
query,
109+
variables,
110+
},
111+
});
112+
const {
113+
nodes, pageInfo,
114+
} = data[resourceKey];
115+
if (!nodes?.length) {
116+
return;
117+
}
118+
for (const node of nodes) {
119+
counter += 1;
120+
yield node;
121+
}
122+
({
123+
hasNextPage, endCursor,
124+
} = pageInfo);
125+
} while (hasNextPage && counter < max);
126+
},
127+
async getPaginatedResources(args) {
128+
const results = [];
129+
const resources = this.paginate(args);
130+
for await (const resource of resources) {
131+
results.push(resource);
132+
}
133+
return results;
134+
},
91135
},
92136
};

components/jobber/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/jobber",
3-
"version": "0.1.1",
3+
"version": "0.2.1",
44
"description": "Pipedream Jobber Components",
55
"main": "jobber.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)