diff --git a/src/resources/wait-list.test.ts b/src/resources/wait-list.test.ts index bc56131..af89d42 100644 --- a/src/resources/wait-list.test.ts +++ b/src/resources/wait-list.test.ts @@ -1,11 +1,12 @@ import mockAxios from 'axios'; +import Attendee from '../models/attendee'; import WaitList from './wait-list'; it('will set location filter using a number', async () => { const resource = new WaitList(mockAxios); - expect(resource.at(1)).toHaveProperty('filters', { + expect(resource.at(1)).toHaveProperty('relationships', { location: 1, }); }); @@ -13,7 +14,7 @@ it('will set location filter using a number', async () => { it('will set location filter using a numeric string', async () => { const resource = new WaitList(mockAxios); - expect(resource.at('1')).toHaveProperty('filters', { + expect(resource.at('1')).toHaveProperty('relationships', { location: '1', }); }); @@ -21,7 +22,7 @@ it('will set location filter using a numeric string', async () => { it('will set service filter using a number', async () => { const resource = new WaitList(mockAxios); - expect(resource.seeking(1)).toHaveProperty('filters', { + expect(resource.seeking(1)).toHaveProperty('relationships', { service: 1, }); }); @@ -29,7 +30,7 @@ it('will set service filter using a number', async () => { it('will set service filter using a numeric string', async () => { const resource = new WaitList(mockAxios); - expect(resource.seeking('1')).toHaveProperty('filters', { + expect(resource.seeking('1')).toHaveProperty('relationships', { service: '1', }); }); @@ -37,7 +38,7 @@ it('will set service filter using a numeric string', async () => { it('will set user filter using a number', async () => { const resource = new WaitList(mockAxios); - expect(resource.with(1)).toHaveProperty('filters', { + expect(resource.with(1)).toHaveProperty('relationships', { user: 1, }); }); @@ -45,7 +46,7 @@ it('will set user filter using a number', async () => { it('will set user filter using a numeric string', async () => { const resource = new WaitList(mockAxios); - expect(resource.with('1')).toHaveProperty('filters', { + expect(resource.with('1')).toHaveProperty('relationships', { user: '1', }); }); @@ -74,6 +75,15 @@ it('will set the includes parameter using a comma separated string', async () => }); }); +it('can set an attendee for the wait list request', async () => { + const resource = new WaitList(mockAxios); + const attendee = new Attendee; + + expect(resource.for(attendee)).toHaveProperty('relationships', { + attendee, + }); +}); + it('can create a new wait list request for a given client using only required attributes', async () => { // }); diff --git a/src/resources/wait-list.ts b/src/resources/wait-list.ts index 6cc995a..25bdd8d 100644 --- a/src/resources/wait-list.ts +++ b/src/resources/wait-list.ts @@ -1,19 +1,19 @@ import { AxiosInstance } from 'axios'; -import { WaitListFilter } from '../types/filters'; import { AttendeeModel, PreferenceModel } from '../types/models'; import { IncludableParameters, WaitListUrlParameters } from '../types/parameters'; +import { WaitListRelationship } from '../types/relationships'; import { WaitListResource } from '../types/resources'; export default class WaitList implements WaitListResource { protected client: AxiosInstance; - protected filters: WaitListFilter; protected parameters: WaitListUrlParameters; + protected relationships: WaitListRelationship; constructor(client: AxiosInstance) { this.client = client; - this.filters = {}; this.parameters = {}; + this.relationships = {}; } public async add(): Promise { @@ -21,7 +21,7 @@ export default class WaitList implements WaitListResource { } public at(location: number | string): this { - this.filters.location = location; + this.relationships.location = location; return this; } @@ -44,6 +44,8 @@ export default class WaitList implements WaitListResource { } public for(attendee: AttendeeModel): this { + this.relationships.attendee = attendee; + return this; } @@ -57,6 +59,10 @@ export default class WaitList implements WaitListResource { return this; } + public provided(notes: string): this { + return this; + } + public async remove(list: number | string): Promise { const { client } = this.parameters; @@ -64,7 +70,7 @@ export default class WaitList implements WaitListResource { } public seeking(service: number | string): this { - this.filters.service = service; + this.relationships.service = service; return this; } @@ -74,7 +80,7 @@ export default class WaitList implements WaitListResource { } public with(user: number | string): this { - this.filters.user = user; + this.relationships.user = user; return this; } diff --git a/src/types/filters.d.ts b/src/types/filters.d.ts index 1fd58d6..82d4f90 100644 --- a/src/types/filters.d.ts +++ b/src/types/filters.d.ts @@ -46,9 +46,3 @@ export interface UserFilter { services?: number | number[] | string | string[]; location?: number | string; } - -export interface WaitListFilter { - location?: number | string; - service?: number | string; - user?: number | string; -} diff --git a/src/types/relationships.d.ts b/src/types/relationships.d.ts index 8825853..9656970 100644 --- a/src/types/relationships.d.ts +++ b/src/types/relationships.d.ts @@ -3,3 +3,10 @@ import { AttendeeModel } from './models'; export interface AppointmentRelationship { attendees?: AttendeeModel[] | [] } + +export interface WaitListRelationship { + attendee?: AttendeeModel; + location?: number | string; + service?: number | string; + user?: number | string; +} diff --git a/src/types/resources.d.ts b/src/types/resources.d.ts index e7989ce..6b90e0b 100644 --- a/src/types/resources.d.ts +++ b/src/types/resources.d.ts @@ -90,6 +90,8 @@ export interface WaitListResource { prefers(preferences: PreferenceModel | PreferenceModel[]): this; + provided(notes: string): this; + remove(list: number | string): Promise; seeking(service: number | string): this;