Hi, Finally I have achieve to post appointments through pure JSON from the Browser with JavaScript.
I advise you to do tests with CURL command. For example:
For get appointments use the following command:
The previous command will show you by console all the appointments in JSON format registered in EA.
For get customers use the following command:
The previous command will show you by console all the customers in JSON format registered in EA.
For get avalilable hours for a specific date use the following command:
The previous command will show you by console all the available hours considering the following: The provider with Id=2, the service with Id=5 and the date 06/21/2018. All in JSON format. The date is optional.
You can POST appointments but you have to create a new customer in case isn't registered in EA. I didn't find this in the documentation clearly. So I had to do several tests.
For search a customer by email you can use the following command:
You can use the name, last name or another value too.
For create customers you can use the followin command:
After you send this request to the server you will get a JSON response from the server like the following:
{
"id": 11,
"firstName": "Julio",
"lastName": "Berne",
"email": "jb@domain",
"phone": "+56965736649",
"address": null,
"city": null,
"zip": null,
"notes": null
}
And you will get a customer id (new custemer Id = 11) generated by the EA server.
Then the only thing missing is to create the appointment. You can do it with the following command:
You will get a JSON response like following:
{
"id": 19,
"book": "2018-12-03 04:55:26",
"start": "2018-12-16 10:00:00",
"end": "2018-12-16 11:00:00",
"hash": "7a36dc51ff12b8ea841212ab571ae6ee",
"notes": null,
"customerId": 11,
"providerId": 2,
"serviceId": 1,
"googleCalendarId": null
}
I haven't tried integrating EA with google calendars yet. You only need adapt this commands to your JS code... which is the funniest part!!!
Hope this can help you
Bye.