Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/revolunet/node-sellsy
Node Sellsy API wrapper
https://github.com/revolunet/node-sellsy
api crm nodejs sellsy-api
Last synced: 7 days ago
JSON representation
Node Sellsy API wrapper
- Host: GitHub
- URL: https://github.com/revolunet/node-sellsy
- Owner: revolunet
- License: mit
- Created: 2015-08-05T14:52:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-10T10:47:42.000Z (almost 2 years ago)
- Last Synced: 2024-10-04T13:41:11.532Z (about 1 month ago)
- Topics: api, crm, nodejs, sellsy-api
- Language: JavaScript
- Homepage: https://github.com/revolunet/node-sellsy
- Size: 207 KB
- Stars: 17
- Watchers: 4
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-sellsy
[![npm](https://img.shields.io/npm/v/node-sellsy.svg)](https://www.npmjs.com/package/node-sellsy) ![license](https://img.shields.io/npm/l/node-sellsy.svg) [![github-issues](https://img.shields.io/github/issues/revolunet/node-sellsy.svg)](https://github.com/revolunet/node-sellsy/issues)
![nodei.co](https://nodei.co/npm/node-sellsy.png?downloads=true&downloadRank=true&stars=true)
Node Sellsy API wrapper - works in NodeJS **and** in the browser.
The official [Sellsy API](http://api.sellsy.fr/index) is PHP based so here's a JavaScript handy replacement.
It can helps you automate most of Sellsy from their API.
For example i use a Stripe webhook to automate actions in Sellsy.
## Features
- Works with your oauth private app id
- Simple promise call for all methods in http://api.sellsy.fr/documentation/methodes## QuickStart
`npm i --save node-sellsy`
```js
var Sellsy = require("node-sellsy");var sellsy = new Sellsy({
creds: {
consumerKey: "myConsumerKey",
consumerSecret: "myConsumerSecret",
userToken: "myUserToken",
userSecret: "myUserSecret",
},
});var params = {
search: {
contains: "test",
},
};sellsy
.api({
method: "Client.getList",
params: params,
})
.then((data) => {
console.log("data", data);
})
.catch((e) => {
console.log("error:", e);
});
```## API
You can access the full Sellsy API using `sellsy.api({ method, params })`.
This call returns a promise.
### Browser usage
Sellsy API doesnt provide CORS access so here's a drop-in proxy you can deploy on your own to use `node-sellsy` on the client : [revolunet/sellsy-proxy](http://github.com/revolunet/sellsy-proxy).
Then, define the endPoint when creating your `Sellsy` instance :
```js
var sellsy = new Sellsy({
creds,
endPoint: "http://path/to/sellsy/proxy",
});
```### Higher-level API methods :
#### Customer
- `sellsy.customers.create(data)`
- `sellsy.customers.get({ email: '[email protected]' })`#### Document
- `sellsy.documents.create(data)`
- `sellsy.documents.createPayment(docType, docId, paymentData)`
- `sellsy.documents.getList(docType, search)`
- `sellsy.documents.getById(docType, docId)`
- `sellsy.documents.updateStep(docType, docId, step)`## Scripts
- **npm run readme** : `node ./node_modules/node-readme/bin/node-readme.js`
- **npm run test** : `find ./spec -iname '*.spec.js' -exec ./node_modules/.bin/babel-node {} \; | ./node_modules/.bin/tap-spec`
- **npm run zuul** : `./node_modules/zuul/bin/zuul -- spec/**/*.spec.js`
- **npm run build** : `babel -d ./dist ./src`## Examples
### Create an invoice
```js
let sellsy = new Sellsy({
creds: {
consumerKey: "myConsumerKey",
consumerSecret: "myConsumerSecret",
userToken: "myUserToken",
userSecret: "myUserSecret",
},
});const customerIdent = "1234";
const amountHorsTaxes = 42;sellsy.customers.get({ ident: customerIdent }).then((customer) => {
const documentData = {
document: {
doctype: "invoice",
thirdid: customer.id,
notes: customer.email,
currency: "1",
displayedDate: new Date().getTime() / 1000,
subject: "Sujet de la facture",
tags: "bookeo,stripe",
},
row: {
1: {
// use 'item' for object from catalog
row_type: "once",
row_name: "titre ligne facture",
row_linkedid: null,
row_notes: "notes ligne facture",
row_tax: 20,
row_unitAmount: amountHorsTaxes,
row_qt: 1,
},
},
};return sellsy.documents.create(documentData);
});
```Then you can use
`sellsy.documents.updateStep(createdDocument.type, createdDocument.id, 'paid')` to mark invoice as paid and `sellsy.documents.createPayment` to record the payment method
## Tests
```
Customers.create should call sellsy api✔ should call API twice
✔ should call Client.create with correct data
✔ should call Client.getList with correct dataCustomers.get should call sellsy api
✔ should call API
✔ should call get with correct data
✔ should return first resultsellsy.api should be defined
✔ should be equal
sellsy.api should init call oAuth.OAuth with correct parameters
✔ consumerKey
✔ consumerSecretsellsy.api post correct data to API
✔ userToken
✔ userSecret
✔ request
✔ io_mode
✔ method
✔ paramsSellsy should use default api endPoint
✔ https://apifeed.sellsy.com/0/
Sellsy should use given api endPoint
✔ http://path.to/proxy/test/
total: 17
passing: 17
duration: 1.8s
```## Author
Julien Bouquillon http://github.com/revolunet and [contributors](https://github.com/revolunet/node-sellsy/graphs/contributors)
## License
- **MIT** : http://opensource.org/licenses/MIT