coconut-open-api-js
Version:
Coconut Calendar JS Open API SDK
210 lines (209 loc) • 7 kB
TypeScript
import { AxiosInstance } from 'axios';
import { Resource } from '../index';
import { AttendeeModel } from '../models/attendee';
import Conditional, { ConditionalResource } from './conditional';
export interface AppointmentFilter {
invitation?: number;
invite_only_resources?: boolean;
locale?: string | null;
location?: number;
matchers?: AppointmentMatcherParameters;
method?: number;
notifications?: AppointmentNotificationParameters;
recaptcha_token?: string | null;
services?: number | number[];
shortcut?: number;
skip_meeting_link_generation?: boolean;
start?: string;
through?: number;
timezone?: string;
user?: number;
user_category?: number;
users?: number | number[];
workflow?: number;
}
export interface UtmParameters {
campaign?: string;
content?: string;
medium?: string;
source?: string;
term?: string;
}
export interface AppointmentMatcherParameters {
code: string;
id: string | number;
}
export interface AppointmentNotificationParameters {
client?: boolean;
user?: boolean;
}
export interface AppointmentParameters {
data: {
attributes?: {
additional_staff_id?: number | number[];
booked_through?: number;
booking_shortcut_id?: number;
invitation_id: number | null;
invite_only_resources?: number;
location_id: number | undefined;
meeting_method?: number;
recaptcha_token?: string;
service_id: number | number[] | undefined;
staff_category_id?: number;
staff_id: number | null;
start: string | undefined;
supported_locale: string | null;
timezone?: string;
workflow_id?: number | null;
};
relationships: {
attendees: {
data: object[];
};
};
type: string;
};
meta?: {
booker?: number;
notify?: {
client?: boolean;
user?: boolean;
};
skip_meeting_link_generation?: boolean;
utm?: {
campaign?: string;
content?: string;
source?: string;
medium?: string;
term?: string;
};
};
}
export interface RescheduleParameters {
data: {
attributes: {
start: string | undefined;
timezone?: string;
};
id: number;
type: string;
};
meta?: {
notify?: {
client?: boolean;
user?: boolean;
};
skip_meeting_link_generation?: boolean;
};
}
interface AddSingleAttendeeParameter {
attributes: {
email: string;
first_name: string;
last_name: string;
};
type: string;
}
export interface AddAttendeeParameters {
data: AddSingleAttendeeParameter[];
meta?: {
booker?: number;
notify?: {
client?: boolean;
user?: boolean;
};
origin?: number;
};
}
export interface AppointmentResource extends Resource, ConditionalResource {
actingAs(identifier: number): this;
add(appointment: number): Promise<any>;
at(location: number): this;
attendedBy(users: number | number[]): this;
book(): Promise<any>;
by(user: number): this;
cancel(appointment: number, attendee: number, code: string): Promise<any>;
for(services: number | number[]): this;
in(timezone: string): this;
matching(matchers: AppointmentMatcherParameters): this;
method(method: number): this;
notify(notifications: AppointmentNotificationParameters): this;
recaptcha(recaptchaToken: string): this;
reschedule(appointment: number, code: string): Promise<any>;
shortcut(shortcut: number): this;
starting(start: string): this;
supporting(locale: string | null): this;
through(origin: number): this;
via(invitation: number): this;
with(attendees: AttendeeModel | AttendeeModel[]): this;
withInviteOnly(inviteOnlyResources?: boolean): this;
withinUserCategory(userCategory: number): this;
withoutMeetingLink(skipMeetingLinkGeneration?: boolean): this;
workflow(workflow: number): this;
}
export interface Utm {
campaign(campaign: string): this;
content(content: string): this;
medium(medium: string): this;
source(source: string): this;
term(term: string): this;
}
export interface FileUpload {
uploads(uploadedFiles: UploadedFile[]): this;
}
export interface UploadedFile {
key: string;
file: File;
}
export interface AppointmentRelationship {
attendees: AttendeeModel[] | [];
}
export interface AppointmentMeta {
booker?: number;
}
export default class Appointment extends Conditional implements AppointmentResource, Utm, FileUpload {
protected client: AxiosInstance;
protected filters: AppointmentFilter;
protected meta: AppointmentMeta;
protected relationships: AppointmentRelationship;
protected uploadedFiles: UploadedFile[];
protected utm: UtmParameters;
constructor(client: AxiosInstance);
actingAs(identifier: number): this;
add(appointment: number): Promise<any>;
at(location: number): this;
attendedBy(users: number | number[]): this;
book(): Promise<any>;
by(user: number): this;
campaign(campaign: string): this;
cancel(appointment: number, attendee: number, code: string): Promise<any>;
content(content: string): this;
for(services: number | number[]): this;
get(): Promise<any>;
in(timezone: string): this;
matching(matchers: AppointmentMatcherParameters): this;
medium(medium: string): this;
method(method: number): this;
notify(notifications: AppointmentNotificationParameters): this;
recaptcha(recaptchaToken: string): this;
reschedule(appointment: number, code: string): Promise<any>;
shortcut(shortcut: number): this;
starting(start: string): this;
source(source: string): this;
supporting(locale: string | null): this;
term(term: string): this;
through(origin: number): this;
uploads(uploadedFiles: UploadedFile[]): this;
via(invitation: number): this;
with(attendees: AttendeeModel | AttendeeModel[]): this;
withInviteOnly(inviteOnlyResources?: boolean): this;
withinUserCategory(userCategory: number): this;
withoutMeetingLink(skipMeetingLinkGeneration?: boolean): this;
workflow(workflow: number): this;
protected addParams(): AddAttendeeParameters;
protected hasUtm(): boolean;
protected params(): AppointmentParameters | object;
protected rescheduleParams(appointment: number): RescheduleParameters | object;
protected transformAttendees(): AddSingleAttendeeParameter[];
}
export {};