A new version of MLM Soft's API, or API3, is a restful services which covers all the functionality of the platform.
It works with new version of Compensation Plan Engine (CPE32), based on document model, and Kafka highload queue.
API3 has its own auto-generated documentation which can be accessed the same endpoint as the API itself:
/api3/api/docs/
For example:
https://yourprojectname.mlmsoft.com/api3/api/docs
How to start using it
In order to use API3 you’ll need to send authenticated requests.
First, you’ll need to obtain auth token. For the beginning you can use admin access. Later when going live you’ll probably want to use Users’ credentials. But for the start:
curl -X 'POST' \ 'https://{your_project_url}/api3/auth/login' \ -H 'accept: */*' \ -H 'Content-Type: application/json' \ -d '{"login":"owner@domain.com", "password":"123345", "networkAccount":false}'
We're using the cURL to explain what has to be done.
Note that you’ll need to issue POST http request
Headers are self-explanatory.
Request data contains user’s login, password and flag indicating whether or not this user is network (your mlm network member) or admin (non-network) user.
In response you’ll get json like that:
{"payload":{"accessToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9SFRGzb2gNxSeeXfO1bgYdsynxjTA6BeZoo5B3C5eBMA","refreshToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJve9EWnnJAEgOPzMC9GPDD0c5fGxOTakmSlzdX6-rneI"},"error":null,"success":true}
The accessToken (payload.accessToken) is what we’re looking for. Use it for the consequent request(s)
Next request you need is probably about sending some volumes to the user when they purchase something:
curl -X 'POST' \ 'https://{your_project_url}/api3/document/create' \ -H 'accept: */*' \ -H 'Authorization: Bearer eyJEkicJp3Hy1N0XAgoZoltpnpGeBKreXA4' \ -H 'Content-Type: application/json' \ -d '{"Doc-type":"Purchase","data":{"accountId":1,"props":{"PV":10000}}}'
Our system is using documents to be used as incoming requests.
Endpoint for creating document is /document/create
Bearer token is the one you’ve got on previous step
In request you need to specify the document type (Purchase in that case) and document’s data. In our case it is account.id of the member that going to receive the volume and properties list to be updated according to your compensation plan. PV is general Personal Volume. So after such a request your network member with account id=1 will receive 10 000 points in PV.
Max SLA
Comments