Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlevel new actions #11507

Merged
merged 16 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/highlevel_oauth/.gitignore

This file was deleted.

51 changes: 51 additions & 0 deletions components/highlevel_oauth/actions/common/common.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { parseObjectEntries } from "../../common/utils.mjs";
import app from "../../highlevel_oauth.app.mjs";

export default {
props: {
app,
name: {
type: "string",
label: "First Name",
description: "Full name of the contact, e.g. `Rosan Deo`",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "Email of the contact, e.g. `rosan@deos.com`",
optional: true,
},
phone: {
type: "string",
label: "Phone Number",
description: "Phone number of the contact, e.g. `+1 888-888-8888`",
optional: true,
},
gender: {
type: "string",
label: "Gender",
description: "Gender of the contact, e.g. `male`",
optional: true,
},
additionalOptions: {
type: "object",
label: "Additional Options",
description:
"Additional parameters to send in the request. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact) for available parameters. Values will be parsed as JSON where applicable.",
optional: true,
},
},
methods: {
getData() {
const {
app, additionalOptions, ...data
} = this;
return {
app,
...data,
...(additionalOptions && parseObjectEntries(additionalOptions)),
};
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import common from "../common/common.mjs";

const {
props: {
app, ...props
},
} = common;

export default {
...common,
key: "highlevel_oauth-create-contact",
name: "Create Contact",
description: "Creates a new contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact)",
version: "0.0.1",
type: "action",
props: {
app,
locationId: {
propDefinition: [
app,
"locationId",
],
},
...props,
},
async run({ $ }) {
const {
app, ...data
} = this.getData();
const response = await app.createContact({
$,
data,
});

$.export("$summary", `Successfully created contact (ID: ${response?.contact?.id})`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import common from "../common/common.mjs";

const {
props: {
app, ...props
},
} = common;

export default {
...common,
key: "highlevel_oauth-update-contact",
name: "Update Contact",
description: "Updates a selected contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/9ce5a739d4fb9-update-contact)",
version: "0.0.1",
type: "action",
props: {
app,
contactId: {
propDefinition: [
app,
"contactId",
],
},
...props,
},
async run({ $ }) {
const {
app, data: {
contactId, ...data
},
} = this.getData();
const response = await app.updateContact({
$,
contactId,
data,
});

$.export("$summary", `Successfully updated contact (ID: ${contactId})`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import common from "../common/common.mjs";

const {
props: {
app, ...props
},
} = common;

export default {
...common,
key: "highlevel_oauth-upsert-contact",
name: "Upsert Contact",
description: "Creates or updates a contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/f71bbdd88f028-upsert-contact)",
version: "0.0.1",
type: "action",
props: {
app,
locationId: {
propDefinition: [
app,
"locationId",
],
},
...props,
},
async run({ $ }) {
const {
app, ...data
} = this.getData();
const response = await app.upsertContact({
$,
data,
});

$.export("$summary", `Successfully upserted contact (ID: ${response?.contact?.id})`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/highlevel_oauth/app/highlevel_oauth.app.ts

This file was deleted.

22 changes: 22 additions & 0 deletions components/highlevel_oauth/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function optionalParseAsJSON(value) {
try {
return JSON.parse(value);
} catch (e) {
return value;
}
}

export function parseObjectEntries(value) {
const obj = typeof value === "string"
? JSON.parse(value)
: value;
return Object.fromEntries(
Object.entries(obj).map(([
key,
value,
]) => [
key,
optionalParseAsJSON(value),
]),
);
}
100 changes: 100 additions & 0 deletions components/highlevel_oauth/highlevel_oauth.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "highlevel_oauth",
propDefinitions: {
locationId: {
type: "string",
label: "Location ID",
description: "Select a location or provide a custom location ID",
async options({ page }) {
const { locations } = await this.searchLocations({
params: {
limit: page,
},
});
return locations?.map(({
id, name,
}) => ({
label: name,
value: id,
}));
},
},
contactId: {
type: "string",
label: "Contact ID",
description: "Search for a contact or provide a custom contact ID",
useQuery: true,
async options({ query }) {
const { contacts } = await this.searchContacts({
params: {
query,
limit: 100,
},
});
return contacts?.map(({
id, name, email,
}) => ({
label: name ?? email ?? id,
value: id,
}));
},
},
},
methods: {
_baseUrl() {
return "https://services.leadconnectorhq.com";
},
async _makeRequest({
$ = this,
headers,
...otherOpts
}) {
return axios($, {
baseURL: this._baseUrl(),
headers: {
...headers,
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
},
...otherOpts,
});
},
async createContact(args) {
return this._makeRequest({
method: "POST",
url: "/contacts",
...args,
});
},
async updateContact({
contactId, ...args
}) {
return this._makeRequest({
method: "PUT",
url: `/contacts/${contactId}`,
...args,
});
},
async upsertContact(args) {
return this._makeRequest({
method: "POST",
url: "/contacts/upsert",
...args,
});
},
async searchContacts(args) {
return this._makeRequest({
url: "/contacts",
...args,
});
},
async searchLocations(args) {
return this._makeRequest({
url: "/locations/search",
...args,
});
},
},
};
10 changes: 6 additions & 4 deletions components/highlevel_oauth/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@pipedream/highlevel_oauth",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream HighLevel (OAuth) Components",
"main": "dist/app/highlevel_oauth.app.mjs",
"main": "highlevel_oauth.app.mjs",
"keywords": [
"pipedream",
"highlevel_oauth"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/highlevel_oauth",
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.2"
}
}
}
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.

Loading