Hey <@U03G6GG8HL0> not shipped to prod yet, but h...
# api
a
Hey @Varun Krishnamurthy not shipped to prod yet, but hopefully will test it properly and merge today. Will keep you guys posted @Vikram too! Also new admin endpoints coming soon!
❤️ 1
v
any updates on this?
v
Hi @Agusti , just wanted to check if you have an update on this!
a
Hey @Varun Krishnamurthy I’ve been looking into this, I expect to have an initial working version soon and refactor later to do some cleanup of duplicated code I’d be introducing.
v
@Agusti would you mind unblocking me by posting a sample response from the API? it would be much appreciated 🙏
👍 1
a
Sure gimme a sec!
{{baseUrl}}/v1/users/:id/availability?dateFrom=2022-06-02T00%3A00%3A00%2B02%3A00&dateTo=2022-06-02T23%3A59%3A59%2B02%3A00&eventTypeId=46055
Copy code
{
  "busy": [],
  "timeZone": "Europe/London",
  "workingHours": [
    {
      "days": [
        1,
        2,
        3,
        4,
        5
      ],
      "startTime": 480,
      "endTime": 960
    }
  ]
}
v
do u have a example with the
busy
field populated as well?
a
Lemme add some bookings to myself on localhost
v
also what format/units is
startTime
and
endTime
in?
this looks great tho!
🙏 1
a
The api endpoint is very similar to this one but query is ID instead of username slug https://github.com/calcom/cal.com/blob/main/apps/web/pages/api/availability/%5Buser%5D.ts
Im seeing this on startTime, const dateFrom = dayjs(asStringOrNull(req.query.dateFrom)); startTime: dateFrom.format(),
Copy code
const busyTimes = await getBusyTimes({
    credentials: currentUser.credentials,
    startTime: dateFrom.format(),
    endTime: dateTo.format(),
    eventTypeId,
    userId: currentUser.id,
    selectedCalendars,
  });

  const bufferedBusyTimes = busyTimes.map((a) => ({
    start: dayjs(a.start).subtract(currentUser.bufferTime, "minute"),
    end: dayjs(a.end).add(currentUser.bufferTime, "minute"),
  }));
Copy code
{
  "busy": [
    {
      "start": "2022-06-09T03:46:03.246Z",
      "end": "2022-06-09T04:16:03.247Z"
    },
    {
      "start": "2022-06-09T08:00:00.000Z",
      "end": "2022-06-09T08:30:00.000Z"
    }
  ],
  "timeZone": "Europe/London",
  "workingHours": [
    {
      "days": [
        1,
        2,
        3,
        4,
        5
      ],
      "startTime": 480,
      "endTime": 960
    }
  ]
}
so Busy is an array with objects that containt start and end datetimes as strings
v
got it. although the startTime on the
workingHours
field seems to be in another format. ill just play around with it once its live but this is enough for me to get started. Any eta on when we can expect something live?
a
Jun 10 (Friday) I think if all goes well
v
got it thanks
a
Also startTime/endTime might get canned
Copy code
// DEPRECATED - TO BE REMOVED
  startTime            Int                  @default(0)
  endTime              Int                  @default(1440)
  // </DEPRECATED>
this on schema.prisma User model
seems to be integers? Not sure how it worked before, prob we’re moving to new Schedules anyways and this is just a fallback for older accounts? Need to ask @Emrysal or @zomars about it