Skip to content

Commit

Permalink
New Components - bilflo (PipedreamHQ#11840)
Browse files Browse the repository at this point in the history
* bilflo init

* [Components] bilflo PipedreamHQ#11732
Actions
 - Create Client
 - Assign Contract Job To Invoice
 - Create Contract Job

* pnpm update

* add datetime format description
  • Loading branch information
luancazarine authored May 8, 2024
1 parent 880bd75 commit 46d0452
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import bilflo from "../../bilflo.app.mjs";

export default {
key: "bilflo-assign-contract-job-to-invoice",
name: "Assign Contract Job to Invoice Group",
description: "Assigns a contract job to a specified invoice group for a client. [See the documentation](https://developer.bilflo.com/documentation#operations-tag-Clients)",
version: "0.0.1",
type: "action",
props: {
bilflo,
jobId: {
type: "integer",
label: "Contract Job Identifier",
description: "The unique identifier for the contract job.",
},
invoiceGroupId: {
type: "integer",
label: "Invoice Group Identifier",
description: "The unique identifier for the invoice group.",
},
},
async run({ $ }) {
const response = await this.bilflo.assignContractJobToInvoiceGroup({
$,
data: {
jobId: this.jobId,
invoiceGroupId: this.invoiceGroupId,
},
});
$.export("$summary", `Successfully assigned contract job ${this.jobId} to invoice group ${this.invoiceGroupId}`);
return response;
},
};
27 changes: 27 additions & 0 deletions components/bilflo/actions/create-client/create-client.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import bilflo from "../../bilflo.app.mjs";

export default {
key: "bilflo-create-client",
name: "Create Client",
description: "Creates a new client account in Bilflo. [See the documentation](https://developer.bilflo.com/documentation#operations-tag-Clients)",
version: "0.0.1",
type: "action",
props: {
bilflo,
businessName: {
type: "string",
label: "Business Name",
description: "The name of the business for the new client account.",
},
},
async run({ $ }) {
const response = await this.bilflo.createClient({
$,
data: {
businessName: this.businessName,
},
});
$.export("$summary", `Successfully created new client account with Id: ${response.data.clientId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import bilflo from "../../bilflo.app.mjs";

export default {
key: "bilflo-create-contract-job",
name: "Create Contract Job",
description: "Creates a new contract job in Bilflo. [See the documentation](https://developer.bilflo.com/documentation)",
version: "0.0.1",
type: "action",
props: {
bilflo,
clientId: {
propDefinition: [
bilflo,
"clientId",
],
},
contractorId: {
type: "integer",
label: "Contractor ID",
description: "The unique identifier for the contractor.",
},
contractorTypeId: {
type: "integer",
label: "Contractor Type ID",
description: "The unique identifier for the contractor type.",
options: [
{
label: "W2",
value: 1,
},
{
label: "1099",
value: 2,
},
],
},
timeCardMethodId: {
type: "integer",
label: "Time Card Method ID",
description: "The unique identifier for the time card method.",
},
overtimeRuleId: {
type: "integer",
label: "Overtime Rule ID",
description: "The unique identifier for the overtime rule.",
},
jobTitle: {
type: "string",
label: "Job Title",
description: "The title of the job.",
},
startDate: {
type: "string",
label: "Start Date",
description: "The start date of the contract job. **Format YYYY-MM-DDTHH:MM:SSZ**",
},
endDate: {
type: "string",
label: "End Date",
description: "The end date of the contract job. **Format YYYY-MM-DDTHH:MM:SSZ**",
},
firstWeekEndingDate: {
type: "string",
label: "First Week Ending Date",
description: "The first week ending date of the contract job. **Format YYYY-MM-DDTHH:MM:SSZ**",
},
burdenTypeId: {
type: "integer",
label: "Burden Type ID",
description: "The unique identifier for the burden type.",
},
},
async run({ $ }) {
const response = await this.bilflo.createContractJob({
$,
data: {
clientId: this.clientId,
contractorId: this.contractorId,
contractorTypeId: this.contractorTypeId,
timeCardMethodId: this.timeCardMethodId,
overtimeRuleId: this.overtimeRuleId,
jobTitle: this.jobTitle,
startDate: this.startDate,
endDate: this.endDate,
firstWeekEndingDate: this.firstWeekEndingDate,
burdenTypeId: this.burdenTypeId,
},
});

$.export("$summary", `Successfully created contract job Id: ${response.data.jobId}`);
return response;
},
};
68 changes: 63 additions & 5 deletions components/bilflo/bilflo.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "bilflo",
propDefinitions: {},
propDefinitions: {
clientId: {
type: "string",
label: "Client ID",
description: "The unique identifier for the client.",
async options() {
const { data } = await this.listClients();

return data.map(({
clientId: value, businessName: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.bilflo.com/v1";
},
_headers() {
return {
"company-id": this.$auth.company_id,
"Authorization": `Bearer ${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
createClient(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/Clients",
...opts,
});
},
listClients() {
return this._makeRequest({
path: "/Clients",
});
},
assignContractJobToInvoiceGroup(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/Clients/contractInvoiceGroups/assignContractJob",
...opts,
});
},
createContractJob(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/ContractJobs",
...opts,
});
},
},
};
};
8 changes: 6 additions & 2 deletions components/bilflo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/bilflo",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Bilflo Components",
"main": "bilflo.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.5"
}
}
}

5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 46d0452

Please sign in to comment.