@foxford/sdk 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js.flow ADDED
@@ -0,0 +1,1005 @@
1
+ // @flow
2
+ import {
3
+ ApiInstance,
4
+ type ApiConfig,
5
+ type CaptchaConfig,
6
+ ApiResponse,
7
+ ApiService,
8
+ CaptchaService,
9
+ } from "@foxford/services";
10
+ declare export {
11
+ ApiAdapter,
12
+ ApiBasicCredentials,
13
+ ApiConfig,
14
+ ApiError,
15
+ ApiErrorExtended,
16
+ ApiInstance,
17
+ ApiInterceptorManager,
18
+ ApiMethod,
19
+ ApiPromise,
20
+ ApiProxyConfig,
21
+ ApiRequestConfig,
22
+ ApiRequestConfigExtended,
23
+ ApiResponse,
24
+ ApiResponseType,
25
+ ApiService,
26
+ ApiServiceInterface,
27
+ ApiStatic,
28
+ ApiTransformer,
29
+ Cancel,
30
+ CancelStatic,
31
+ CancelToken,
32
+ CancelTokenSource,
33
+ CancelTokenStatic,
34
+ Canceler,
35
+ CaptchaError,
36
+ CaptchaService,
37
+ RequestPlugin,
38
+ RequestPluginInterface,
39
+ ResponseError,
40
+ ResponseFailPlugin,
41
+ ResponseSuccessPlugin,
42
+ ResponseSuccessPluginInterface,
43
+ } from "@foxford/services";
44
+ import {
45
+ type CartItemResourceType,
46
+ type BusinessUnitAbbreviation,
47
+ type Course,
48
+ } from "@foxford/types";
49
+ declare type Widget = {
50
+ name:
51
+ | "menu"
52
+ | "reviews"
53
+ | "featuredCoaches"
54
+ | "coachEnrollment"
55
+ | "shortForm"
56
+ | "userTypePrompt"
57
+ | "teachersSlider"
58
+ | "externshipFormats",
59
+ options: { [key: string]: any, ... },
60
+ container?: HTMLElement,
61
+ ...
62
+ };
63
+ declare type WidgetsInitConfig = {
64
+ version?: "latest" | string,
65
+ locale?: "ru",
66
+ ...
67
+ };
68
+ declare type FoxfordWidgetsConfig = {
69
+ analyticContext?: {
70
+ prefix: string,
71
+ module: string,
72
+ payload?: { [key: string]: any, ... },
73
+ ...
74
+ },
75
+ rootColors?: boolean,
76
+ loadFonts?: boolean,
77
+ widgets: Array<Widget>,
78
+ ...
79
+ };
80
+ declare type WidgetsConfig = {
81
+ analyticContext?: {
82
+ prefix: string,
83
+ module: string,
84
+ payload?: { [key: any]: any, ... },
85
+ ...
86
+ },
87
+ rootColors?: boolean,
88
+ loadFonts?: boolean,
89
+ widgets: Array<Widget>,
90
+ ...
91
+ } & WidgetsInitConfig;
92
+ declare class Widgets {
93
+ static ENTRY: string[];
94
+ static DEFAULT_CONFIG: WidgetsInitConfig;
95
+ constructor(config: WidgetsInitConfig | void, apiInstance: ApiInstance): this;
96
+ create(config: WidgetsConfig): Promise<void>;
97
+ update(name: string, config: Widget): Promise<void>;
98
+ static appendScript(src: string): Promise<mixed>;
99
+ }
100
+ declare module "global" {
101
+ declare interface Window {
102
+ /**
103
+ * Реферер Foxford для отслеживания источников трафика
104
+ */
105
+ __fox_referrer__?: string;
106
+
107
+ /**
108
+ * Google Tag Manager data layer для отправки событий аналитики
109
+ * @see https ://developers.google.com/tag-manager/devguide
110
+ */
111
+ dataLayer?: Array<{ [key: string]: mixed, ... }>;
112
+ antibotInitialized?: boolean;
113
+ onCaptureReady?: () => void;
114
+ Foxford?: {
115
+ Widgets?: {
116
+ create(config: FoxfordWidgetsConfig): void,
117
+ update(name: string, config: Widget): void,
118
+ ...
119
+ },
120
+ ...
121
+ };
122
+ }
123
+ }
124
+
125
+ declare type PupilRole =
126
+ | "11 класс"
127
+ | "10 класс"
128
+ | "9 класс"
129
+ | "8 класс"
130
+ | "7 класс"
131
+ | "6 класс"
132
+ | "5 класс"
133
+ | "4 класс"
134
+ | "3 класс"
135
+ | "2 класс"
136
+ | "1 класс";
137
+ declare type UserRole =
138
+ | "Ученик"
139
+ | "Репетитор"
140
+ | "Учитель"
141
+ | "Родитель"
142
+ | "Выпускник"
143
+ | "Дошкольник"
144
+ | PupilRole;
145
+ declare interface UserDTO {
146
+ id: null | number;
147
+ email: string;
148
+ firstName: string;
149
+ middleName: string;
150
+ lastName: string;
151
+ fullName: string;
152
+ shortName: string;
153
+ createdAt: null | string;
154
+ timezone: null | string;
155
+ locale: null | string;
156
+ grade: {
157
+ id: null | number,
158
+ index: null | number,
159
+ name: null | string,
160
+ translit: null | string,
161
+ ...
162
+ };
163
+ phone: null | string;
164
+ avatarUrl: string;
165
+ isParent: boolean;
166
+ isGraduated: boolean;
167
+ gradeChecked: boolean;
168
+ type: null | "pupil" | "agent";
169
+ isCoach: boolean;
170
+ isMiniGroupTeacher: boolean;
171
+ isExternshipCoach: boolean;
172
+ isAgent: boolean;
173
+ methodist: boolean;
174
+ address: {
175
+ index: null | string,
176
+ countryId: null | number,
177
+ countryName: null | string,
178
+ regionId: null | number,
179
+ regionName: null | string,
180
+ cityId: null | number,
181
+ cityName: null | string,
182
+ street: null | string,
183
+ house: null | string,
184
+ building: null | string,
185
+ room: null | string,
186
+ ...
187
+ } | null;
188
+ socialNets: Array<{
189
+ provider:
190
+ | "facebook"
191
+ | "google_oauth2"
192
+ | "mailru_oauth2"
193
+ | "odnoklassniki"
194
+ | "vkontakte"
195
+ | "yandex",
196
+ uid: number,
197
+ ...
198
+ }>;
199
+ skype: null | string;
200
+ settings?: {
201
+ calendarUserExperienceFeedback?: boolean,
202
+ elementaryDashboardUserExperienceFeedback?: boolean,
203
+ homeSchoolFamilyEducationGuideHidden?: boolean,
204
+ pageBonusesVisited?: boolean,
205
+ pagePaymentsInfoVisited?: boolean,
206
+ pageSocializationLandingVisited?: boolean,
207
+ pageSocializationVisited?: boolean,
208
+ ...
209
+ };
210
+ bonus: {
211
+ giftAmount: number,
212
+ realMoneyAmount: number,
213
+ ...
214
+ };
215
+ bonusAmount: number;
216
+ hasActivePurchases: boolean;
217
+ hasAttemptsSolveExamRehearsals: boolean;
218
+ hasBookmarks: boolean;
219
+ tags: null | string[];
220
+ cartTemplateId: null | number;
221
+ cartItemsCount: number;
222
+ onboardingFinished: boolean;
223
+ onboardingFinishedAt: null | string;
224
+ emailConfirmed: boolean;
225
+ phoneConfirmed: boolean;
226
+ fakeEmail: boolean;
227
+ fakeUser: boolean;
228
+ profileEnriched: boolean;
229
+ recapUuid: string | null;
230
+ disciplineIds: number[];
231
+ privacy: {
232
+ publicProfile: boolean,
233
+ ...
234
+ };
235
+ parentPhone: null | string;
236
+ parentPhoneConfirmed: boolean;
237
+ isCustomer: null | boolean;
238
+ hasAccessToMultiDaysStreaks: boolean;
239
+ isElementaryPupil: boolean;
240
+ webSocketNotificationsJwt: null | string;
241
+ hasAccessToAttestationSheets: boolean;
242
+ externshipUser: boolean;
243
+ hasPurchasedExternshipContracts: boolean;
244
+ hasExternshipAttestationAccess: boolean;
245
+ appearanceId?: null | number;
246
+ hasUnseenRoomFeatures?: boolean;
247
+ unconfirmedEmail?: null | string;
248
+ socializationProfile: {
249
+ id: number,
250
+ state: "active" | "draft" | "banned",
251
+ ...
252
+ } | null;
253
+ freeAccessFinishesAt: null | string;
254
+ purchaseAnyExternshipContracts: boolean;
255
+ }
256
+ declare class User {
257
+ constructor(): this;
258
+ id: $PropertyType<UserDTO, "id">;
259
+ email: $PropertyType<UserDTO, "email">;
260
+ firstName: $PropertyType<UserDTO, "firstName">;
261
+ middleName: $PropertyType<UserDTO, "middleName">;
262
+ lastName: $PropertyType<UserDTO, "lastName">;
263
+ fullName: $PropertyType<UserDTO, "fullName">;
264
+ shortName: $PropertyType<UserDTO, "shortName">;
265
+ createdAt: $PropertyType<UserDTO, "createdAt">;
266
+ timezone: $PropertyType<UserDTO, "timezone">;
267
+ locale: $PropertyType<UserDTO, "locale">;
268
+ grade: $PropertyType<UserDTO, "grade">;
269
+ phone: $PropertyType<UserDTO, "phone">;
270
+ avatarUrl: $PropertyType<UserDTO, "avatarUrl">;
271
+ isParent: $PropertyType<UserDTO, "isParent">;
272
+ isGraduated: $PropertyType<UserDTO, "isGraduated">;
273
+ gradeChecked: $PropertyType<UserDTO, "gradeChecked">;
274
+ type: $PropertyType<UserDTO, "type">;
275
+ isCoach: $PropertyType<UserDTO, "isCoach">;
276
+ isMiniGroupTeacher: $PropertyType<UserDTO, "isMiniGroupTeacher">;
277
+ isExternshipCoach: $PropertyType<UserDTO, "isExternshipCoach">;
278
+ isAgent: $PropertyType<UserDTO, "isAgent">;
279
+ methodist: $PropertyType<UserDTO, "methodist">;
280
+ address: $PropertyType<UserDTO, "address">;
281
+ socialNets: $PropertyType<UserDTO, "socialNets">;
282
+ skype: $PropertyType<UserDTO, "skype">;
283
+ settings: $PropertyType<UserDTO, "settings">;
284
+ bonus: $PropertyType<UserDTO, "bonus">;
285
+ bonusAmount: $PropertyType<UserDTO, "bonusAmount">;
286
+ hasActivePurchases: $PropertyType<UserDTO, "hasActivePurchases">;
287
+ hasAttemptsSolveExamRehearsals: $PropertyType<
288
+ UserDTO,
289
+ "hasAttemptsSolveExamRehearsals"
290
+ >;
291
+ hasBookmarks: $PropertyType<UserDTO, "hasBookmarks">;
292
+ tags: $PropertyType<UserDTO, "tags">;
293
+ cartTemplateId: $PropertyType<UserDTO, "cartTemplateId">;
294
+ cartItemsCount: $PropertyType<UserDTO, "cartItemsCount">;
295
+ onboardingFinished: $PropertyType<UserDTO, "onboardingFinished">;
296
+ onboardingFinishedAt: $PropertyType<UserDTO, "onboardingFinishedAt">;
297
+ emailConfirmed: $PropertyType<UserDTO, "emailConfirmed">;
298
+ phoneConfirmed: $PropertyType<UserDTO, "phoneConfirmed">;
299
+ fakeEmail: $PropertyType<UserDTO, "fakeEmail">;
300
+ fakeUser: $PropertyType<UserDTO, "fakeUser">;
301
+ profileEnriched: $PropertyType<UserDTO, "profileEnriched">;
302
+ recapUuid: $PropertyType<UserDTO, "recapUuid">;
303
+ disciplineIds: $PropertyType<UserDTO, "disciplineIds">;
304
+ privacy: $PropertyType<UserDTO, "privacy">;
305
+ parentPhone: $PropertyType<UserDTO, "parentPhone">;
306
+ parentPhoneConfirmed: $PropertyType<UserDTO, "parentPhoneConfirmed">;
307
+ isCustomer: $PropertyType<UserDTO, "isCustomer">;
308
+ hasAccessToMultiDaysStreaks: $PropertyType<
309
+ UserDTO,
310
+ "hasAccessToMultiDaysStreaks"
311
+ >;
312
+ isElementaryPupil: $PropertyType<UserDTO, "isElementaryPupil">;
313
+ webSocketNotificationsJwt: $PropertyType<
314
+ UserDTO,
315
+ "webSocketNotificationsJwt"
316
+ >;
317
+ hasAccessToAttestationSheets: $PropertyType<
318
+ UserDTO,
319
+ "hasAccessToAttestationSheets"
320
+ >;
321
+ externshipUser: $PropertyType<UserDTO, "externshipUser">;
322
+ hasPurchasedExternshipContracts: $PropertyType<
323
+ UserDTO,
324
+ "hasPurchasedExternshipContracts"
325
+ >;
326
+ hasExternshipAttestationAccess: $PropertyType<
327
+ UserDTO,
328
+ "hasExternshipAttestationAccess"
329
+ >;
330
+ socializationProfile: $PropertyType<UserDTO, "socializationProfile">;
331
+ freeAccessFinishesAt: $PropertyType<UserDTO, "freeAccessFinishesAt">;
332
+ hasUnseenRoomFeatures: $PropertyType<UserDTO, "hasUnseenRoomFeatures">;
333
+ purchaseAnyExternshipContracts: $PropertyType<
334
+ UserDTO,
335
+ "purchaseAnyExternshipContracts"
336
+ >;
337
+ static createDefault(): User;
338
+ static fromApi(input: mixed): User;
339
+ isDefaultUser(): boolean;
340
+ isLoggedIn(): boolean;
341
+
342
+ /**
343
+ * Возвращает тектовое представление роли / класса пользователя
344
+ * @returns {UserRole}
345
+ */
346
+ getPupilRole(): UserRole;
347
+
348
+ /**
349
+ * Возвращает роль пользователя
350
+ * @returns {UserRole} роль как строка
351
+ */
352
+ getRole: () => UserRole;
353
+
354
+ /**
355
+ * Возвращает фамилию и инициалы юзера
356
+ * @param {User} user
357
+ * @return {string} 'Пупкин В.'
358
+ */
359
+ getInitials: () => string;
360
+ toJson(): string;
361
+ }
362
+ declare type AppOptions = {
363
+ activePromoBanner?: number,
364
+ captcha?: {
365
+ provider: "recaptcha",
366
+ siteKey: string,
367
+ ...
368
+ },
369
+ contactPhoneNumber: null | string,
370
+ currency: {
371
+ code: "RUB",
372
+ exchangeRate: number,
373
+ ...
374
+ },
375
+ currentSchoolYear: null | {
376
+ current: boolean,
377
+ id: number,
378
+ startsFrom: number,
379
+ translit: string,
380
+ ...
381
+ },
382
+ experiments?: Array<{
383
+ name: string,
384
+ value: string,
385
+ ...
386
+ }>,
387
+ externalReviews?: {
388
+ pageAvailable: boolean,
389
+ ...
390
+ },
391
+ featureFlags?: Array<string>,
392
+ feedbackThemes?: {
393
+ foxford: {
394
+ tasks: number,
395
+ ...
396
+ },
397
+ ...
398
+ },
399
+ flash: {
400
+ alert?: string,
401
+ notice?: string,
402
+ warning?: string,
403
+ ...
404
+ },
405
+ nextSchoolYearProductsExists: boolean,
406
+ paymentMethods?: {
407
+ another?: string,
408
+ cardPayment?: "Yandex",
409
+ creditExternshipPayment?: "TinkoffCredit",
410
+ creditPayment?: "Sberbank" | "Yandex",
411
+ internationalCardPayment?: "Payture" | "Payanyway",
412
+ splitPayment?: "YandexPay",
413
+ platiChastyamiPayment?: "PlatiChastyami",
414
+ sberPayPayment?: "SberbankEcommerce",
415
+ sberSpasiboPayment?: "SberbankEcommerce",
416
+ sbpPayment?: "Yandex",
417
+ ...
418
+ },
419
+ phoneConfirmationType:
420
+ | "sms"
421
+ | "phone_call"
422
+ | "cascade_by_call"
423
+ | "telegram_cascade",
424
+ popupAlerts?: number[],
425
+ prerender?: boolean,
426
+ requestMetaTags?: boolean,
427
+ rootMenuItems: Array<{
428
+ contextOfUse?: "externat" | "media" | "portal",
429
+ id: number,
430
+ title: string,
431
+ url: string,
432
+ ...
433
+ }>,
434
+ sentry?: {
435
+ dsn: string,
436
+ ...
437
+ },
438
+ showPromoBanners: string[],
439
+ user?: UserDTO,
440
+ userIdentity?: string,
441
+ webSocketNotifications?: {
442
+ clientConnection: null | Array<{
443
+ endpoint: string,
444
+ transport:
445
+ | "websocket"
446
+ | "http_stream"
447
+ | "sse"
448
+ | "sockjs"
449
+ | "webtransport",
450
+ ...
451
+ }>,
452
+ token: string,
453
+ ...
454
+ },
455
+ contacts: {
456
+ email: null | string,
457
+ phone: null | string,
458
+ telegram: null | string,
459
+ vkontakte: null | string,
460
+ whatsapp: null | string,
461
+ ...
462
+ },
463
+ ...
464
+ };
465
+ declare class AppOptionsService {
466
+ constructor(apiInstance: ApiInstance, eventName: string): this;
467
+ getCurrentAppOptions(): Promise<AppOptions>;
468
+
469
+ /**
470
+ * Get app options data from api
471
+ */
472
+ getAppOptions(): Promise<AppOptions>;
473
+ }
474
+ declare interface FoxfordAntibotConfig {
475
+ antibotFrameSrc?: string;
476
+ antibotOnload?: (e: Event) => void;
477
+ antibotOnerror?: () => void;
478
+ debug?: boolean;
479
+ }
480
+ declare class FoxfordAntibot {
481
+ static FOXFORD_ANTIBOT_URL: string;
482
+ static DEFAULT_CONFIG: {
483
+ antibotFrameSrc: string,
484
+ ...
485
+ };
486
+ static FRAME_CLASSNAME: string;
487
+ constructor(config?: FoxfordAntibotConfig): this;
488
+ createAntibotFrame: (params: {
489
+ src: string,
490
+ onload?: (_e: Event) => void,
491
+ onerror?: () => void,
492
+ ...
493
+ }) => void;
494
+ }
495
+ declare type ProductTypeItem = {
496
+ type: string,
497
+ id: number,
498
+ description: string,
499
+ title: string,
500
+ discipline: {
501
+ id: number,
502
+ name: string,
503
+ ...
504
+ },
505
+ teacher: {
506
+ id: number,
507
+ long_name: string,
508
+ description: string,
509
+ experience: number,
510
+ photo_url: string,
511
+ photo_large_url: string,
512
+ ...
513
+ },
514
+ levels: Array<{
515
+ id: number,
516
+ name: string,
517
+ ...
518
+ }>,
519
+ ...
520
+ };
521
+ declare type ProductPack = {
522
+ name: string,
523
+ description: string,
524
+ meta_title: string,
525
+ meta_description: string,
526
+ published: true,
527
+ content_description: string,
528
+ disciplines_scope: string,
529
+ guaranteed_admission: true,
530
+ grade_names: string,
531
+ is_purchased: false,
532
+ learning_flow: {
533
+ title: string,
534
+ steps: Array<{
535
+ header: string,
536
+ description: string,
537
+ ...
538
+ }>,
539
+ ...
540
+ },
541
+ offers: {
542
+ intro: string,
543
+ items: Array<{
544
+ title: string,
545
+ description: string,
546
+ ...
547
+ }>,
548
+ ...
549
+ },
550
+ price_block: {
551
+ price: number,
552
+ initial_price: number,
553
+ title: string,
554
+ description: string,
555
+ points: Array<string>,
556
+ price_per_month: number,
557
+ initial_price_per_month: number,
558
+ ...
559
+ },
560
+ product_pack_items: Array<ProductTypeItem>,
561
+ faq_items: Array<{
562
+ question: string,
563
+ answer: string,
564
+ ...
565
+ }>,
566
+ landing_image_urls: Array<string>,
567
+ ...
568
+ };
569
+ declare interface CartItemDTO {
570
+ cart_item_type: CartItemResourceType;
571
+ resource_id: number;
572
+ }
573
+ declare type FoxfordConfig = {
574
+ host?: string,
575
+
576
+ /**
577
+ * @deprecated
578
+ */
579
+ widgetsVersion?: "latest" | string,
580
+ antibot?: boolean,
581
+ antibotConfig?: FoxfordAntibotConfig,
582
+ api?: ApiConfig,
583
+ captchaConfig?: () => CaptchaConfig,
584
+
585
+ /**
586
+ * @deprecated Не используйте инициализацию виджетов через SDK
587
+ */
588
+ widgetsConfig?: WidgetsInitConfig,
589
+ ...
590
+ };
591
+ declare type Reasons =
592
+ | "additional_education_free_period_started"
593
+ | "announcement_clicked"
594
+ | "catalog_filtered"
595
+ | "coach_intro_lesson_scheduled"
596
+ | "coach_landing_visited"
597
+ | "course_conspect_visited"
598
+ | "course_landing_visited"
599
+ | "event_scheduled"
600
+ | "event_visited"
601
+ | "exam_rehearsal_page_visited"
602
+ | "exam_rehearsal_passed"
603
+ | "externship_contract_draft_created"
604
+ | "externship_demo_access"
605
+ | "externship_iep_selected"
606
+ | "externship_intendance_expressed"
607
+ | "interactive_training_course_visited"
608
+ | "externship_landing_visited"
609
+ | "externship_lead_request"
610
+ | "mini_group_landing_visited"
611
+ | "olympiad_page_visited"
612
+ | "onboarding"
613
+ | "onboarding_finished"
614
+ | "product_pack_landing_visited"
615
+ | "promos_coach_recommendation_clicked"
616
+ | "promos_course_recommendation_clicked"
617
+ | "promos_results_filtered"
618
+ | "subscription_landing_visited"
619
+ | "teacher_course_visited"
620
+ | "training_page_visited"
621
+ | "training_passed"
622
+ | "wiki_visited"
623
+ | "project_landing_cta_clicked";
624
+ declare type ProductFormats =
625
+ | "coach_course"
626
+ | "course"
627
+ | "event"
628
+ | "exam_rehearsal"
629
+ | "externship"
630
+ | "game"
631
+ | "interactive_trainings"
632
+ | "mini_group"
633
+ | "olympiad"
634
+ | "product_pack"
635
+ | "teacher_course"
636
+ | "trainings";
637
+ declare type UserInterests = {
638
+ businessUnitAbbrs?: BusinessUnitAbbreviation[] | null,
639
+ disciplineId?: number | number[] | null,
640
+ gradeId?: number | number[] | null,
641
+ levelId?: number | number[] | null,
642
+ productId?: number | null,
643
+ productFormat?: ProductFormats | null,
644
+ reason?: Reasons | null,
645
+ ...
646
+ };
647
+ declare interface CommunicationSubscriptions {
648
+ subscriptionNews?: boolean;
649
+ subscriptionMaterials?: boolean;
650
+ subscriptionEvents?: boolean;
651
+ subscriptionPromos?: boolean;
652
+ subscriptionReminders?: boolean;
653
+ subscriptionMedia?: boolean;
654
+ subscriptionExternship?: boolean;
655
+ subscriptionExternal?: boolean;
656
+ }
657
+ declare interface LoginByPhoneParams {
658
+ onEmailRequest: (phoneCheckResponse: {
659
+ email?: string,
660
+ fakeEmail?: boolean,
661
+ state: "new" | "confirmed" | "not_confirmed",
662
+ ...
663
+ }) => Promise<string>;
664
+ onCodeRequest: () => Promise<string>;
665
+ onNameRequest: () => Promise<{
666
+ first_name: string,
667
+ last_name: string,
668
+ ...
669
+ }>;
670
+ onConfirmationCodeResponse: (confirmationCodeResponse: {
671
+ nextDeliveryAt: string,
672
+ ...
673
+ }) => void;
674
+ onConfirmationCodeError: (error: Error) => void;
675
+ }
676
+ declare interface LoginOrRegistrationResponse {
677
+ redirectUrl?: string;
678
+ registered?: boolean;
679
+ type?: string;
680
+ }
681
+ declare class CartService {
682
+ constructor(apiInstance: ApiInstance): this;
683
+ createCartItem(id: number, type: CartItemResourceType): CartItemDTO;
684
+ addCartItemToCart(cartItem: CartItemDTO): Promise<mixed>;
685
+ }
686
+ declare class CourseService {
687
+ constructor(apiInstance: ApiInstance): this;
688
+ getCourse(id: number): Promise<Course>;
689
+ enrollCourse(id: number): Promise<void>;
690
+ }
691
+ declare type LeadRequestPayload = {
692
+ email?: string | null,
693
+ phone?: string | null,
694
+ school_id?: number | null,
695
+ contract_id?: number | null,
696
+ referrer?: string | null,
697
+ subscription_external?: "true" | "false" | null,
698
+ user_type?: "pupil" | "agent" | "parent" | null,
699
+ agent_id?: number | null,
700
+ agreement?: boolean | null,
701
+ code?: string | null,
702
+ communication_method?: "phone" | "email" | "whatsapp" | null,
703
+ course_name?: string | null,
704
+ discipline_id?: number | null,
705
+ free_intro_lesson_group_id?: number | null,
706
+ free_intro_lesson_mini_group_id?: number | null,
707
+ grade_id?: number | null,
708
+ group_template_ids?: Array<number> | null,
709
+ id?: string | null,
710
+ interests?: Array<string> | null,
711
+ level_id?: any | null,
712
+ name?: string | null,
713
+ parent_phone?: string | null,
714
+ phone_number?: string | null,
715
+ placement?: string | null,
716
+ product_id?: number | null,
717
+ product_pack_id?: string | null,
718
+ product_type?: any | null,
719
+ source?: string | null,
720
+ school_entry_year?: number | null,
721
+ total_balance?: number | null,
722
+ user_id?: number | null,
723
+ user_phone_number?: string | null,
724
+ utm_campaign?: string | null,
725
+ utm_medium?: string | null,
726
+ utm_source?: string | null,
727
+ utm_term?: string | null,
728
+ ...
729
+ };
730
+ declare type LeadRequest = {
731
+ type: $Values<typeof LeadRequestType>,
732
+ agreement?: boolean,
733
+ context: "rep_change_tariff" | "split_balance" | "demo_order" | string,
734
+ ...
735
+ } & LeadRequestPayload;
736
+ declare interface LeadRequestApiResponse {
737
+ id: string;
738
+ newUser: boolean;
739
+ }
740
+ declare interface LeadRequestResponse {
741
+ leadRequest: LeadRequest;
742
+ response: LeadRequestApiResponse;
743
+ }
744
+ declare var LeadRequestType: {|
745
+ +Algorithmics: "LeadRequests::Algorithmics", // "LeadRequests::Algorithmics"
746
+ +External: "LeadRequests::External", // "LeadRequests::External"
747
+ +Callback: "LeadRequests::Callback", // "LeadRequests::Callback"
748
+ +Basic: "LeadRequests::Basic", // "LeadRequests::Basic"
749
+ +Main: "LeadRequests::Main", // "LeadRequests::Main"
750
+ +Coach: "LeadRequests::Coach", // "LeadRequests::Coach"
751
+ +Media: "LeadRequests::Media", // "LeadRequests::Media"
752
+ +MiniGroup: "LeadRequests::MiniGroup", // "LeadRequests::MiniGroup"
753
+ +Externship: "LeadRequests::Externship", // "LeadRequests::Externship"
754
+ +CoachUserCoursePlanUpgradeCallback: "LeadRequests::CoachUserCoursePlanUpgradeCallback", // "LeadRequests::CoachUserCoursePlanUpgradeCallback"
755
+ +ParentCallback: "LeadRequests::ParentCallback", // "LeadRequests::ParentCallback"
756
+ +TeacherCallback: "LeadRequests::TeacherCallback", // "LeadRequests::TeacherCallback"
757
+ +Email: "LeadRequests::EmailSubscription", // "LeadRequests::EmailSubscription"
758
+ +IThubLead: "LeadRequests::IThubLead", // "LeadRequests::IThubLead"
759
+ |};
760
+ declare class LeadRequestService {
761
+ types: typeof LeadRequestType;
762
+ constructor(apiInstance: ApiInstance): this;
763
+
764
+ /**
765
+ * Create lead request
766
+ * @param {$Values<
767
+ typeof
768
+ LeadRequestType>} type
769
+ * @param {$PropertyType<LeadRequest, "context">} context
770
+ * @param {LeadRequestPayload} data
771
+ */
772
+ createLeadRequest(
773
+ type: $Values<typeof LeadRequestType>,
774
+ context: $PropertyType<LeadRequest, "context">,
775
+ data?: LeadRequestPayload
776
+ ): LeadRequest;
777
+
778
+ /**
779
+ * Send lead request with specific data
780
+ * @param {LeadRequest} leadRequest
781
+ */
782
+ send(leadRequest: LeadRequest): Promise<LeadRequestResponse>;
783
+
784
+ /**
785
+ * Update lead request with specific data
786
+ * @param {string} id
787
+ * @param {LeadRequestPayload} lrData
788
+ */
789
+ update(id: string, lrData?: $Rest<LeadRequest, { ... }>): Promise<mixed>;
790
+ }
791
+ declare class ProductPackService {
792
+ constructor(apiInstance: ApiInstance): this;
793
+ getProductPack(id: number): Promise<ProductPack>;
794
+ }
795
+ declare class PromoService {
796
+ constructor(apiInstance: ApiInstance): this;
797
+ checkPromocode(code: string): Promise<mixed>;
798
+
799
+ /**
800
+ * Send data if user saw the promo code
801
+ * @param {string} promoCode
802
+ * @returns {Promise}
803
+ */
804
+ trackCodeCampaign(promoCode: string): Promise<void>;
805
+ }
806
+ declare class TagService {
807
+ constructor(apiInstance: ApiInstance): this;
808
+ addTag(id: number): Promise<mixed>;
809
+ }
810
+ declare class UserService {
811
+ constructor(
812
+ apiInstance: ApiInstance,
813
+ appOptionsService: AppOptionsService
814
+ ): this;
815
+
816
+ /**
817
+ * Create user instance
818
+ * @param {UserDTO} data data of user
819
+ */
820
+ static createUser(data: UserDTO): User;
821
+
822
+ /**
823
+ * Create default user
824
+ * @returns {User}
825
+ */
826
+ static createDefaultUser(): User;
827
+
828
+ /**
829
+ * Get current user data
830
+ * @return {Promise} Server response with user data
831
+ */
832
+ getUser(): Promise<User>;
833
+
834
+ /**
835
+ * Логин или регистрация юзера по email
836
+ * @param email email юзера
837
+ * @param password пароль
838
+ * @returns {Promise<{
839
+ user: User,
840
+ result: LoginOrRegistrationResponse,...
841
+ }>}
842
+ */
843
+ loginByEmail(
844
+ email: string,
845
+ password: string
846
+ ): Promise<{
847
+ user: User,
848
+ result: LoginOrRegistrationResponse,
849
+ ...
850
+ }>;
851
+
852
+ /**
853
+ * Запрос кода на подтвеждение телефона
854
+ */
855
+ getConfirmationCode(phone: string): Promise<
856
+ ApiResponse<{
857
+ nextDeliveryAt: string,
858
+ ...
859
+ }>
860
+ >;
861
+
862
+ /**
863
+ * Логин или регистрация юзера по телефону
864
+ * @param phone номер телефона
865
+ * @param params
866
+ * @returns {Promise<{
867
+ user: User,
868
+ result: LoginOrRegistrationResponse,...
869
+ }>}
870
+ */
871
+ loginByPhone(phone: string, params: LoginByPhoneParams): Promise<any>;
872
+
873
+ /**
874
+ * Получение покупок текущего пользователя
875
+ * @param {Number} params.resourceId Resource ID
876
+ * @param {String} params.resourceType Resource type
877
+ * @return {Promise} Server response with user purchases
878
+ */
879
+ purchases(x: {
880
+ resourceId: number,
881
+ resourceType: string,
882
+ ...
883
+ }): Promise<mixed>;
884
+
885
+ /**
886
+ * Навигация на страницу входа и перенаправление на указанный путь после успешного входа.
887
+ * @param {String} options.redirectUrl URL для редиректа.
888
+ */
889
+ signIn(x: {
890
+ redirectUrl?: string,
891
+ ...
892
+ }): void;
893
+
894
+ /**
895
+ * Выход из аккаунта с перезагрузкой страницы
896
+ */
897
+ signOut(reloadAfter?: boolean): Promise<mixed>;
898
+ pushEvent(event: {
899
+ action: "experiment" | "funnel" | "conversion" | "click",
900
+ label: string,
901
+ ...
902
+ }): Promise<void>;
903
+
904
+ /**
905
+ * Установить подписку пользователю
906
+ * @param {CommunicationSubscriptions} subscriptions пользовательские подписки
907
+ */
908
+ setSubscriptions(subscriptions: CommunicationSubscriptions): Promise<void>;
909
+
910
+ /**
911
+ * Получение интересов пользователя
912
+ */
913
+ getUserInterests(): Promise<UserInterests>;
914
+
915
+ /**
916
+ * Обновление интересов пользователя
917
+ * @param {$Rest<UserInterests, {...}>} data интересы пользователя
918
+ */
919
+ updateUserInterests(data: $Rest<UserInterests, { ... }>): Promise<void>;
920
+
921
+ /**
922
+ * Обновления множества интересов пользователя
923
+ * @param {$Rest<UserInterests, {...}>} data интересы пользователя
924
+ */
925
+ updateMultipleUserInterests(
926
+ data: $Rest<UserInterests, { ... }>[]
927
+ ): Promise<void>;
928
+ }
929
+ declare interface SdkPlugin {
930
+ apply(sdk: Foxford): void;
931
+ destroy(): void;
932
+ }
933
+ declare class Foxford {
934
+ foxApi: $Call<
935
+ <R>((...args: any[]) => R) => R,
936
+ typeof ApiService.createFoxApiInstance
937
+ >;
938
+ api: $Call<
939
+ <R>((...args: any[]) => R) => R,
940
+ typeof ApiService.createApiInstance
941
+ >;
942
+ staticApi: $Call<
943
+ <R>((...args: any[]) => R) => R,
944
+ typeof ApiService.createStaticApiInstance
945
+ >;
946
+ user: UserService;
947
+ tag: TagService;
948
+ cart: CartService;
949
+ promo: PromoService;
950
+ course: CourseService;
951
+ productPack: ProductPackService;
952
+ leadrequest: LeadRequestService;
953
+ widgets: Widgets;
954
+ appOptions: AppOptionsService;
955
+ captcha: CaptchaService;
956
+ static events: {
957
+ +FETCH_APP_OPTIONS: "Foxford.app_options.fetch",
958
+ +LR_REGISTRATION_SET: "LeadRequest.registration.set",
959
+ ...
960
+ };
961
+ static DEFAULT_CONFIG: FoxfordConfig;
962
+ constructor(config?: FoxfordConfig): this;
963
+
964
+ /**
965
+ * Get short link
966
+ * @param {string} url link for shortening
967
+ */
968
+ shortURL(url: string): Promise<ApiResponse<mixed>>;
969
+
970
+ /**
971
+ * Applies and throwing itself into plugin for access to Api
972
+ * @param {SdkPlugin} plugin Plugin to apply
973
+ */
974
+ applyPlugin(plugin: SdkPlugin): void;
975
+ }
976
+ declare var Analytics: {
977
+ initGlobal(): Promise<void>,
978
+ ...
979
+ };
980
+ export type {
981
+ FoxfordAntibotConfig,
982
+ FoxfordConfig,
983
+ LeadRequest,
984
+ LeadRequestApiResponse,
985
+ LeadRequestPayload,
986
+ SdkPlugin,
987
+ UserDTO,
988
+ UserInterests,
989
+ };
990
+ declare export {
991
+ Analytics,
992
+ AppOptionsService,
993
+ CartService,
994
+ CourseService,
995
+ Foxford,
996
+ FoxfordAntibot,
997
+ LeadRequestService,
998
+ LeadRequestType,
999
+ ProductPackService,
1000
+ PromoService,
1001
+ TagService,
1002
+ User,
1003
+ UserService,
1004
+ Widgets,
1005
+ };