-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Konecty/konecty-save
Create new nodes for Konecty Integration
- Loading branch information
Showing
22 changed files
with
2,805 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,37 @@ | ||
Running node module locally: | ||
![Konecty](logo-konecty.png) | ||
|
||
In the directory containing the node’s package.json file, run: sudo npm link | ||
# Konecty Integration Nodes | ||
|
||
In your node-red user directory, typically ~/.node-red run: npm link node-red-contrib-konecty | ||
With these nodes, you can visually create full-featured flows to improve your business. | ||
|
||
|
||
## Getting started | ||
|
||
Install [Node-RED](http://nodered.org/docs/getting-started/installation), if you don't get it done before | ||
|
||
``` | ||
$ sudo npm install -g node-red | ||
``` | ||
|
||
Then go to the node-red directory `~/.node-red` and install the package | ||
|
||
``` | ||
$ cd ~/.node-red | ||
$ npm install node-red-contrib-konecty | ||
``` | ||
|
||
Then run | ||
|
||
``` | ||
node-red | ||
``` | ||
|
||
# Credits | ||
|
||
Thanks to our core team | ||
[Derotino Silveira](https://github.com/silveirado), | ||
[Marcus de Moura](https://github.com/marcusdemoura), | ||
[Leonardo Viva](https://github.com/7sete7), | ||
[Vinícius Freitas](https://github.com/viniciustinga) | ||
|
||
A special thanks for [Luciano Costa](https://github.com/lucianocosta) for your help to make this possible, and our awesome [contributors](https://github.com/Konecty/node-red-contrib-konecty/graphs/contributors). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
const axios = require('axios'); | ||
|
||
module.exports = ({ host, key }) => ({ | ||
async getDocuments() { | ||
const { data } = await axios.get(`${host}/rest/menu/documents`, { | ||
headers: { | ||
Authorization: key | ||
} | ||
}); | ||
return data; | ||
}, | ||
async getDocument(id) { | ||
const { data } = await axios.get(`${host}/rest/menu/documents/${id}`, { | ||
headers: { | ||
Authorization: key | ||
} | ||
}); | ||
return data; | ||
}, | ||
async getMenu(id) { | ||
const { data } = await axios.get(`${host}/rest/menu/list`, { | ||
headers: { | ||
Authorization: key | ||
} | ||
}); | ||
return data; | ||
}, | ||
async getSuggestions(document, field, search) { | ||
const { data } = await axios.get(`${host}/rest/data/${document}/lookup/${field}`, { | ||
headers: { | ||
Authorization: key | ||
}, | ||
params: { | ||
page: 1, | ||
start: 0, | ||
limit: 10, | ||
search | ||
} | ||
}); | ||
return data; | ||
}, | ||
async getIdFromCode(document, code) { | ||
const { data } = await axios.get(`${host}/rest/data/${document}/find`, { | ||
headers: { | ||
Authorization: key | ||
}, | ||
params: { | ||
limit: 1, | ||
filter: { match: 'and', conditions: [{ term: 'code', operator: 'equals', value: Number(code) }] }, | ||
fields: '_id, _updatedAt' | ||
} | ||
}); | ||
if (data.success === true && data.total === 1) { | ||
const { | ||
data: [{ _id, _updatedAt }] | ||
} = data; | ||
return { _id, _updatedAt: { $date: _updatedAt } }; | ||
} | ||
return {}; | ||
}, | ||
async getIdFromId(document, id) { | ||
const { data } = await axios.get(`${host}/rest/data/${document}/${id}`, { | ||
headers: { | ||
Authorization: key | ||
}, | ||
params: { | ||
fields: '_id, _updatedAt' | ||
} | ||
}); | ||
if (data.success === true && data.total === 1) { | ||
const { | ||
data: [{ _id, _updatedAt }] | ||
} = data; | ||
return { _id, _updatedAt: { $date: _updatedAt } }; | ||
} | ||
return {}; | ||
}, | ||
async update(document, ids, data) { | ||
const { data: result } = await axios.put( | ||
`${host}/rest/data/${document}`, | ||
{ | ||
data, | ||
ids | ||
}, | ||
{ | ||
headers: { | ||
Authorization: key | ||
} | ||
} | ||
); | ||
|
||
return result; | ||
}, | ||
async create(document, body) { | ||
const { data: result } = await axios.post(`${host}/rest/data/${document}`, body, { | ||
headers: { | ||
Authorization: key | ||
} | ||
}); | ||
|
||
return result; | ||
}, | ||
async getSuggestionsForDocument(document, field, search) { | ||
const { data } = await axios.get(`${host}/rest/data/${document}/find`, { | ||
headers: { | ||
Authorization: key | ||
}, | ||
params: { | ||
limit: 20, | ||
filter: { match: 'and', conditions: [{ term: field, operator: 'contains', value: search }] }, | ||
fields: `_id, ${field}`, | ||
sort: [{ property: field, direction: 'ASC' }] | ||
} | ||
}); | ||
return data; | ||
}, | ||
async getNextOnQueue(queueId) { | ||
const { data } = await axios.get(`${host}/rest/data/Queue/queue/next/${queueId}`, { | ||
headers: { | ||
Authorization: key | ||
} | ||
}); | ||
return data; | ||
}, | ||
async createContact(contactData) { | ||
const { data } = await axios.post( | ||
`${host}/rest/process/submit`, | ||
{ | ||
data: [ | ||
{ | ||
name: 'contact', | ||
data: contactData | ||
} | ||
] | ||
}, | ||
{ | ||
headers: { | ||
Authorization: key | ||
} | ||
} | ||
); | ||
return data; | ||
}, | ||
async createOpportunity(opportunityData) { | ||
const { data } = await axios.post( | ||
`${host}/rest/process/submit`, | ||
{ | ||
data: [ | ||
{ | ||
name: 'opportunity', | ||
data: opportunityData | ||
} | ||
] | ||
}, | ||
{ | ||
headers: { | ||
Authorization: key | ||
} | ||
} | ||
); | ||
return data; | ||
} | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.