Skip to content

[73533] Support remaining Scheduler endpoints#287

Merged
mrashed-dev merged 15 commits intomainfrom
mostafarashed/sc-73533/support-remaining-scheduler-api-endpoints
Nov 18, 2021
Merged

[73533] Support remaining Scheduler endpoints#287
mrashed-dev merged 15 commits intomainfrom
mostafarashed/sc-73533/support-remaining-scheduler-api-endpoints

Conversation

@mrashed-dev
Copy link
Contributor

@mrashed-dev mrashed-dev commented Nov 12, 2021

Description

This PR adds the remaining Scheduler endpoints

Usage

Checking Provider Availability

// Google Availability
const googleAvailability = await nylas.scheduler.getGoogleAvailability();

// Office 365 Availability
const o365Availability = await nylas.scheduler.getOffice365Availability();

Retrieve available time slots

const availabileTimeslots = await nylas.scheduler.getAvailableTimeslots('slug');

Book a time slot

const slot = new SchedulerSlot(nylas);
slot.accountId = 'test-account-id';
slot.calendarId = 'test-calendar-id';
slot.emails = ['recipient@example.com'];
slot.start = new Date("2021-08-24T15:05:48.000Z");
slot.end = new Date("2021-08-24T16:05:48.000Z");

const timeslotToBook = new SchedulerTimeslot(nylas);
timeslotToBook.additionalValues = {
  test: 'yes',
};
timeslotToBook.email = 'recipient@example.com';
timeslotToBook.locale = 'en_US';
timeslotToBook.name = 'Recipient Doe';
timeslotToBook.timezone = 'America/New_York';
timeslotToBook.slot = slot;

const availabileTimeslots = await nylas.scheduler.bookTimeslot('slug', timeslotToBook);

Confirm a booking

const bookingConfirmation = await nylas.scheduler.confirmBooking('slug', 'edit-hash');

Cancel a booking

await nylas.scheduler.cancelBooking('slug', 'edit-hash', 'reason');

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@mrashed-dev mrashed-dev requested a review from tbadun November 12, 2021 22:19
@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #73533: Support remaining Scheduler API endpoints.

- Add a new type representing the upload image API response
- Add a new class representing the calendars response, and desearlize list of calendars into list of calendar objects
The baseurl previously was modified at the NylasConnection level, which unless cloned, causes problems for subsequent non-scheduler calls. Instead of overwriting it there, pass in a baseUrl option that will override the base url when needed.
Copy link

@tbadun tbadun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't attest to javascript but endpoint stuff looks good :)

name?: string;
}
SchedulerAvailableCalendars.collectionName = 'scheduler_available_calendars';
SchedulerAvailableCalendars.attributes = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these props be set directly in the class declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, no. Not in the SDK's current state at least, moving it into the class deceleration leads to a rabbit hole of TS errors.

Copy link

@ozsivanov ozsivanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just had a comment about a tiny potential improvement.

@mrashed-dev mrashed-dev merged commit bd0f5b5 into main Nov 18, 2021
@mrashed-dev mrashed-dev deleted the mostafarashed/sc-73533/support-remaining-scheduler-api-endpoints branch November 18, 2021 16:42
@mrashed-dev mrashed-dev mentioned this pull request Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants