[#61] Getting time slots using Locations

Migrated from Redmine #61 | Author: Sebastian Fratini
Status: Resolved | Priority: High, I’m very impatient | Created: 2017-11-01


Hi! We cannot figure it how to make the API request to get the time matrix when we have locations.

This is our current request:

@{
“jsonrpc”: “2.0”,
“id”: 1,
“method”: “getStartTimeMatrix”,
“params”: [“2017-11-01”,“2017-11-11”,4,[2],5]
}@

And this is the response:
@
{
“result”: {
“2017-11-01”: ,
“2017-11-02”: ,
“2017-11-03”: ,
“2017-11-04”: ,
“2017-11-05”: ,
“2017-11-06”: ,
“2017-11-07”: ,
“2017-11-08”: ,
“2017-11-09”: ,
“2017-11-10”: ,
“2017-11-11”:
},
“id”: “1”,
“jsonrpc”: “2.0”
}@

We are pretty sure the problem is the way we are sending the unitId list but the API documentation is not very clear about how to do this.

The company login is nsx if you want to check. If helps, this is the other example data we have:

Service:
@
{
“id”: “4”,
“name”: “Medicina General”,
“duration”: “15”,
“hide_duration”: “0”,
“description”: “Servicio de medicina general o guardia”,
“is_public”: “1”,
“is_active”: “1”,
“position”: “5”,
“file_id”: null,
“seo_url”: null,
“is_recurring”: “0”,
“picture”: null,
“picture_sub_path”: null,
“is_visible”: “1”,
“picture_path”: null,
“unit_map”: {
“2”: null,
“3”: null
}
}
@

Unit:
@
{
“id”: “2”,
“name”: “Gregory House”,
“description”: “”,
“phone”: “”,
“email”: “”,
“station_id”: “1”,
“qty”: “1”,
“is_active”: “1”,
“position”: “3”,
“is_visible”: “1”,
“file_id”: null,
“seo_url”: null,
“picture”: null,
“picture_sub_path”: null,
“picture_path”: null,
“event_map”: {
“4”: null
},
“locations”: [
“1”
],
“position_in_location”: {
“1”: “2”
}
},@

The answer seems always empty. This is a new calendar so all the slots are available. And we can see them in our booking website.

Thanks!

Sebastian Fratini wrote:

I have found that if I dont send the last parameter $count I get a response, but still does not seem to understand how to make sure the matrix has the location as a filter.

Dmytro Bondarev wrote:

Pass array of performer’s ids from location as $performerId parameter.

Sebastian Fratini wrote:

Can you give me an example? Because I don’t see a $performerId in the API:

This is the method: getStartTimeMatrix ($from, $to, $eventId, $unitId, $count)

Let’s say I want the time matrix for tis location:

{
“id”: “4”,
“title”: “Centro de Estudios”,
“units”: [
“4”
],
“events”: [
“2”,
“1”
],

        "units_position": {
            "4": "1"
        }
    }

And this service:

{
“id”: “2”,
“name”: “Odontologia”,
“duration”: “20”,
“description”: “Servicio de Odontologia”,
“unit_map”: {
“4”: null
}
},

And this unit:

{
“id”: “4”,
“name”: “Laura Muela”,
“event_map”: {
“2”: null
},
“locations”: [
“4”
],
“position_in_location”: {
“4”: “1”
}
}

How should I make the call?

I am doing this:

{
“jsonrpc”: “2.0”,
“id”: 1,
“method”: “getStartTimeMatrix”,
“params”: [
“2017-11-02”,
“2017-11-09”,
2, → Unit ID
[4] → Service ID
]
}

I don’t understand how to send the location. If you mean putting this as the serviceId: [“4”] I think this is fine however how can I make sure I get the slot for the location I want and not some other location that also supports this event and unit?

Thanks!

Dmytro Bondarev wrote:

Hi! Sorry for confusing.

Let’s say I want the time matrix for tis location:
ok you see that you have
“units”: [
“4”
]

So just pass [“4”] as $unitId in getStartTimeMatrix method.

Sebastian Fratini wrote:

No problem! Just trying to make sure I understand that. Now, just one last question, if 2 locations have the same unit enabled, like 4 in this case, how is the API going to choose the location I want? Or the issue is that in your design one unit is not supposed to be available in more than one location?

I was able to set one unit to 2 locations but it seems there is no way from the API to say “I want to book this person on this location and not the other”.

I hope I am being clear enough.
Thanks!

Dmytro Bondarev wrote:

Client supposed to select location first and then you will have unit list.
It is allowed to add unit to different locations, but take into account that this unit will be not available in case client book them (in any location).
So probably you need few units with the same name but in different locations.