Skip to content

Commit

Permalink
Adds ability to send supported locale along with a booking
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Apr 16, 2020
1 parent 562543c commit 374ed0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ it('can set the notifications property', async () => {
});
});

it('can set a supported locale property', async () => {
const resource = new Appointment(mockAxios);
const locale = 'fr';

expect(resource.supporting(locale)).toHaveProperty('filters', {
locale,
});
});

it('can set the starting time property', async () => {
const resource = new Appointment(mockAxios);
const start = '2018-01-01 12:00:00';
Expand Down Expand Up @@ -164,6 +173,7 @@ it('can book an appointment with the minimum required parameters', async () => {
service_id: 2,
staff_id: null,
start,
supported_locale: null,
},
relationships: {
attendees: {
Expand Down Expand Up @@ -200,6 +210,7 @@ it('can book an appointment with all available parameters', async () => {
.via(5)
.starting(start)
.method(PHONE_CALL)
.supporting('fr')
.campaign('test campaign')
.content('test content')
.medium('test medium')
Expand Down Expand Up @@ -240,6 +251,7 @@ it('can book an appointment with all available parameters', async () => {
service_id: [2, 3],
staff_id: 4,
start,
supported_locale: 'fr',
},
relationships: {
attendees: {
Expand Down
11 changes: 11 additions & 0 deletions src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Conditional, { ConditionalResource } from './conditional';

export interface AppointmentFilter {
invitation?: number;
locale?: string | null;
location?: number;
matchers?: AppointmentMatcherParameters;
method?: number;
Expand Down Expand Up @@ -42,6 +43,7 @@ export interface AppointmentParameters {
service_id: number | number[] | undefined;
staff_id: number | null;
start: string | undefined;
supported_locale: string | null;
};
relationships: {
attendees: {
Expand Down Expand Up @@ -127,6 +129,8 @@ export interface AppointmentResource extends Resource, ConditionalResource {

starting(start: string): this;

supporting(locale: string | null): this;

via(invitation: number): this;

with(attendees: AttendeeModel | AttendeeModel[]): this;
Expand Down Expand Up @@ -269,6 +273,12 @@ export default class Appointment extends Conditional implements AppointmentResou
return this;
}

public supporting(locale: string | null): this {
this.filters.locale = locale;

return this;
}

public term(term: string): this {
this.utm.term = term;

Expand Down Expand Up @@ -339,6 +349,7 @@ export default class Appointment extends Conditional implements AppointmentResou
service_id: this.filters.services,
staff_id: null,
start: this.filters.start,
supported_locale: this.filters.locale || null,
};

if (this.filters.user) {
Expand Down

0 comments on commit 374ed0b

Please sign in to comment.