new(all): hubspot.gblib new methods. New Keyword FIND CONTACT.
This commit is contained in:
parent
d8044124e3
commit
0fe8b8c1b6
4 changed files with 22 additions and 9 deletions
|
@ -145,6 +145,16 @@ export class DialogKeywords {
|
|||
return deal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds contacts in XRM.
|
||||
*
|
||||
* @example list = FIND CONTACT "Sandra"
|
||||
*/
|
||||
public async fndContact(name) {
|
||||
let s = new HubSpotServices(null, null, process.env.HUBSPOT_KEY);
|
||||
return await s.searchContact(name);
|
||||
}
|
||||
|
||||
|
||||
public getContentLocaleWithCulture(contentLocale) {
|
||||
switch (contentLocale) {
|
||||
|
|
|
@ -248,6 +248,10 @@ export class GBVMService extends GBService {
|
|||
return `${$2} = hear()`;
|
||||
});
|
||||
|
||||
code = code.replace(/(\w)\s*\=\s*find contact\s*(.*)/gi, ($0, $1, $2, $3) => {
|
||||
return `${$1} = fndContact(${$2})\n`;
|
||||
});
|
||||
|
||||
code = code.replace(/(\w+)\s*=\s*find\s*(.*)\s*or talk\s*(.*)/gi, ($0, $1, $2, $3) => {
|
||||
return `${$1} = sys().find(${$2})\n
|
||||
if (!${$1}) {
|
||||
|
@ -576,6 +580,9 @@ export class GBVMService extends GBService {
|
|||
code = code.replace(/("[^"]*"|'[^']*')|\bcreateDeal\b/gi, ($0, $1) => {
|
||||
return $1 === undefined ? 'this.createDeal' : $1;
|
||||
});
|
||||
code = code.replace(/("[^"]*"|'[^']*')|\bfndContact\b/gi, ($0, $1) => {
|
||||
return $1 === undefined ? 'this.fndContact' : $1;
|
||||
});
|
||||
code = code.replace(/("[^"]*"|'[^']*')|\bgetActiveTasks\b/gi, ($0, $1) => {
|
||||
return $1 === undefined ? 'this.getActiveTasks' : $1;
|
||||
});
|
||||
|
|
|
@ -146,16 +146,13 @@ export class HubSpotServices extends GBService {
|
|||
|
||||
public async searchContact(query) {
|
||||
const client = new hubspot.Client({ apiKey: this.key });
|
||||
const filter = { propertyName: 'createdate', operator: 'GTE', value: Date.now() - 30 * 60000 }
|
||||
const filterGroup = { filters: [filter] }
|
||||
const sort = JSON.stringify({ propertyName: 'createdate', direction: 'DESCENDING' })
|
||||
|
||||
const properties = ['createdate', 'firstname', 'lastname']
|
||||
const properties = ['createdate', 'firstname', 'lastname', 'phone', 'email']
|
||||
const limit = 100
|
||||
const after = 0
|
||||
|
||||
const publicObjectSearchRequest = {
|
||||
filterGroups: [filterGroup],
|
||||
sorts: [sort],
|
||||
query,
|
||||
properties,
|
||||
|
@ -164,8 +161,7 @@ export class HubSpotServices extends GBService {
|
|||
}
|
||||
|
||||
const result = await client.crm.contacts.searchApi.doSearch(publicObjectSearchRequest)
|
||||
console.log(JSON.stringify(result.body))
|
||||
return result.body;
|
||||
return result.body.results;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ export class GBServer {
|
|||
GBLog.verbose(`Error initializing storage: ${error}`);
|
||||
GBServer.globals.bootInstance =
|
||||
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
|
||||
|
||||
|
||||
}
|
||||
|
||||
core.ensureAdminIsSecured();
|
||||
|
@ -155,7 +155,7 @@ export class GBServer {
|
|||
await deployer.deployPackages(core, server, GBServer.globals.appPackages);
|
||||
await core.syncDatabaseStructure();
|
||||
|
||||
|
||||
|
||||
GBLog.info(`Publishing instances...`);
|
||||
const instances: IGBInstance[] = await core.loadAllInstances(
|
||||
core,
|
||||
|
@ -164,7 +164,7 @@ export class GBServer {
|
|||
);
|
||||
|
||||
if (instances.length === 0) {
|
||||
|
||||
|
||||
const instance = await importer.importIfNotExistsBotPackage(
|
||||
GBConfigService.get('BOT_ID'),
|
||||
'boot.gbot',
|
||||
|
|
Loading…
Add table
Reference in a new issue