-
Notifications
You must be signed in to change notification settings - Fork 126
feat(scheduler): add GET /v3/scheduling/availability endpoint support #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { Overrides } from '../config.js'; | ||
| import { NylasResponse } from '../models/response.js'; | ||
| import { | ||
| AvailabilityResponse, | ||
| GetAvailabilityQueryParams, | ||
| } from '../models/scheduler.js'; | ||
| import { Resource } from './resource.js'; | ||
| import { makePathParams } from '../utils.js'; | ||
|
|
||
| /** | ||
| * The parameters for the {@link SchedulerAvailability.list} method | ||
| * @property queryParams The query parameters to include in the request | ||
| */ | ||
| export interface GetAvailabilityParams { | ||
| queryParams: GetAvailabilityQueryParams; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate
|
||
|
|
||
| export class SchedulerAvailability extends Resource { | ||
| /** | ||
| * Get availability for a scheduling configuration | ||
| * @return The availability response with time slots | ||
| */ | ||
| public list({ | ||
| queryParams, | ||
| overrides, | ||
| }: GetAvailabilityParams & | ||
| Overrides): Promise<NylasResponse<AvailabilityResponse>> { | ||
| return super._find({ | ||
| path: makePathParams('/v3/scheduling/availability', {}), | ||
| queryParams, | ||
| overrides, | ||
| }); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,19 @@ | ||
| import { Configurations } from './configurations.js'; | ||
| import { Sessions } from './sessions.js'; | ||
| import { Bookings } from './bookings.js'; | ||
| import { SchedulerAvailability } from './availability.js'; | ||
| import APIClient from '../apiClient.js'; | ||
|
|
||
| export class Scheduler { | ||
| public configurations: Configurations; | ||
| public bookings: Bookings; | ||
| public sessions: Sessions; | ||
| public availability: SchedulerAvailability; | ||
|
|
||
| constructor(apiClient: APIClient) { | ||
| this.configurations = new Configurations(apiClient); | ||
| this.bookings = new Bookings(apiClient); | ||
| this.sessions = new Sessions(apiClient); | ||
| this.availability = new SchedulerAvailability(apiClient); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import APIClient from '../../src/apiClient'; | ||
| import { SchedulerAvailability } from '../../src/resources/availability'; | ||
| jest.mock('../../src/apiClient'); | ||
|
|
||
| describe('SchedulerAvailability', () => { | ||
| let apiClient: jest.Mocked<APIClient>; | ||
| let availability: SchedulerAvailability; | ||
|
|
||
| beforeAll(() => { | ||
| apiClient = new APIClient({ | ||
| apiKey: 'apiKey', | ||
| apiUri: 'https://test.api.nylas.com', | ||
| timeout: 30, | ||
| headers: {}, | ||
| }) as jest.Mocked<APIClient>; | ||
|
|
||
| availability = new SchedulerAvailability(apiClient); | ||
| apiClient.request.mockResolvedValue({}); | ||
| }); | ||
|
|
||
| describe('list', () => { | ||
| it('should call apiClient.request with the correct params', async () => { | ||
| await availability.list({ | ||
| queryParams: { | ||
| startTime: '1659367800', | ||
| endTime: '1659369600', | ||
| configurationId: 'configuration123', | ||
| }, | ||
| overrides: { | ||
| apiUri: 'https://test.api.nylas.com', | ||
| headers: { override: 'foobar' }, | ||
| }, | ||
| }); | ||
|
|
||
| expect(apiClient.request).toHaveBeenCalledWith({ | ||
| method: 'GET', | ||
| path: '/v3/scheduling/availability', | ||
| queryParams: { | ||
| startTime: '1659367800', | ||
| endTime: '1659369600', | ||
| configurationId: 'configuration123', | ||
| }, | ||
| overrides: { | ||
| apiUri: 'https://test.api.nylas.com', | ||
| headers: { override: 'foobar' }, | ||
| }, | ||
| }); | ||
| }); | ||
| }); | ||
| }); |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Availability time slot timestamps likely wrong type
Medium Severity
AvailabilityTimeSlot.startTimeandendTimeare typed asnumber, but the analogousTimeSlotinterface inmodels/availability.ts(used for calendar availability — a very similar endpoint) types these same fields asstring. The Nylas SDK reference documentation also confirms that availability time slot timestamps are strings. If the scheduling availability endpoint follows the same convention, consumers relying onnumberarithmetic will get unexpected results at runtime since the actual values would be strings.