@microfox/fillout
Version:
TypeScript SDK for the Fillout REST API.
133 lines (130 loc) • 4.26 kB
TypeScript
type QuestionType = 'Address' | 'AudioRecording' | 'Calcom' | 'Calendly' | 'Captcha' | 'Checkbox' | 'Checkboxes' | 'ColorPicker' | 'CurrencyInput' | 'DatePicker' | 'DateRange' | 'DateTimePicker' | 'Dropdown' | 'EmailInput' | 'FileUpload' | 'ImagePicker' | 'LocationCoordinates' | 'LongAnswer' | 'Matrix' | 'MultiSelect' | 'MultipleChoice' | 'NumberInput' | 'OpinionScale' | 'Password' | 'Payment' | 'PhoneNumber' | 'Ranking' | 'RecordPicker' | 'ShortAnswer' | 'Signature' | 'Slider' | 'StarRating' | 'Subform' | 'SubmissionPicker' | 'Switch' | 'Table' | 'TimePicker' | 'URLInput';
type CalculationType = 'number' | 'text' | 'duration';
interface Question {
id: string;
name: string;
type: QuestionType;
value?: any;
}
interface Calculation {
id: string;
name: string;
type: CalculationType;
value?: string | number;
}
interface URLParameter {
id: string;
name: string;
value?: string;
}
interface SchedulingValue {
fullName: string;
email: string;
timezone: string;
eventStartTime: string;
eventEndTime: string;
eventId?: string;
eventUrl?: string;
rescheduleOrCancelUrl?: string;
userId?: number;
scheduledUserEmail?: string;
meetingNotes?: string;
}
interface Scheduling {
id: string;
name: string;
value?: SchedulingValue;
}
interface PaymentValue {
stripeCustomerId?: string;
stripeCustomerUrl?: string;
stripePaymentUrl?: string;
totalAmount?: number;
currency?: string;
email?: string;
discountCode?: string;
status?: string;
paymentId: string;
stripeSubscriptionId?: string;
}
interface Payment {
id: string;
name: string;
value?: PaymentValue;
}
interface Login {
email: string;
}
interface Quiz {
enabled: boolean;
score?: number;
maxScore?: number;
}
interface FormMetadata {
id: string;
name: string;
questions: Question[];
calculations: Calculation[];
urlParameters: URLParameter[];
scheduling?: Scheduling[];
payments?: Payment[];
quiz?: Quiz;
}
interface Submission {
questions: Question[];
calculations: Calculation[];
urlParameters: URLParameter[];
quiz?: Quiz;
submissionId: string;
submissionTime: string;
scheduling?: Scheduling[];
payments?: Payment[];
login?: Login;
lastUpdatedAt?: string;
}
interface SubmissionResponse {
responses: Submission[];
totalResponses: number;
pageCount: number;
}
interface SingleSubmissionResponse {
submission: Submission;
}
interface WebhookCreateResponse {
id: number;
}
interface CreateSubmissionsResponse {
submissions: Submission[];
}
interface Form {
name: string;
formId: string;
}
interface FilloutSDKOptions {
apiKey?: string;
}
declare class FilloutSDK {
private apiKey;
constructor(options?: FilloutSDKOptions);
private request;
getForms(): Promise<Form[]>;
getFormMetadata(formId: string): Promise<FormMetadata>;
getAllSubmissions(formId: string, options?: {
limit?: number;
afterDate?: string;
beforeDate?: string;
offset?: number;
status?: 'in_progress';
includeEditLink?: boolean;
includePreview?: boolean;
sort?: 'asc' | 'desc';
search?: string;
}): Promise<SubmissionResponse>;
getSubmissionById(formId: string, submissionId: string, includeEditLink?: boolean): Promise<SingleSubmissionResponse>;
deleteSubmissionById(formId: string, submissionId: string): Promise<void>;
createWebhook(formId: string, url: string): Promise<WebhookCreateResponse>;
removeWebhook(webhookId: number): Promise<void>;
createSubmissions(formId: string, submissions: Submission[]): Promise<CreateSubmissionsResponse>;
}
declare function createFilloutSDK(options?: FilloutSDKOptions): FilloutSDK;
export { type Calculation, type CalculationType, type CreateSubmissionsResponse, FilloutSDK, type FilloutSDKOptions, type Form, type FormMetadata, type Login, type Payment, type PaymentValue, type Question, type QuestionType, type Quiz, type Scheduling, type SchedulingValue, type SingleSubmissionResponse, type Submission, type SubmissionResponse, type URLParameter, type WebhookCreateResponse, createFilloutSDK };