@eway-crm/connector
v1.0.192
Published
eWay-CRM API JavaScript connector library.
Downloads
499
Readme
eWay-CRM API
API used for communication with eWay-CRM web service. This library is a wrapper over HTTP/S communication and sessions. See our documentation for more information.
Installation
The simpliest way to start using this library is to get the NPM Package. To do that, just run this command in your NodeJS project's root dir:
npm i @eway-crm/connector
To get the best dev experience, we also recommend using TypeScript since this library contains the types headers.
Usage
This library wraps the communication with JSON API. For HTTP requests, it uses Axios. To provide the most variability, it lets you input JSON data and fetch JSON data in the same structure as the server uses. The only thing you don't have to care about is the sessionId
.
The actual usage is then the same as it would be for example with PHP. See the documentation for more.
Version Compatibility
This library is compatible with eWay-CRM 6.0.1 and higher. If you have got a lower version of your eWay-CRM, check the Updates section in the eWay-CRM Administration Application. If there is no update available, contact your eWay-CRM account manager or via other channel listed on our web page.
Establishing Connection
To communicate with eWay-CRM web service, we first have to establish connection. This must be done prior to every action we want to accomplish with use of the web service. To do that, we have to create new instance of ApiConnection
with seven parameters:
- Service url address (same as the one you use in Outlook)
- Username
- Password hash (md5 of the user's UTF8 password or hash created by the tool from eWay-CRM server component)
- App version identifier (name and version of the connecting client app - must consist of alphabet string and digits at the end)
- Client machine identifier (unique identifier of the connecting machine - MAC address for instance)
- Client machine name (human readable client machine - PC name for instance)
- Error handling callback (this callback is called everytime an unexpected error occurs)
import ApiConnection from '@eway-crm/connector';
const serviceUrl = 'https://trial.eway-crm.com/31994';
const username = 'api';
const passwordHash = '470AE7216203E23E1983EF1851E72947';
const connection = ApiConnection.create(serviceUrl, username, passwordHash, 'JSSample1', '00:00:00:00:00', 'SampleTestMachine', (err) => console.error(err));
⚠️ The code above does not support Microsoft Account Authenticaion. If you log into eWay-CRM with your Microsoft account, you need to implement your own OAuth2 client.
CORS
If you are developing a web app running on a different host than your eWay-CRM web service, you need to configure your eWay-CRM web service to allow cross-origin requests. To achieve that, put the following setting into appSettings
section of your web service's web.config file.
<add key="AccessControlAllowOrigin" value="https://YOUR-ORIGIN:PORT" />
⚠ If you add the setting above to your web.config, the web-based eWay-CRM Administration Center won't work in Internet Explorer, which will be a huge loss for the whole humankind.
Using the Connection Object
Once having the ApiConnection
instance, the API requests look like this searching of our user record.
connection.callMethod(
'SearchUsers',
{
transmitObject: { Username: username },
},
(result) => {
console.log('My user detail follows:');
console.log(result.Data[0]);
}
);