Skip to content

Highlevel Oauth - New Components #16462

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "highlevel_oauth-add-contact-to-campaign",
name: "Add Contact to Campaign",
description: "Adds an existing contact to a campaign. [See the documentation](https://highlevel.stoplight.io/docs/integrations/ecf9b5b45deaf-add-contact-to-campaign)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
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.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
61 changes: 61 additions & 0 deletions components/highlevel_oauth/actions/create-record/create-record.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import common from "../../common/base.mjs";
import { parseObjectEntries } from "../../common/utils.mjs";

export default {
...common,
key: "highlevel_oauth-create-record",
name: "Create Record",
description: "Creates a custom object record. [See the documentation](https://highlevel.stoplight.io/docs/integrations/47e05e18c5d41-create-record)",
version: "0.0.1",
type: "action",
props: {
...common.props,
schemaKey: {
propDefinition: [
common.props.app,
"schemaKey",
],
},
ownerId: {
propDefinition: [
common.props.app,
"userId",
],
label: "Owner ID",
description: "The ID of a user representing the owner of the record. Only supported for custom objects.",
optional: true,
},
followerIds: {
propDefinition: [
common.props.app,
"userId",
],
type: "string[]",
label: "Follower IDs",
description: "An array of user IDs representing followers of the record. Only supported for custom objects",
optional: true,
},
properties: {
propDefinition: [
common.props.app,
"properties",
],
},
},
async run({ $ }) {
const response = await this.app.createRecord({
$,
schemaKey: this.schemaKey,
data: {
locationId: this.app.getLocationId(),
owners: [
this.ownerId,
],
followers: this.followerIds,
properties: parseObjectEntries(this.properties),
},
});
$.export("$summary", `Successfully created record with ID: ${response.record.id}`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
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.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
46 changes: 46 additions & 0 deletions components/highlevel_oauth/actions/update-note/update-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import common from "../../common/base.mjs";

export default {
...common,
key: "highlevel_oauth-update-note",
name: "Update Note",
description: "Updates a note associated with a contact. [See the documentation](https://highlevel.stoplight.io/docs/integrations/71814e115658f-update-note)",
version: "0.0.1",
type: "action",
props: {
...common.props,
contactId: {
propDefinition: [
common.props.app,
"contactId",
],
description: "The contact that the note is associated with",
},
noteId: {
propDefinition: [
common.props.app,
"noteId",
(c) => ({
contactId: c.contactId,
}),
],
},
body: {
type: "string",
label: "Body",
description: "The body of the note",
},
},
async run({ $ }) {
const response = await this.app.updateNote({
$,
contactId: this.contactId,
noteId: this.noteId,
data: {
body: this.body,
},
});
$.export("$summary", `Successfully updated note (ID: ${this.noteId})`);
return response;
},
};
71 changes: 71 additions & 0 deletions components/highlevel_oauth/actions/update-record/update-record.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import common from "../../common/base.mjs";
import { parseObjectEntries } from "../../common/utils.mjs";

export default {
...common,
key: "highlevel_oauth-update-record",
name: "Update Record",
description: "Updates a custom object record. [See the documentation](https://highlevel.stoplight.io/docs/integrations/b4c5fdbd3ec85-update-record)",
version: "0.0.1",
type: "action",
props: {
...common.props,
schemaKey: {
propDefinition: [
common.props.app,
"schemaKey",
],
},
recordId: {
propDefinition: [
common.props.app,
"recordId",
(c) => ({
schemaKey: c.schemaKey,
}),
],
},
ownerId: {
propDefinition: [
common.props.app,
"userId",
],
label: "Owner ID",
description: "The ID of a user representing the owner of the record. Only supported for custom objects.",
optional: true,
},
followerIds: {
propDefinition: [
common.props.app,
"userId",
],
type: "string[]",
label: "Follower IDs",
description: "An array of user IDs representing followers of the record. Only supported for custom objects",
optional: true,
},
properties: {
propDefinition: [
common.props.app,
"properties",
],
},
},
async run({ $ }) {
const response = await this.app.updateRecord({
$,
schemaKey: this.schemaKey,
recordId: this.recordId,
data: {
locationId: this.app.getLocationId(),
owners: [
this.ownerId,
],
followers: this.followerIds,
properties: parseObjectEntries(this.properties),
},
});
$.export("$summary", `Successfully updated record with ID: ${response.record.id}`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
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.2",
version: "0.0.3",
type: "action",
props: {
app,
Expand Down
3 changes: 3 additions & 0 deletions components/highlevel_oauth/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ function optionalParseAsJSON(value) {
}

export function parseObjectEntries(value) {
if (!value) {
return undefined;
}
const obj = typeof value === "string"
? JSON.parse(value)
: value;
Expand Down
139 changes: 139 additions & 0 deletions components/highlevel_oauth/highlevel_oauth.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,81 @@ export default {
})) || [];
},
},
noteId: {
type: "string",
label: "Note ID",
description: "The ID of the note to update",
async options({ contactId }) {
const { notes } = await this.listNotes({
contactId,
});
return notes?.map(({
id: value, body,
}) => ({
label: body.slice(0, 50),
value,
})) || [];
},
},
userId: {
type: "string",
label: "User ID",
description: "The ID of a user",
async options() {
const { users } = await this.listUsers({
params: {
locationId: this.getLocationId(),
},
});
return users?.map(({
id, name, email,
}) => ({
label: name ?? email ?? id,
value: id,
}));
},
},
schemaKey: {
type: "string",
label: "Object Schema Key",
description: "Key used to refer the custom / standard Object internally. For custom objects, the key must include the “custom_objects.” prefix, while standard objects use their respective object keys. This information is available on the Custom Objects Details page under Settings.",
async options() {
const { objects } = await this.listObjects({
params: {
locationId: this.getLocationId(),
},
});
return objects?.map(({
key: value, labels,
}) => ({
label: labels.plural,
value,
})) || [];
},
},
recordId: {
type: "string",
label: "Record ID",
description: "The ID of the record to be updated. Available on the Record details page under the 3 dots or in the url",
async options({
schemaKey, page,
}) {
const { customObjectRecords } = await this.searchRecords({
schemaKey,
params: {
page: page + 1,
pageLimit: 20,
},
});
return customObjectRecords?.map(({ id }) => id) || [];
},
},
properties: {
type: "object",
label: "Properties",
description: "Properties of the record as key/value pairs. Example: `{\"customer_number\":1424,\"ticket_name\":\"Customer not able login\",\"phone_number\":\"+917000000000\"}`",
optional: true,
},
},
methods: {
getLocationId() {
Expand Down Expand Up @@ -101,6 +176,15 @@ export default {
...args,
});
},
searchRecords({
schemaKey, ...args
}) {
return this._makeRequest({
method: "POST",
url: `/objects/${schemaKey}/records/search`,
...args,
});
},
listCampaigns(args = {}) {
return this._makeRequest({
url: "/campaigns/",
Expand All @@ -113,6 +197,61 @@ export default {
...args,
});
},
listNotes({
contactId, ...args
}) {
return this._makeRequest({
url: `/contacts/${contactId}/notes`,
...args,
});
},
getObject({
schemaKey, ...args
}) {
return this._makeRequest({
url: `/objects/${schemaKey}`,
...args,
});
},
listObjects(args = {}) {
return this._makeRequest({
url: "/objects/",
...args,
});
},
listUsers(args = {}) {
return this._makeRequest({
url: "/users/",
...args,
});
},
updateNote({
contactId, noteId, ...args
}) {
return this._makeRequest({
method: "PUT",
url: `/contacts/${contactId}/notes/${noteId}`,
...args,
});
},
createRecord({
schemaKey, ...args
}) {
return this._makeRequest({
method: "POST",
url: `/objects/${schemaKey}/records`,
...args,
});
},
updateRecord({
schemaKey, recordId, ...args
}) {
return this._makeRequest({
method: "PUT",
url: `/objects/${schemaKey}/records/${recordId}`,
...args,
});
},
addContactToCampaign({
contactId, campaignId, ...args
}) {
Expand Down
Loading
Loading