@foxford/foxford-js-sdk
Advanced tools
Comparing version 2.1.56 to 2.1.57
@@ -28,6 +28,12 @@ import { AxiosInstance } from 'axios' | ||
export interface LeadRequestSendResponse extends LeadRequest { | ||
export interface LeadRequestApiResponse { | ||
id: string, | ||
newUser: boolean, | ||
} | ||
export interface LeadRequestResponse { | ||
leadRequest: LeadRequest, | ||
response: LeadRequestApiResponse, | ||
} | ||
export type Course = { | ||
@@ -241,3 +247,3 @@ id: number, | ||
urlGetParams?: string, | ||
): Promise<LeadRequest>; | ||
): Promise<LeadRequestResponse>; | ||
update( | ||
@@ -249,2 +255,15 @@ id: string, | ||
export class LeadRequestService implements LeadRequestServiceI { | ||
createLeadRequest(type: LeadRequestType, context: LeadRequest['context'], data?: LeadRequestData): LeadRequest; | ||
send( | ||
learRequest: LeadRequestData, | ||
urlGetParams?: string, | ||
): Promise<LeadRequestResponse>; | ||
update( | ||
id: string, | ||
data: Partial<LeadRequestData>, | ||
): Promise<unknown>; | ||
static events: LeadRequestEvents; | ||
} | ||
export interface CartItem { | ||
@@ -251,0 +270,0 @@ resource_id: number; |
@@ -1,2 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('axios');var t=require('axios-retry');function r(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var n=r(e);var a=r(t);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((t=>Object.getOwnPropertyDescriptor(e,t).enumerable))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((t=>{u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((t=>{Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function h(e,t){if(null==e)return{};var r=((e,t)=>{if(null==e)return{};var r={};var n=Object.keys(e);var a,o;for(o=0;o<n.length;o++)t.indexOf(a=n[o])>=0||(r[a]=e[a]);return r})(e,t);var n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)t.indexOf(n=o[a])>=0||{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var f;var d=(function(){var e=function(e){var t=Object.prototype;var r=t.hasOwnProperty;var n;var a="function"==typeof Symbol?Symbol:{};var o=a.iterator||"@@iterator";var i=a.asyncIterator||"@@asyncIterator";var s=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=(e,t,r)=>e[t]=r}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof y?t:y).prototype);var o=new L(n||[]);return a._invoke=((e,t,r)=>{var n=h;return(a,o)=>{if(n===d)throw new Error("Generator is already running");if(n===l){if("throw"===a)throw o;return P()}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var s=O(i,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=l,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=p(e,t,r);if("normal"===u.type){if(n=r.done?l:f,u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=l,r.method="throw",r.arg=u.arg)}}})(e,r,o),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h="suspendedStart";var f="suspendedYield";var d="executing";var l="completed";var v={};function y(){}function w(){}function m(){}var g={};g[o]=function(){return this};var b=Object.getPrototypeOf;var x=b&&b(b(A([])));x&&x!==t&&r.call(x,o)&&(g=x);var k=m.prototype=y.prototype=Object.create(g);function E(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function n(a,o,i,s){var u=p(e[a],e,o);if("throw"!==u.type){var c=u.arg;var h=c.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((e=>{n("next",e,i,s)}),(e=>{n("throw",e,i,s)})):t.resolve(h).then((e=>{c.value=e,i(c)}),(e=>n("throw",e,i,s)))}s(u.arg)}var a;this._invoke=(e,r)=>{function o(){return new t(((t,a)=>{n(e,r,t,a)}))}return a=a?a.then(o,o):o()}}function O(e,t){var r=e.iterator[t.method];if(r===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,O(e,t),"throw"===t.method))return v;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var a=p(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,v;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,v):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function t(){for(;++a<e.length;)if(r.call(e,a))return t.value=e[a],t.done=!1,t;return t.value=n,t.done=!0,t};return i.next=i}}return{next:P}}function P(){return{value:n,done:!0}}return w.prototype=k.constructor=m,m.constructor=w,w.displayName=u(m,s,"GeneratorFunction"),e.isGeneratorFunction=e=>{var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},e.mark=e=>(Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e),e.awrap=e=>({__await:e}),E(_.prototype),_.prototype[i]=function(){return this},e.AsyncIterator=_,e.async=(t,r,n,a,o)=>{void 0===o&&(o=Promise);var i=new _(c(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((e=>e.done?e.value:i.next()))},E(k),u(k,s,"Generator"),k[o]=function(){return this},k.toString=()=>"[object Generator]",e.keys=e=>{var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=A,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function a(r,a){return s.type="throw",s.arg=e,t.next=r,a&&(t.method="next",t.arg=n),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o];var s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc");var c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;C(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),v}},e}((f={exports:{}}).exports);try{regeneratorRuntime=e}catch(t){Function("e","regeneratorRuntime=e")(e)}}(),f.exports);function l(e,t,r,n,a,o,i){try{var s=e[o](i);var u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function v(e){return function(){var t=this,r=arguments;return new Promise(((n,a)=>{var o=e.apply(t,r);function i(e){l(o,n,a,i,s,"next",e)}function s(e){l(o,n,a,i,s,"throw",e)}i(void 0)}))}}var y='https://foxford.ru';function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var m=(e,t)=>{var r={};var n=Object.keys(e);for(var a=0;a<n.length;a++){var o=n[a];var i=t(o,e[o],e);r[i[0]]=i[1]}return r};var g=function e(t,r){return t?t instanceof Date?t:Array.isArray(t)?t.map((t=>e(t,r))):"object"==typeof t?m(t,((n,a)=>{var o=((e,t)=>{if('string'!=typeof e)throw new TypeError('Expected a string');return e.replace(/([a-z\d])([A-Z])/g,'$1'+(t=void 0===t?'_':t)+'$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g,'$1'+t+'$2').toLowerCase()})(n,r);if(n!==o&&o in t)throw new Error("Decamelized key `"+o+"` would overwrite existing key of the given JSON object");return[o,e(a,r)]})):t:t};function b(e){var t=!1;for(var r=0;r<e.length;r++){var n=e.charAt(r);t&&/[a-zA-Z]/.test(n)&&n.toUpperCase()===n?(e=e.substr(0,r)+'-'+e.substr(r),t=!1,r++):t=n.toLowerCase()===n}return e}var x=function e(t){return t?t instanceof Date?t:Array.isArray(t)?t.map((t=>e(t))):"object"==typeof t?m(t,((r,n)=>{var a=function(){var e=[].map.call(arguments,(e=>e.trim())).filter((e=>e.length)).join('-');return e.length?1===e.length?e:/[_.\- ]+/.test(e)?(e=b(e)).replace(/^[_.\- ]+/,'').toLowerCase().replace(/[_.\- ]+(\w|$)/g,((e,t)=>t.toUpperCase())):e===e.toUpperCase()?e.toLowerCase():e[0]!==e[0].toLowerCase()?e[0].toLowerCase()+e.slice(1):e:''}(r);if(r!==a&&a in t)throw new Error("Camelcased key `"+a+"` would overwrite existing key of the given JSON object");return[a,e(n)]})):t:t};var k=[422,401];var E=n.default.create({timeout:1e4,baseURL:y,withCredentials:!0,xsrfCookieName:'_csrf_token',xsrfHeaderName:'X-CSRF-Token',headers:{'X-Requested-With':'XMLHttpRequest'}});E.interceptors.request.use((e=>{var t,r;var a='boolean'!=typeof e.camelize||e.camelize;if(e.headers?e.headers['Content-Type']='application/json':e.headers={'Content-Type':'application/json'},e.headers['X-Referer']=(null===(t=window)||void 0===t||null===(r=t.location)||void 0===r?void 0:r.href)||'',e.headers['Referrer-Policy']='no-referrer-when-downgrade',a){var o=n.default.defaults.transformResponse||[];var i=e=>x(e);var s=Array.isArray(o)?[].concat((e=>{if(Array.isArray(e))return w(e)})(u=o)||(e=>{if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)})(u)||((e,t)=>{if(e){if("string"==typeof e)return w(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}})(u)||(()=>{throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})(),[i]):[o,i];e.transformResponse=s}var u;return e})),E.interceptors.response.use((e=>e),(e=>{var t=e.config,r=void 0===t?null:t,n=e.response,a=void 0===n?null:n;if(null===r||null===a)return Promise.reject(e);var o=r;k.includes(a.status)&&(o._retry=!0);var i=p({status:a.status,statusText:a.statusText,errorText:e.toString(),headers:a.headers},'object'==typeof a.data?a.data:{data:a.data});return Promise.reject(i)})),a.default(E,{retries:3,retryDelay:a.default.exponentialDelay});var _=function(){function e(t){if(o(this,e),this.id=void 0,this.email=void 0,this.firstName=void 0,this.middleName=void 0,this.lastName=void 0,this.phone=void 0,this.parent=void 0,this.fakeUser=void 0,this.isCustomer=void 0,this.emailConfirmed=void 0,this.fakeEmail=void 0,this.phoneConfirmed=void 0,this.createdAt=void 0,this.recentRegistration=void 0,this.profileEnriched=void 0,this.skype=void 0,this.graduate=void 0,this.type=void 0,this.avatarUrl=void 0,this.bonusAmount=void 0,this.grade=void 0,this.gradeChecked=void 0,this.tags=void 0,this.hasChats=void 0,this.hasReferrals=void 0,this.onboardingFinished=void 0,this.externshipUser=void 0,'object'!=typeof t)throw new Error('data is wrong');this.id=t.id,this.gradeChecked=t.gradeChecked,this.email=t.email||'',this.firstName=t.firstName,this.middleName=t.middleName||'',this.lastName=t.lastName,this.phone=t.phone||'',this.parent=t.parent,this.fakeUser=t.fakeUser,this.isCustomer=t.isCustomer,this.emailConfirmed=t.emailConfirmed,this.fakeEmail=t.fakeEmail,this.phoneConfirmed=t.phoneConfirmed,this.createdAt=t.createdAt||'',this.recentRegistration=t.recentRegistration,this.profileEnriched=t.profileEnriched,this.skype=t.skype||'',this.graduate=t.graduate,this.type=t.type,this.avatarUrl=t.avatarUrl||'',this.bonusAmount=t.bonusAmount,this.grade=t.grade,this.tags=t.tags,this.hasChats=t.hasChats,this.hasReferrals=t.hasReferrals,this.onboardingFinished=t.onboardingFinished,this.externshipUser=t.externshipUser}return s(e,[{key:"isLoggedIn",value:function(){return this.id>0}}]),e}();var O={id:0,gradeChecked:!1,email:'',firstName:'',middleName:'',lastName:'',phone:'',parent:!1,fakeUser:!1,isCustomer:!1,emailConfirmed:!1,fakeEmail:!1,phoneConfirmed:!1,createdAt:'',recentRegistration:!1,profileEnriched:!1,skype:'',graduate:!1,type:'pupil',avatarUrl:'',bonusAmount:0,grade:{id:0,index:0},tags:[],hasChats:!1,hasReferrals:!1,onboardingFinished:!1,externshipUser:!1};var j=function(){function e(){o(this,e)}var t;var r;var n;var a;var i;var u;var c;return s(e,[{key:"getUser",value:(c=v(d.mark((function e(){var t;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,E.get('/api/user/me').then((e=>e.data));case 3:return t=new _(e.sent),e.abrupt("return",t);case 8:return e.prev=8,e.t0=e.catch(0),e.abrupt("return",new _(O));case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return c.apply(this,arguments)})},{key:"createUser",value:e=>new _(e)},{key:"purchases",value:(u=v(d.mark((function e(t){var r,n,a,o;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if(n=t.resourceType,!(r=t.resourceId)||'number'==typeof r){e.next=3;break}throw new Error('resourceId must be a number');case 3:if(!n||'string'==typeof n){e.next=5;break}throw new Error('resourceType must be a string');case 5:return a=[],r&&a.push("resource_id=".concat(encodeURIComponent(r))),n&&a.push("resource_type=".concat(encodeURIComponent(n))),o=a.length?"?".concat(a.join('&')):'',e.next=11,E.get("/api/user/purchases".concat(o));case 11:return e.abrupt("return",e.sent.data);case 14:case"end":return e.stop()}}),e)}))),function(e){return u.apply(this,arguments)})},{key:"signIn",value:e=>{var t=e.redirectUrl,r=void 0===t?void 0:t;if(r&&'string'!=typeof r)throw new Error('redirectUrl must be a string');var n="".concat(y,"/user/registration?redirect_url=");r&&(n+=encodeURIComponent(document.location.href)),document.location.href=n}},{key:"signOut",value:(i=v(d.mark((function e(){var t,r,n=arguments;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return t=!(n.length>0&&void 0!==n[0])||n[0],e.next=3,E.delete("/user/log_out");case 3:return r=e.sent,t&&window.location.reload(),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)})},{key:"pushEvent",value:(a=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.post("/api/user/event",{event:t});case 2:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})},{key:"setSubscriptions",value:(n=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.put("/api/user/communication_subscriptions",{communication_subscriptions:t});case 2:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getUserInterests",value:(r=v(d.mark((function e(){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.get('/api/user/user_interest');case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"updateUserInterests",value:(t=v(d.mark((function e(t){var r,n,a,o;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return r=t.disciplines,n=h(t,["disciplines"]),a=(null==r?void 0:r.map((e=>e.id)))||[],i=p(p({},n),{},{disciplineIds:a}),o=g(i),e.next=5,E.put('/api/user/user_interest',{user_interest:o});case 5:case"end":return e.stop()}var i}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var C=function(){function e(){o(this,e)}var t;return s(e,[{key:"checkPromocode",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.get("/api/promo_codes/invite/".concat(t));case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var L=function(){function e(){o(this,e)}var t;var r;return s(e,[{key:"createLeadRequest",value:function(e,t,r){var n=arguments.length>2&&void 0!==r?r:{};return Object.assign({type:e,agreement:!0,context:t},n)}},{key:"send",value:(r=v(d.mark((function t(r){var n,a,o=arguments;return d.wrap((t=>{for(;;)switch(t.prev=t.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:'',t.next=3,E.post("/api/lead_requests".concat(n),{lead_request:r});case 3:return(a=t.sent.data).newUser&&window.dispatchEvent(new CustomEvent(e.events.LR_REGISTRATION_SET)),t.abrupt("return",p(p({},r),a));case 7:case"end":return t.stop()}}),t)}))),function(e){return r.apply(this,arguments)})},{key:"update",value:(t=v(d.mark((function e(t){var r,n=arguments;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.next=3,E.put("/api/lead_requests/".concat(t),{lead_request:r});case 3:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();L.events=Object.freeze({LR_REGISTRATION_SET:'LeadRequest.registration.set'});var A=function(){function e(){o(this,e)}var t;return s(e,[{key:"addTag",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.post("/api/user/tag?id=".concat(t));case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var P=function(){function e(){o(this,e)}var t;return s(e,[{key:"createCartItem",value:(e,t)=>({resource_id:e,cart_item_type:t})},{key:"addCartItemToCart",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.post("/api/cart_items",{cart_item:t});case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var R=function(){function e(){o(this,e)}var t;var r;return s(e,[{key:"getCourse",value:(r=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if('number'==typeof t){e.next=2;break}throw new TypeError('id is wrong');case 2:return e.next=4,E.get("/api/courses/".concat(t));case 4:return e.abrupt("return",e.sent.data);case 7:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"enrollCourse",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if('number'==typeof t){e.next=2;break}throw new TypeError('id is wrong');case 2:return e.next=4,E.post("/api/courses/".concat(t,"/users_courses"));case 4:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var T=function(){function e(){o(this,e)}var t;return s(e,[{key:"getProductPack",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if('number'==typeof t){e.next=2;break}throw new TypeError('id is wrong');case 2:return e.next=4,E.get("/api/product_packs/".concat(t));case 4:return e.abrupt("return",e.sent.data);case 7:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var U=function(){function e(t){var r=arguments.length>0&&void 0!==t?t:'latest';o(this,e),this.version=void 0,this.version=r}var t;var r;var n;return s(e,[{key:"create",value:(n=v(d.mark((function e(t){return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error('You must specify config for creating widgets');case 2:return e.next=4,this.loadAssets();case 4:if(window.Foxford&&window.Foxford.Widgets){e.next=6;break}throw new Error('FoxfordWidgets not found in global scope');case 6:if('function'==typeof window.Foxford.Widgets.create){e.next=8;break}throw new Error('Not found function create in FoxfordWidgets library');case 8:window.Foxford.Widgets.create(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=v(d.mark((function e(t,r){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:window.Foxford&&window.Foxford.Widgets&&window.Foxford.Widgets.update(t,r);case 1:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"loadAssets",value:(t=v(d.mark((function e(){var t=this;return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.version||(this.version='latest'),e.abrupt("return",new Promise(((e,r)=>{var n="https://dist.ngcdn.ru/libs/foxford-widgets/".concat(t.version,"/fxf-widgets.js");var a=document.createElement('script');a.type='text/javascript',a.async=!0,a.onload=()=>e(!0),a.onerror=e=>r(e),a.src=n,document.body.appendChild(a)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();var N=function(){function e(){o(this,e)}var t;return s(e,[{key:"getAppOptions",value:(t=v(d.mark((function e(){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.get("/api/app_options");case 2:return e.abrupt("return",e.sent.data);case 4:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),e}();var S={host:y,widgetsVersion:'latest'};var I=function(){function e(t){var r=arguments.length>0&&void 0!==t?t:S;o(this,e),this.api=void 0,this.user=void 0,this.tag=void 0,this.cart=void 0,this.promo=void 0,this.course=void 0,this.productPack=void 0,this.leadrequest=void 0,this.widgets=void 0,this.appOptions=void 0,this._config=void 0,this._config=r,this._config.host&&(E.defaults.baseURL=this._config.host),this.user=new j,this.promo=new C,this.tag=new A,this.cart=new P,this.course=new R,this.widgets=new U(r.widgetsVersion),this.productPack=new T,this.leadrequest=new L,this.appOptions=new N,this.api=E}return s(e,[{key:"shortURL",value:e=>E.post("/api/short_urls",{link:e}).then((e=>e))}]),e}();I.events=Object.freeze({SET_APP_OPTIONS:'Foxford.app_options.set'}),exports.Foxford=I; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var e=require('axios');var t=require('axios-retry');function r(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var n=r(e);var a=r(t);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((t=>Object.getOwnPropertyDescriptor(e,t).enumerable))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((t=>{u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((t=>{Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function h(e,t){if(null==e)return{};var r=((e,t)=>{if(null==e)return{};var r={};var n=Object.keys(e);var a,o;for(o=0;o<n.length;o++)t.indexOf(a=n[o])>=0||(r[a]=e[a]);return r})(e,t);var n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)t.indexOf(n=o[a])>=0||{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var f;var d=(function(){var e=function(e){var t=Object.prototype;var r=t.hasOwnProperty;var n;var a="function"==typeof Symbol?Symbol:{};var o=a.iterator||"@@iterator";var i=a.asyncIterator||"@@asyncIterator";var s=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=(e,t,r)=>e[t]=r}function c(e,t,r,n){var a=Object.create((t&&t.prototype instanceof y?t:y).prototype);var o=new L(n||[]);return a._invoke=((e,t,r)=>{var n=h;return(a,o)=>{if(n===d)throw new Error("Generator is already running");if(n===l){if("throw"===a)throw o;return P()}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var s=O(i,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=l,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var u=p(e,t,r);if("normal"===u.type){if(n=r.done?l:f,u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=l,r.method="throw",r.arg=u.arg)}}})(e,r,o),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h="suspendedStart";var f="suspendedYield";var d="executing";var l="completed";var v={};function y(){}function w(){}function m(){}var g={};g[o]=function(){return this};var b=Object.getPrototypeOf;var x=b&&b(b(A([])));x&&x!==t&&r.call(x,o)&&(g=x);var k=m.prototype=y.prototype=Object.create(g);function E(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function n(a,o,i,s){var u=p(e[a],e,o);if("throw"!==u.type){var c=u.arg;var h=c.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((e=>{n("next",e,i,s)}),(e=>{n("throw",e,i,s)})):t.resolve(h).then((e=>{c.value=e,i(c)}),(e=>n("throw",e,i,s)))}s(u.arg)}var a;this._invoke=(e,r)=>{function o(){return new t(((t,a)=>{n(e,r,t,a)}))}return a=a?a.then(o,o):o()}}function O(e,t){var r=e.iterator[t.method];if(r===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,O(e,t),"throw"===t.method))return v;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var a=p(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,v;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,v):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function t(){for(;++a<e.length;)if(r.call(e,a))return t.value=e[a],t.done=!1,t;return t.value=n,t.done=!0,t};return i.next=i}}return{next:P}}function P(){return{value:n,done:!0}}return w.prototype=k.constructor=m,m.constructor=w,w.displayName=u(m,s,"GeneratorFunction"),e.isGeneratorFunction=e=>{var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},e.mark=e=>(Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e),e.awrap=e=>({__await:e}),E(_.prototype),_.prototype[i]=function(){return this},e.AsyncIterator=_,e.async=(t,r,n,a,o)=>{void 0===o&&(o=Promise);var i=new _(c(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((e=>e.done?e.value:i.next()))},E(k),u(k,s,"Generator"),k[o]=function(){return this},k.toString=()=>"[object Generator]",e.keys=e=>{var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=A,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function a(r,a){return s.type="throw",s.arg=e,t.next=r,a&&(t.method="next",t.arg=n),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o];var s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc");var c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;C(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),v}},e}((f={exports:{}}).exports);try{regeneratorRuntime=e}catch(t){Function("e","regeneratorRuntime=e")(e)}}(),f.exports);function l(e,t,r,n,a,o,i){try{var s=e[o](i);var u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,a)}function v(e){return function(){var t=this,r=arguments;return new Promise(((n,a)=>{var o=e.apply(t,r);function i(e){l(o,n,a,i,s,"next",e)}function s(e){l(o,n,a,i,s,"throw",e)}i(void 0)}))}}var y='https://foxford.ru';function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var m=(e,t)=>{var r={};var n=Object.keys(e);for(var a=0;a<n.length;a++){var o=n[a];var i=t(o,e[o],e);r[i[0]]=i[1]}return r};var g=function e(t,r){return t?t instanceof Date?t:Array.isArray(t)?t.map((t=>e(t,r))):"object"==typeof t?m(t,((n,a)=>{var o=((e,t)=>{if('string'!=typeof e)throw new TypeError('Expected a string');return e.replace(/([a-z\d])([A-Z])/g,'$1'+(t=void 0===t?'_':t)+'$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g,'$1'+t+'$2').toLowerCase()})(n,r);if(n!==o&&o in t)throw new Error("Decamelized key `"+o+"` would overwrite existing key of the given JSON object");return[o,e(a,r)]})):t:t};function b(e){var t=!1;for(var r=0;r<e.length;r++){var n=e.charAt(r);t&&/[a-zA-Z]/.test(n)&&n.toUpperCase()===n?(e=e.substr(0,r)+'-'+e.substr(r),t=!1,r++):t=n.toLowerCase()===n}return e}var x=function e(t){return t?t instanceof Date?t:Array.isArray(t)?t.map((t=>e(t))):"object"==typeof t?m(t,((r,n)=>{var a=function(){var e=[].map.call(arguments,(e=>e.trim())).filter((e=>e.length)).join('-');return e.length?1===e.length?e:/[_.\- ]+/.test(e)?(e=b(e)).replace(/^[_.\- ]+/,'').toLowerCase().replace(/[_.\- ]+(\w|$)/g,((e,t)=>t.toUpperCase())):e===e.toUpperCase()?e.toLowerCase():e[0]!==e[0].toLowerCase()?e[0].toLowerCase()+e.slice(1):e:''}(r);if(r!==a&&a in t)throw new Error("Camelcased key `"+a+"` would overwrite existing key of the given JSON object");return[a,e(n)]})):t:t};var k=[422,401];var E=n.default.create({timeout:1e4,baseURL:y,withCredentials:!0,xsrfCookieName:'_csrf_token',xsrfHeaderName:'X-CSRF-Token',headers:{'X-Requested-With':'XMLHttpRequest'}});E.interceptors.request.use((e=>{var t,r;var a='boolean'!=typeof e.camelize||e.camelize;if(e.headers?e.headers['Content-Type']='application/json':e.headers={'Content-Type':'application/json'},e.headers['X-Referer']=(null===(t=window)||void 0===t||null===(r=t.location)||void 0===r?void 0:r.href)||'',e.headers['Referrer-Policy']='no-referrer-when-downgrade',a){var o=n.default.defaults.transformResponse||[];var i=e=>x(e);var s=Array.isArray(o)?[].concat((e=>{if(Array.isArray(e))return w(e)})(u=o)||(e=>{if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)})(u)||((e,t)=>{if(e){if("string"==typeof e)return w(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}})(u)||(()=>{throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")})(),[i]):[o,i];e.transformResponse=s}var u;return e})),E.interceptors.response.use((e=>e),(e=>{var t=e.config,r=void 0===t?null:t,n=e.response,a=void 0===n?null:n;if(null===r||null===a)return Promise.reject(e);var o=r;k.includes(a.status)&&(o._retry=!0);var i=p({status:a.status,statusText:a.statusText,errorText:e.toString(),headers:a.headers},'object'==typeof a.data?a.data:{data:a.data});return Promise.reject(i)})),a.default(E,{retries:3,retryDelay:a.default.exponentialDelay});var _=function(){function e(t){if(o(this,e),this.id=void 0,this.email=void 0,this.firstName=void 0,this.middleName=void 0,this.lastName=void 0,this.phone=void 0,this.parent=void 0,this.fakeUser=void 0,this.isCustomer=void 0,this.emailConfirmed=void 0,this.fakeEmail=void 0,this.phoneConfirmed=void 0,this.createdAt=void 0,this.recentRegistration=void 0,this.profileEnriched=void 0,this.skype=void 0,this.graduate=void 0,this.type=void 0,this.avatarUrl=void 0,this.bonusAmount=void 0,this.grade=void 0,this.gradeChecked=void 0,this.tags=void 0,this.hasChats=void 0,this.hasReferrals=void 0,this.onboardingFinished=void 0,this.externshipUser=void 0,'object'!=typeof t)throw new Error('data is wrong');this.id=t.id,this.gradeChecked=t.gradeChecked,this.email=t.email||'',this.firstName=t.firstName,this.middleName=t.middleName||'',this.lastName=t.lastName,this.phone=t.phone||'',this.parent=t.parent,this.fakeUser=t.fakeUser,this.isCustomer=t.isCustomer,this.emailConfirmed=t.emailConfirmed,this.fakeEmail=t.fakeEmail,this.phoneConfirmed=t.phoneConfirmed,this.createdAt=t.createdAt||'',this.recentRegistration=t.recentRegistration,this.profileEnriched=t.profileEnriched,this.skype=t.skype||'',this.graduate=t.graduate,this.type=t.type,this.avatarUrl=t.avatarUrl||'',this.bonusAmount=t.bonusAmount,this.grade=t.grade,this.tags=t.tags,this.hasChats=t.hasChats,this.hasReferrals=t.hasReferrals,this.onboardingFinished=t.onboardingFinished,this.externshipUser=t.externshipUser}return s(e,[{key:"isLoggedIn",value:function(){return this.id>0}}]),e}();var O={id:0,gradeChecked:!1,email:'',firstName:'',middleName:'',lastName:'',phone:'',parent:!1,fakeUser:!1,isCustomer:!1,emailConfirmed:!1,fakeEmail:!1,phoneConfirmed:!1,createdAt:'',recentRegistration:!1,profileEnriched:!1,skype:'',graduate:!1,type:'pupil',avatarUrl:'',bonusAmount:0,grade:{id:0,index:0},tags:[],hasChats:!1,hasReferrals:!1,onboardingFinished:!1,externshipUser:!1};var j=function(){function e(){o(this,e)}var t;var r;var n;var a;var i;var u;var c;return s(e,[{key:"getUser",value:(c=v(d.mark((function e(){var t;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,E.get('/api/user/me').then((e=>e.data));case 3:return t=new _(e.sent),e.abrupt("return",t);case 8:return e.prev=8,e.t0=e.catch(0),e.abrupt("return",new _(O));case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return c.apply(this,arguments)})},{key:"createUser",value:e=>new _(e)},{key:"purchases",value:(u=v(d.mark((function e(t){var r,n,a,o;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if(n=t.resourceType,!(r=t.resourceId)||'number'==typeof r){e.next=3;break}throw new Error('resourceId must be a number');case 3:if(!n||'string'==typeof n){e.next=5;break}throw new Error('resourceType must be a string');case 5:return a=[],r&&a.push("resource_id=".concat(encodeURIComponent(r))),n&&a.push("resource_type=".concat(encodeURIComponent(n))),o=a.length?"?".concat(a.join('&')):'',e.next=11,E.get("/api/user/purchases".concat(o));case 11:return e.abrupt("return",e.sent.data);case 14:case"end":return e.stop()}}),e)}))),function(e){return u.apply(this,arguments)})},{key:"signIn",value:e=>{var t=e.redirectUrl,r=void 0===t?void 0:t;if(r&&'string'!=typeof r)throw new Error('redirectUrl must be a string');var n="".concat(y,"/user/registration?redirect_url=");r&&(n+=encodeURIComponent(document.location.href)),document.location.href=n}},{key:"signOut",value:(i=v(d.mark((function e(){var t,r,n=arguments;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return t=!(n.length>0&&void 0!==n[0])||n[0],e.next=3,E.delete("/user/log_out");case 3:return r=e.sent,t&&window.location.reload(),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(){return i.apply(this,arguments)})},{key:"pushEvent",value:(a=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.post("/api/user/event",{event:t});case 2:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})},{key:"setSubscriptions",value:(n=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.put("/api/user/communication_subscriptions",{communication_subscriptions:t});case 2:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"getUserInterests",value:(r=v(d.mark((function e(){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.get('/api/user/user_interest');case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"updateUserInterests",value:(t=v(d.mark((function e(t){var r,n,a,o;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return r=t.disciplines,n=h(t,["disciplines"]),a=(null==r?void 0:r.map((e=>e.id)))||[],i=p(p({},n),{},{disciplineIds:a}),o=g(i),e.next=5,E.put('/api/user/user_interest',{user_interest:o});case 5:case"end":return e.stop()}var i}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var C=function(){function e(){o(this,e)}var t;return s(e,[{key:"checkPromocode",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.get("/api/promo_codes/invite/".concat(t));case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var L=function(){function e(){o(this,e)}var t;var r;return s(e,[{key:"createLeadRequest",value:function(e,t,r){var n=arguments.length>2&&void 0!==r?r:{};return Object.assign({type:e,agreement:!0,context:t},n)}},{key:"send",value:(r=v(d.mark((function t(r){var n,a,o=arguments;return d.wrap((t=>{for(;;)switch(t.prev=t.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:'',t.next=3,E.post("/api/lead_requests".concat(n),{lead_request:r});case 3:return(a=t.sent.data).newUser&&window.dispatchEvent(new CustomEvent(e.events.LR_REGISTRATION_SET)),t.abrupt("return",{leadRequest:r,response:a});case 7:case"end":return t.stop()}}),t)}))),function(e){return r.apply(this,arguments)})},{key:"update",value:(t=v(d.mark((function e(t){var r,n=arguments;return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.next=3,E.put("/api/lead_requests/".concat(t),{lead_request:r});case 3:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();L.events=Object.freeze({LR_REGISTRATION_SET:'LeadRequest.registration.set'});var A=function(){function e(){o(this,e)}var t;return s(e,[{key:"addTag",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.post("/api/user/tag?id=".concat(t));case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var P=function(){function e(){o(this,e)}var t;return s(e,[{key:"createCartItem",value:(e,t)=>({resource_id:e,cart_item_type:t})},{key:"addCartItemToCart",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.post("/api/cart_items",{cart_item:t});case 2:return e.abrupt("return",e.sent.data);case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var R=function(){function e(){o(this,e)}var t;var r;return s(e,[{key:"getCourse",value:(r=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if('number'==typeof t){e.next=2;break}throw new TypeError('id is wrong');case 2:return e.next=4,E.get("/api/courses/".concat(t));case 4:return e.abrupt("return",e.sent.data);case 7:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"enrollCourse",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if('number'==typeof t){e.next=2;break}throw new TypeError('id is wrong');case 2:return e.next=4,E.post("/api/courses/".concat(t,"/users_courses"));case 4:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var T=function(){function e(){o(this,e)}var t;return s(e,[{key:"getProductPack",value:(t=v(d.mark((function e(t){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:if('number'==typeof t){e.next=2;break}throw new TypeError('id is wrong');case 2:return e.next=4,E.get("/api/product_packs/".concat(t));case 4:return e.abrupt("return",e.sent.data);case 7:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();var U=function(){function e(t){var r=arguments.length>0&&void 0!==t?t:'latest';o(this,e),this.version=void 0,this.version=r}var t;var r;var n;return s(e,[{key:"create",value:(n=v(d.mark((function e(t){return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error('You must specify config for creating widgets');case 2:return e.next=4,this.loadAssets();case 4:if(window.Foxford&&window.Foxford.Widgets){e.next=6;break}throw new Error('FoxfordWidgets not found in global scope');case 6:if('function'==typeof window.Foxford.Widgets.create){e.next=8;break}throw new Error('Not found function create in FoxfordWidgets library');case 8:window.Foxford.Widgets.create(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=v(d.mark((function e(t,r){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:window.Foxford&&window.Foxford.Widgets&&window.Foxford.Widgets.update(t,r);case 1:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"loadAssets",value:(t=v(d.mark((function e(){var t=this;return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.version||(this.version='latest'),e.abrupt("return",new Promise(((e,r)=>{var n="https://dist.ngcdn.ru/libs/foxford-widgets/".concat(t.version,"/fxf-widgets.js");var a=document.createElement('script');a.type='text/javascript',a.async=!0,a.onload=()=>e(!0),a.onerror=e=>r(e),a.src=n,document.body.appendChild(a)})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();var N=function(){function e(){o(this,e)}var t;return s(e,[{key:"getAppOptions",value:(t=v(d.mark((function e(){return d.wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.next=2,E.get("/api/app_options");case 2:return e.abrupt("return",e.sent.data);case 4:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),e}();var S={host:y,widgetsVersion:'latest'};var I=function(){function e(t){var r=arguments.length>0&&void 0!==t?t:S;o(this,e),this.api=void 0,this.user=void 0,this.tag=void 0,this.cart=void 0,this.promo=void 0,this.course=void 0,this.productPack=void 0,this.leadrequest=void 0,this.widgets=void 0,this.appOptions=void 0,this._config=void 0,this._config=r,this._config.host&&(E.defaults.baseURL=this._config.host),this.user=new j,this.promo=new C,this.tag=new A,this.cart=new P,this.course=new R,this.widgets=new U(r.widgetsVersion),this.productPack=new T,this.leadrequest=new L,this.appOptions=new N,this.api=E}return s(e,[{key:"shortURL",value:e=>E.post("/api/short_urls",{link:e}).then((e=>e))}]),e}();I.events=Object.freeze({SET_APP_OPTIONS:'Foxford.app_options.set'}),exports.Foxford=I; | ||
//# sourceMappingURL=foxford.cjs.js.map |
@@ -28,6 +28,12 @@ import { AxiosInstance } from 'axios' | ||
export interface LeadRequestSendResponse extends LeadRequest { | ||
export interface LeadRequestApiResponse { | ||
id: string, | ||
newUser: boolean, | ||
} | ||
export interface LeadRequestResponse { | ||
leadRequest: LeadRequest, | ||
response: LeadRequestApiResponse, | ||
} | ||
export type Course = { | ||
@@ -241,3 +247,3 @@ id: number, | ||
urlGetParams?: string, | ||
): Promise<LeadRequest>; | ||
): Promise<LeadRequestResponse>; | ||
update( | ||
@@ -249,2 +255,15 @@ id: string, | ||
export class LeadRequestService implements LeadRequestServiceI { | ||
createLeadRequest(type: LeadRequestType, context: LeadRequest['context'], data?: LeadRequestData): LeadRequest; | ||
send( | ||
learRequest: LeadRequestData, | ||
urlGetParams?: string, | ||
): Promise<LeadRequestResponse>; | ||
update( | ||
id: string, | ||
data: Partial<LeadRequestData>, | ||
): Promise<unknown>; | ||
static events: LeadRequestEvents; | ||
} | ||
export interface CartItem { | ||
@@ -251,0 +270,0 @@ resource_id: number; |
@@ -28,6 +28,12 @@ import { AxiosInstance } from 'axios' | ||
export interface LeadRequestSendResponse extends LeadRequest { | ||
export interface LeadRequestApiResponse { | ||
id: string, | ||
newUser: boolean, | ||
} | ||
export interface LeadRequestResponse { | ||
leadRequest: LeadRequest, | ||
response: LeadRequestApiResponse, | ||
} | ||
export type Course = { | ||
@@ -241,3 +247,3 @@ id: number, | ||
urlGetParams?: string, | ||
): Promise<LeadRequest>; | ||
): Promise<LeadRequestResponse>; | ||
update( | ||
@@ -249,2 +255,15 @@ id: string, | ||
export class LeadRequestService implements LeadRequestServiceI { | ||
createLeadRequest(type: LeadRequestType, context: LeadRequest['context'], data?: LeadRequestData): LeadRequest; | ||
send( | ||
learRequest: LeadRequestData, | ||
urlGetParams?: string, | ||
): Promise<LeadRequestResponse>; | ||
update( | ||
id: string, | ||
data: Partial<LeadRequestData>, | ||
): Promise<unknown>; | ||
static events: LeadRequestEvents; | ||
} | ||
export interface CartItem { | ||
@@ -251,0 +270,0 @@ resource_id: number; |
{ | ||
"name": "@foxford/foxford-js-sdk", | ||
"version": "2.1.56", | ||
"version": "2.1.57", | ||
"description": "Foxford sdk for external projects", | ||
@@ -5,0 +5,0 @@ "main": "foxford.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
295219
1329