GitHub Actions workflows status
CodeClimate
A Node client to communicate with Collmex API. This was inspired by our co-collmex
package but rewritten with modern Javascript (removing deprecated dependencies in the process).
Note: this package uses a GitHub Action sync-data
(see here and there) to scrap Collmex API documentation daily to check that the CSV mapping (stored here) used is still up to date. This mapping could have been stored into a public CDN and fetched on client instanciation (& then on daily basis for persistent clients) but that would slow down performances and introduce a potential failure point (CDN down -> no data). Please make sure you always use the latest version of this package to ensure the answer you get from Collmex API is the correct one.
New in 1.14.0: when instanciating a new client, a check will be performed to compare your locally installed version of collmex-client
with the latest one available on npm
. If the version you use is not the latest one, a warning will be printed in stdout
.
npm i collmex-client
Module | Description |
---|---|
collmex-client | Creates a new client to communicate with Collmex API. |
Name | Description |
---|---|
Options | Options for the new Collmex client instanciation |
Creates a new client to communicate with Collmex API.
Returns: Collmex
- Collmex client
Param | Type | Description |
---|---|---|
opts | Options |
Options to be passed to instanciate a new client |
Example
const collmex = require('collmex-client')({
User: 'username',
Password: 'password',
CMXKundennummer: 123456,
Firma_Nr: 1,
Systemname: 'collmex-test'
})
Calls Collmex API.
Kind: static method of collmex-client
Returns: Promise.<(Array.<object>|Array.<array>|Array.<string>)>
- The fulfilled promise(s) value type depends on the output_format
provided when using get
or on the Output
option used when instanciating a new client
Param | Type | Default | Description |
---|---|---|---|
data | object | Array.<object> |
Data for the request to send to Collmex. Use an array if you would like to send multiple requests at once. |
|
[output_format] | string |
'object' |
Desired output type (set only for that specific call). See here for output_format valid values |
Example
// retrieve a given product from Collmex
const data = await collmex.get({ Satzart: 'PRODUCT_GET', Produktnummer: 12345 })
// you can also retrieve a given product
// AND the available stocks for that product (multiple requests)
const data = await collmex.get([
{ Satzart: 'PRODUCT_GET', Produktnummer: 12345 },
{ Satzart: 'STOCK_AVAILABLE_GET', Produktnummer: 12345 }
])
Options for the new Collmex client instanciation
Kind: global typedef
Properties
Name | Type | Default | Description |
---|---|---|---|
User | string |
Collmex user | |
Password | string |
Collmex password for given user | |
CMXKundennummer | number |
Collmex Customer Number | |
Firma_Nr | number |
Company Number (as registered with Collmex) | |
[Systemname] | string |
'collmex-client' |
User-agent you would like to use for your client |
[Output] | string |
'object' |
Desired output type. Will be set for any further get calls except if reassigned or overwritten via get output_format parameter. |
Value | Description |
---|---|
object |
default turns the response into an array of objects with named properties according to the collmex api documentation. numeric values are converted to js notation (dezimal point). Dates are turned to js/mysql compatible dates. |
array |
turns the response into an array of arrays. useful for bulk inserts into mysql for example. numeric values are converted to js notation (dezimal point). Dates are turned to js/mysql compatible dates. |
raw |
the raw response (CSV with ";" as the seperator). no conversion is performed. |
Notes
- all outputs are automatically converted to utf-8
- posting data can be performed via the get method as well