UNPKG

bb-api-platforma

Version:

API module for BetBooster Platform

2 lines 34.9 kB
import{api}from"./Types.js";const locales={en:"en-US",pt:"en-US",fr:"fr-FR",ht:"fr-FR",es:"en-US",tr:"tr-TR",az:"tr-TR",uk:"en-US",cr:"fr-FR",ru:"ru-RU"},languageIdsRemote={en:1,pt:1,fr:4,es:1,tr:5,az:5,uk:1,cr:1,ru:0},stringify=t=>JSON.stringify(t,null,2);function convertBasketToPost(t){return{a1:t.Add1,a2:t.Add2,bId:t.BetVarID,eId:t.LinesID,fs:t.HandSize,isLive:t.IsLive,r:t.Odds}}export function routeNameId(t,e=""){return`${e.replace(/[\s\.\,\(\)\[\]\\\/\-\~\`\"\']+/g," ").trim().replace(/\s+/g,"-").toLowerCase()}~${t}`}export function clearPhone(t,e="",s=""){return e+(String(t).match(/\d+/g)||[]).join("")+s}let IS_DEV_MODE=!1;export class BetBoosterApi{constructor(t,e,s="en",a=15e3,i=!1){this._locale="en-EN",this._locales=locales,this._languageIdsRemote=languageIdsRemote,this.EXIST_LANGUAGES=Object.keys(locales),this._languageId=1,this._lang="en",this._USER_DATA={},this.LANG_DEFAULT="en",this.LOCALE_DEFAULT="en-EN",this.LANG_ID_DEFAULT=1,this.maxTimeExecutionMs=15e3,this.liveTimestamp=0,this._liveTimestampReset=!1,this.liveRecivedIsFullPackage=!1,this.isNotActive=!1,IS_DEV_MODE=i,this.maxTimeExecutionMs=a,this.axi=t,this.setBaseUrl(e),this.setLanguage(s)}get locale(){return this._locale}get isSinged(){return void 0!==this.user&&void 0!==this.user.UserId&&this.user.UserId>0}get user(){return this._USER_DATA}get userMain(){var t,e,s,a,i,n,r,l,o,u,c,d,h,g;return[`uid: ${null!==(e=null===(t=this._USER_DATA)||void 0===t?void 0:t.UserId)&&void 0!==e?e:"--"}`,`unm: ${null!==(a=null===(s=this._USER_DATA)||void 0===s?void 0:s.UserName)&&void 0!==a?a:"--"}`,`pid: ${null!==(n=null===(i=this._USER_DATA)||void 0===i?void 0:i.PointId)&&void 0!==n?n:"--"}`,`ptp: ${null!==(l=null===(r=this._USER_DATA)||void 0===r?void 0:r.PlayerType)&&void 0!==l?l:"--"}`,`gid: ${null!==(u=null===(o=this._USER_DATA)||void 0===o?void 0:o.GroupID)&&void 0!==u?u:"--"}`,`bal: ${null!==(d=null===(c=this._USER_DATA)||void 0===c?void 0:c.Amount)&&void 0!==d?d:"--"}`,`cur: ${null!==(g=null===(h=this._USER_DATA)||void 0===h?void 0:h.CurrencyName)&&void 0!==g?g:"--"}`]}set user(t){this._USER_DATA=t}get lang(){return this._lang}get languageId(){return this._languageId}get token(){var t;return null!==(t=this._TOKEN)&&void 0!==t?t:void 0}set token(t){this._TOKEN="string"==typeof t?t.split(/\s*,\s*/)[0]:void 0}responseHandlerData(t,e,s){var a,i,n;let r=null;void 0!==(null===(a=null==t?void 0:t.Data)||void 0===a?void 0:a.Data)?r=t.Data.Data:void 0!==(null===(i=null==t?void 0:t.Data)||void 0===i?void 0:i._isSuccessful)?r=t.Data._isSuccessful:void 0!==(null==t?void 0:t.Data)?r=t.Data:void 0!==t&&(r=t);const l=(null===(n=null==t?void 0:t.Data)||void 0===n?void 0:n.Error)||(null==t?void 0:t.Error)||(200!==e?s:null)||(r?null:"Unknown error");return"Object reference not set to an instance of an object."===l&&console.log("!!!!!!!!!!! Object reference not set to an instance of an object."),{data:r,error:l,status:e,statusText:s}}convertDataData(t){var e;if(void 0!==(null===(e=null==t?void 0:t.Data)||void 0===e?void 0:e.Data)){const e=Object.keys(t.Data);if(e.length>0){const s={};return e.forEach((e=>{var a;s[e.toLowerCase()]=null!==(a=t.Data[e])&&void 0!==a?a:null})),s}}return t}setDevMode(t){IS_DEV_MODE=void 0===t||t}addLocalesConverters(t){this._locales=Object.assign(Object.assign({},this._locales),t);const e=new Set([...this.EXIST_LANGUAGES,...Object.keys(this._locales)]);this.EXIST_LANGUAGES=Array.from(e)}checkLanguage(t="en"){try{const e=t.substring(0,2)||this.LANG_DEFAULT;return this.EXIST_LANGUAGES.includes(e)?e:this.LANG_DEFAULT}catch(t){return this.LANG_DEFAULT}}setLanguage(t="en"){var e,s;return this._lang=this.checkLanguage(t),this._locale=null!==(e=this._locales[this._lang])&&void 0!==e?e:this.LOCALE_DEFAULT,this._languageId=null!==(s=this._languageIdsRemote[this._lang])&&void 0!==s?s:this.LANG_ID_DEFAULT,this._lang}async setLanguageRemoteLocale(t="en"){if(this.setLanguage(t),this.isSinged){const t=this.url("/account/SetLanguage",api.LBC);return await this.POST(t,{culture:this.locale})||!1}}setBaseUrl(t){return t.endsWith("/")&&(t=t.slice(0,-1)),this._baseUrl=t,this._baseUrl}statusHandler(t,e){401===t&&(this.user={},this.token=void 0,IS_DEV_MODE&&console.log("Status:",t,e))}queryStringHandler(t={}){return Object.keys(t).forEach((e=>{null===t[e]?t[e]="null":!0===t[e]?t[e]="true":!1===t[e]?t[e]="false":void 0===t[e]&&(t[e]="")})),t}responseHandler(t){var e,s,a,i;const n=null!==(s=null!==(e=null==t?void 0:t.headers["x-token"])&&void 0!==e?e:null==t?void 0:t.headers["X-token"])&&void 0!==s?s:null;IS_DEV_MODE&&(null===(a=null==t?void 0:t.request)||void 0===a?void 0:a.path)&&console.log(null===(i=null==t?void 0:t.request)||void 0===i?void 0:i.path),n&&(this.token=n,IS_DEV_MODE&&console.log("isSinged:",this.isSinged+"\nX-Token:",n))}axiosErrorHandler(t){var e,s,a,i,n,r,l,o;let u,c=null!==(s=null===(e=t.response)||void 0===e?void 0:e.status)&&void 0!==s?s:null,d=null!==(i=null===(a=t.response)||void 0===a?void 0:a.statusText)&&void 0!==i?i:null;const h=null!==(n=t.response)&&void 0!==n?n:null;if(h){if(u=[...c?[c]:[],...d?[d]:[],...(null===(r=null==h?void 0:h.data)||void 0===r?void 0:r.Message)?[h.data.Message]:[],...(null===(l=null==h?void 0:h.data)||void 0===l?void 0:l.MessageDetail)?[h.data.MessageDetail]:[]].join(" > "),IS_DEV_MODE){const t=(null!==(o=h.config.method)&&void 0!==o?o:"").toUpperCase(),e=h.config.url,s=h.config.data;console.log("```"),console.log("ERROR:",t,e),console.log("DATA:",s),console.log("RESPONCE:",null==h?void 0:h.data),console.log("```")}}else t.request?(u="Error: No response received",c=503,d="Service Unavailable"):(u=`Error: ${null==t?void 0:t.message}`,c=601,d=(null==t?void 0:t.message)||"Unknown error");return console.error("Axios request error:",u),{data:null,status:c,statusText:u||d||"Unknown error"}}url(t,e){if(t.toLowerCase().startsWith("http"))return t;switch(e){case api.V2:return`${this._baseUrl}/v2/bsw/api${t}`;case api.NV20:return`${this._baseUrl}/nv20${t}`;case api.LBC:return`${this._baseUrl}/v2/lbc/api${t}`;case api.DIRECT:return`${this._baseUrl}${t}`;case api.V1:default:return`${this._baseUrl}/api${t}`}}request(t){const e=this.queryStringHandler,s=this.axi,a=this.axiosErrorHandler,i=(t,e)=>{401===t&&(this.user={},this.token=void 0,IS_DEV_MODE&&console.log("Status:",t,e))},n=async t=>{var e,s;try{console.error(t);const a=["undefined"!=typeof window?window.location.href:"url: unknown",`Error: ${(null==t?void 0:t.error)||"Unknown error"}`,...this.userMain].filter(Boolean).join("\n");let i="";try{i=null!==(e=JSON.stringify(t,null,2))&&void 0!==e?e:"Unknown error"}catch(e){i=null!==(s=null==t?void 0:t.error)&&void 0!==s?s:"Unknown error"}await this.sendErrInfo(a,i)}catch(t){}},r=t=>{var e,s,a,i,r,l,o,u,c,d,h,g,v,p;const T=null!==(e=null==t?void 0:t.headers["x-token"])&&void 0!==e?e:null,m=null!==(a=null===(s=null==t?void 0:t.request)||void 0===s?void 0:s.path)&&void 0!==a?a:null;if(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.Error){const e=(null!==(l=null===(r=null==t?void 0:t.config)||void 0===r?void 0:r.method)&&void 0!==l?l:"").toUpperCase(),s=Object.assign(Object.assign(Object.assign({method:e,url:(null===(o=null==t?void 0:t.config)||void 0===o?void 0:o.url)||""},(null===(u=null==t?void 0:t.config)||void 0===u?void 0:u.params)?{params:null!==(d=null===(c=null==t?void 0:t.config)||void 0===c?void 0:c.params)&&void 0!==d?d:""}:{}),(null===(h=null==t?void 0:t.config)||void 0===h?void 0:h.data)?{POST:null!==(v=null===(g=null==t?void 0:t.config)||void 0===g?void 0:g.data)&&void 0!==v?v:""}:{}),{error:null===(p=null==t?void 0:t.data)||void 0===p?void 0:p.Error});n(s)}IS_DEV_MODE&&m&&console.log(m),T&&(this.token=T,IS_DEV_MODE&&console.log("isSinged:",this.isSinged+"\nX-Token:",T))},l=Date.now(),o=new AbortController,u=setTimeout((()=>{o.abort()}),this.maxTimeExecutionMs),c={url:t,method:"GET",params:{_:l},headers:Object.assign({},this.token?{"X-Token":this.token}:{}),responseType:"json",signal:o.signal};return{query(t={}){const s=e(t);return c.params=Object.assign(Object.assign({},s),c.params),this},headers(t={}){return c.headers=Object.assign(Object.assign({},c.headers),t),this},deleteAllHeaders(){return delete c.headers,this},GET(){return c.method="GET",this},POST(t={}){return c.method="POST",c.data=t,this},PUT(t={}){return c.method="PUT",c.data=t,this},DELETE(t={}){return c.method="DELETE",c.data=t,this},async exec(){"GET"!==c.method&&delete c.params._;const t=s.request(c).then((t=>(r(t),t))).catch(a).finally((()=>clearTimeout(u))),{data:e,status:n,statusText:l}=await t;return i(n,l),{data:e,status:n,statusText:l}},async value(){const{data:t}=await this.exec();await t}}}async GET(t,e={},s={}){const a=new AbortController,i=setTimeout((()=>{a.abort()}),this.maxTimeExecutionMs),n={params:this.queryStringHandler(e),headers:Object.assign(Object.assign({},this.token?{"X-Token":this.token}:{}),null!=s?s:{}),responseType:"json",signal:a.signal},r=this.axi.get(t,n).then((t=>(this.responseHandler(t),t))).catch(this.axiosErrorHandler).finally((()=>clearTimeout(i))),{data:l,status:o,statusText:u}=await r;return this.statusHandler(o,u),l}async POST(t,e={},s={},a={}){const i=new AbortController,n=setTimeout((()=>{i.abort()}),this.maxTimeExecutionMs),r={params:this.queryStringHandler(s),headers:Object.assign(Object.assign({},this.token?{"X-Token":this.token}:{}),null!=a?a:{}),responseType:"json",signal:i.signal},l=this.axi.post(t,e,r).then((t=>(this.responseHandler(t),t))).catch(this.axiosErrorHandler).finally((()=>clearTimeout(n))),o=await l,{data:u,status:c,statusText:d}=o;return this.statusHandler(c,d),u}async DELETE(t,e={},s={},a={}){const i=new AbortController,n=setTimeout((()=>{i.abort()}),this.maxTimeExecutionMs),r={params:this.queryStringHandler(s),headers:Object.assign(Object.assign({},this.token?{"X-Token":this.token}:{}),null!=a?a:{}),responseType:"json",signal:i.signal,data:e},l=this.axi.delete(t,r).then((t=>(this.responseHandler(t),t))).catch(this.axiosErrorHandler).finally((()=>clearTimeout(n))),{data:o,status:u,statusText:c}=await l;return this.statusHandler(u,c),o}async PUT(t,e={},s={},a={}){const i=new AbortController,n=setTimeout((()=>{i.abort()}),this.maxTimeExecutionMs),r={params:this.queryStringHandler(s),headers:Object.assign(Object.assign({},this.token?{"X-Token":this.token}:{}),null!=a?a:{}),responseType:"json",signal:i.signal},l=this.axi.put(t,e,r).then((t=>(this.responseHandler(t),t))).catch(this.axiosErrorHandler).finally((()=>clearTimeout(n))),{data:o,status:u,statusText:c}=await l;return this.statusHandler(u,c),o}async getLineSports(t=0){var e;const s=+t>0?this.url(`/line/${this.locale}/sports/${t}`):this.url(`/line/${this.locale}/allSports`);return null!==(e=await this.GET(s,{},{}))&&void 0!==e?e:[]}async getHotEvents(){var t;const e=this.url(`/line/${this.locale}/hotevents`);return null!==(t=await this.GET(e,{},{}))&&void 0!==t?t:[]}async getCountriesList(t,e=0){var s;const a=this.url(`/line/${this.locale}/countries/sport${t}/${e}`);return null!==(s=await this.GET(a,{},{}))&&void 0!==s?s:[]}async getPrematchTournaments(t,e,s=0){var a;const i=this.url(`/line/${this.locale}/tournaments/sport${t}/country${e}/${s}`);return null!==(a=await this.GET(i,{},{}))&&void 0!==a?a:[]}async getPrematchTournamentsByMinutes(t=0,e=0){var s;const a=this.url(`/line/${this.locale}/events/full/sport${t}/${e}`);return(null!==(s=await this.GET(a,{},{}))&&void 0!==s?s:[]).filter((t=>{var e;return(null!==(e=null==t?void 0:t.EventsHeaders)&&void 0!==e?e:[]).length>0}))}async getPrematchTournamentsHeadersByMinutes(t=0,e=0){var s;const a=this.url(`/line/${this.locale}/tournaments/headers/sport${t}/${e}`);return null!==(s=await this.GET(a,{},{}))&&void 0!==s?s:[]}async getPrematchEvents(t,e,s,a){var i;const n=this.url(`/line/${this.locale}/events/sport${t}/country${e}/tourney${s}/${a}`);return null!==(i=await this.GET(n,{},{}))&&void 0!==i?i:[]}liveTimestampReset(t=!0){this._liveTimestampReset=t}async getLive(t=!1,e=[]){var s;let a=!1;(t||!0===this._liveTimestampReset)&&(this.liveTimestamp=0,this.liveTimestampReset(!1));const i=this.url(`/live/${this.locale}/full/${this.liveTimestamp}/0`),{data:n,status:r}=await this.request(i).GET().query({events:e}).exec(),{TimeStamp:l,LEvents:o,IsChanges:u}=null!=n?n:{};return a=!1===u,this.liveTimestamp=200===r&&null!==(s=null!=l?l:this.liveTimestamp)&&void 0!==s?s:0,{ts:+this.liveTimestamp,events:null!=o?o:[],isFullPackage:a}}async getFullLiveWithoutSaveTimeStamp(){var t;const e=this.url(`/live/${this.locale}/full/0/0`),s=null!==(t=await this.GET(e,{},{}))&&void 0!==t?t:{},{LEvents:a}=null!=s?s:{};return null!=a?a:[]}async getLiveEventsAndFullEvent(t){var e;const s=this.url(`/live/${this.locale}/bets/${t}`);return[null!==(e=await this.GET(s,{},{}))&&void 0!==e?e:{}]}async getLiveEventFull(t){const e=this.url(`/live/${this.locale}/bets/${t}`),{data:s}=await this.request(e).exec();return null!=s?s:null}async getEventPrematch(t){var e;const s=this.url(`/line/${this.locale}/event/${t}`);return null!==(e=await this.GET(s,{},{}))&&void 0!==e?e:{}}async verifyEmail(t){var e;const s=this.url(`/account/userActivationByEmail/${t}/${this.locale}`);return null!==(e=await this.GET(s,{},{}))&&void 0!==e?e:{}}async signUp(t){Object.assign(t,{Culture:this.locale});const e=this.url(`/account/${this.locale}/registration`);return await this.POST(e,t)}async signUpViaEmail(t){if(t.CurrencyId){const e=t.CurrencyId;t.PointId=e,delete t.CurrencyId}Object.assign(t,{Culture:this.locale});const e=this.url(`/account/${this.locale}/registrationNewEmail`);return await this.POST(e,t)}async signUpDirect(t){if(t.CurrencyId){const e=t.CurrencyId;t.PointId=e,delete t.CurrencyId}Object.assign(t,{Culture:this.locale});const e=this.url(`/account/${this.locale}/registrationNewWhithOutEmail`);return await this.POST(e,t)}async createInternetUser(t){var e,s;if(t.CurrencyId){const e=t.CurrencyId;t.PointId=e,delete t.CurrencyId}if(!(null==(t=Object.assign({},t,{Culture:this.locale}))?void 0:t.PointId))return{created:null,error:"parametersError",status:200,statusText:""};t.PointId&&t.PointId<1e4&&(t.PointId=t.PointId+1e4);const a=this.url(`/account/${this.locale}/registrationNewWhithOutEmail`),{data:i,status:n,statusText:r}=await this.request(a).POST(t).exec();return{created:null!==(s=null===(e=null==i?void 0:i.Data)||void 0===e?void 0:e._isSuccessful)&&void 0!==s?s:null,error:(null==i?void 0:i.Error)||null,status:n,statusText:r}}async getResultsSports(t,e){const s=this.url(`/results/${this.locale}/sports/0/${t}/${e}`);return await this.GET(s,{},{})}async getResultsTournamentsBySportId(t,e,s){const a=this.url(`/results/${this.locale}/tournaments/sport${t}/0/${e}/${s}`);return await this.GET(a,{},{})}async getResultsGrid(t,e,s,a,i){const n=this.url(`/results/${this.locale}/sport${t}/country${e}/tournament${s}/0/${a}/${i}`),r=await this.GET(n,{},{});return null!=r?r:[]}async getGamesProvidersTopGames(){const t=this.url("/slotintegrator-service/topGameByProvider"),e=await this.GET(t,{},{});return null!=e?e:[]}async getGamesTopProviders(){const t=this.url("/slotintegrator-service/topProviders"),e=await this.GET(t,{},{});return null!=e?e:[]}async getSlotsList(){const t=this.url("/slotintegrator-service/gamelist"),{items:e}=await this.GET(t,{},{});return null!=e?e:[]}async createSlotOutcome(t){return{}}async createSlotIntegratorDemo(t){const e=this.locale||"en";try{t.language=e.substring(0,2);const s=this.url("/slotintegrator-service/InitDemoGames"),a=await this.POST(s,t);return JSON.parse(a)}catch(t){return{}}}async createSlotIntegratorReal(t){try{const e=this.url("/slotintegrator-service/InitRealGames"),s=await this.POST(e,t);return JSON.parse(s)}catch(t){return{}}}async getSlotIntegratorProvidersHeaders(){try{const t=this.url("/slotintegrator-service/ProviderHeaders"),e=(await this.GET(t)||[]).map((t=>Object.assign(Object.assign({},t),{ProviderName:t.Provider,Games:[]})));return null!=e?e:[]}catch(t){return[]}}async getSlotIntegratorProviderAllGames(t){const e=this.url(`/slotintegrator-service/searchGameByProvider/${t}`),s=await this.GET(e);return null!=s?s:[]}async getSlotIntegratorFilteredGames(t){const e=this.url(`/slotintegrator-service/searchGameByName/${t}`),s=await this.GET(e);return null!=s?s:[]}async login({login:t,password:e}){this.token=void 0;const s=this.url("/account/LogIn",api.LBC),a={Login:t,Password:e,Culture:this.locale},i=await this.POST(s,a),{Data:n}=null!=i?i:{};return!n&&IS_DEV_MODE&&console.log("\n```\n/account/LogIn:\n",i,"\n```\n"),n&&n.UserId>0&&n["X-Token"]?(this.token=n["X-Token"],this.user=n,this.user):(this.user={},this.user)}async getUserData_OLD(){const t=this.url("/account/GetUserData",api.LBC),e=await this.GET(t);return(null==e?void 0:e.UserId)>0?(this.user=e,e):(this.user={},null)}async getUserData(){const t=this.url("/account/GetUserData",api.LBC),{data:e,status:s,statusText:a}=await this.request(t).exec();return this.user=(null==e?void 0:e.UserId)>0?e:{},this.responseHandlerData(e,s,a)}async getUserFullData(){return await this.getUserData()}async logout(){const t=this.url("/account/LogOut",api.LBC),e=await this.POST(t),s=!1===e;return this.user={},this.token=void 0,{ok:s,isLogged:!!s&&e}}async balance(){if(this.isSinged){const t=this.url("/account/GetUserBalance",api.LBC),e=await this.GET(t);return null!=e?e:{}}return{}}async getBalance(){const t=this.url("/account/GetUserBalance",api.LBC),{data:e,status:s,statusText:a}=await this.request(t).exec();return this.responseHandlerData(e,s,a)}async changePassword(t){var e;if(this.isSinged){t.userData.Gmt=(new Date).getTimezoneOffset()/60,t.userData.Language=this.languageId;const s=this.url("/account/ChangeUserPassword",api.LBC),a=await this.POST(s,t);return console.log(a),{ok:!a.IsError||!1,status:null!==(e=a.ErrorCode)&&void 0!==e?e:5001}}return{ok:!1,status:5001}}longToGuid(t){const e=new ArrayBuffer(16);new DataView(e).setUint32(0,t,!0);const s=Array.from(new Uint8Array(e));return[s.slice(0,4).reverse(),s.slice(4,6).reverse(),s.slice(6,8).reverse(),s.slice(8,10),s.slice(10,16)].map((t=>t.map((t=>t.toString(16).padStart(2,"0"))).join(""))).join("-")}async getSportsEventsSearch(t){var e,s;if(!t)return[];const a=this.url("/line/SearchFullByCulture",api.V2),i={culture:this.locale,searchText:t},[n,r]=await Promise.all([null!==(e=this.GET(a,i))&&void 0!==e?e:[],null!==(s=this.getFullLiveWithoutSaveTimeStamp())&&void 0!==s?s:[]]),l=n.filter((t=>t.Type>1)).map((t=>{var e;const s=new Date(null!==(e=null==t?void 0:t.Date)&&void 0!==e?e:"").toLocaleDateString(this.locale,{weekday:"short",day:"2-digit",month:"long",hour:"2-digit",minute:"2-digit"}).replace(",","");return Object.assign(t,{Date:s,to:{name:"eventprematch",params:{prEventId:routeNameId(t.Id,t.Name)}},t1:t.Name.split(/\s*\-\s*/)[0],t2:t.Name.split(/\s*\-\s*/)[1]})})),o=t.toLowerCase();return[...r.filter((t=>t.Description.NameTeam1.toLowerCase().includes(o)||t.Description.NameTeam2.toLowerCase().includes(o)||t.Description.TName.toLowerCase().includes(o))).map((t=>{const e=`${t.Description.NameTeam1} vs ${t.Description.NameTeam2} ${t.Description.SportName}`,s=new Date(t.Description.Date).toLocaleDateString(this.locale,{weekday:"short",day:"2-digit",month:"long",hour:"2-digit",minute:"2-digit"}).replace(",","");return{CountryId:t.Description.CountryId,Date:s,Id:+t.Id,Name:e,PriceNum:t.Description.PriceNum,SportId:t.Description.SportId,SportName:t.Description.SportName,TournamentId:t.Description.TournamentId,TournamentName:t.Description.TName,Type:3,isLive:!0,to:{name:"eventinplay",params:{prEventId:routeNameId(t.Id,e)}},t1:t.Description.NameTeam1,t2:t.Description.NameTeam2}})),...l]}async getFavorites(){if(this.isSinged){const t=this.url("/favorites/GetFavorites",api.V2),e=await this.GET(t,{culture:this.locale});return null!=e?e:[]}return[]}async addFavorite(t,e){if(this.isSinged){const s=this.url("/favorites/AddToFavorites",api.V2),a=await this.POST(s,{},{id:t,type:e});return null!=a&&a}return!1}async removeFavorite(t){if(this.isSinged){const e=this.url("/favorites/RemoveFromFavorites",api.V2),s=await this.POST(e,{id:t});return null!=s&&s}return!1}async getPurses(t=5){if(this.isSinged){const e=this.url("/account/GetPurses",api.V2),s={psType:t},a=await this.GET(e,s);return null!=a?a:[]}return[]}async sendWithdrawal(t,e){}async sendWithdrawalAgent(t){if(this.isSinged){const e={securityCode:"",secAnswer:"",additionalParams:{}};Object.assign(e,t);const s=this.url("/payment/CreateOrderWithdraw",api.LBC),a=await this.POST(s,e);if(isNaN(parseFloat(a)))return{ok:!1,status:a};{const t=await this.getOrderedTransactions();return{ok:!0,balance:parseFloat(a),userOrders:t}}}return{ok:!1,status:10016}}async cancelOrderedTransaction(t){if(this.isSinged){const e=this.url("/payment/CancelOrderedTransaction",api.LBC),s=await this.POST(e,t);if(-1===s)return{ok:!1,status:103};if(isNaN(parseFloat(s)))return{ok:!1,status:103};{const t=await this.getOrderedTransactions();return{ok:!0,balance:parseFloat(s),userOrders:t}}}return{ok:!1,status:10016}}async getMovementOfMoney(t){var e;if(this.isSinged){Object.assign(t,{culture:this.locale});const s=this.url("/account/GetAccountTransactions",api.V2),a=await this.GET(s,t),i=(null!==(e=null==a?void 0:a.TransactionsDataList)&&void 0!==e?e:[]).map((t=>{var e;return{income:null!==(e=t.IsAddition)&&void 0!==e&&e,sign:t.IsAddition?"+":"-",id:t.Id,typeId:t.TransactionType,typeName:t.TransactionDescription,date:t.TransactionDate,value:t.Amount,amount:t.Amount,bonus:t.Bonus,balance:t.Balance}}));return{result:i}}return{result:[]}}async getOrderedTransactions(){if(this.isSinged){const t=this.url("/account/GetOrderedTransactions",api.V2);return await this.GET(t)}return[]}async getBetContent(t){const e={id:t,culture:this.locale};if(this.isSinged){const t=this.url("/account/GetBetContent",api.V2);return await this.GET(t,e)}return{}}async getUserBets(t){if(Object.assign(t,{culture:this.locale}),this.isSinged){const e=this.url("/account/GetUserBets",api.V2);return await this.GET(e,t)}}async getUserBets02(t){if(Object.assign(t,{culture:this.locale}),this.isSinged){const e=this.url("/account/GetUserBets",api.V2),{data:s,status:a,statusText:i}=await this.request(e).query(t).exec();return{data:null!=s?s:null,error:200!==a?i:null,status:a,statusText:i}}return{data:null,error:"Unauthorized",status:401,statusText:"Unauthorized"}}async getOddsForEdit(t){const e=this.url("/betting/GetBetForChange",api.LBC),{data:s,status:a,statusText:i}=await this.request(e).POST(t).exec(),n=this.convertDataData(s);return this.responseHandlerData(n,a,i)}async placeCouponEdited(t){const e=this.url("/betting/ChangeBet",api.LBC),{data:s,status:a,statusText:i}=await this.request(e).POST(t).exec(),n=this.convertDataData(s);return this.responseHandlerData(n,a,i)}async getUserBetsCashout(t){const e=this.url("/betting/CheckCashoutForBets",api.LBC),{data:s,status:a,statusText:i}=await this.request(e).POST({BetIds:t}).exec();return this.responseHandlerData(s,a,i)}async returnCashoutBet(t){const e=this.url("/betting/CashOutReturnBet",api.LBC),{data:s,status:a,statusText:i}=await this.request(e).POST(t).exec(),n=this.convertDataData(s);return this.responseHandlerData(n,a,i)}createCoupon(t,e,s,a=-1){var i,n,r,l,o;const u={betAmount:e,doAcceptOddsChanges:s,statuses:{},systemIndex:a};for(let e=0;e<t.length;e++){const s=t[e],a=[null!==(i=s.LinesID)&&void 0!==i?i:"null",null!==(n=s.BetVarID)&&void 0!==n?n:"null",null!==(r=s.HandSize)&&void 0!==r?r:"null",null!==(l=s.Add1)&&void 0!==l?l:"null",null!==(o=s.Add2)&&void 0!==o?o:"null"].join("_");u.statuses[a]=!0}return u}async placeCoupon(t){if(this.isSinged){const e=this.url("/betting/PlaceBet",api.LBC);return await this.POST(e,t)}}async placeCouponBetShop(t){if(this.isSinged){const e=this.url("/betting/PlaceBetSubCashier",api.LBC);return await this.POST(e,t)}}async getBetShopCouponByCode(t){if(this.isSinged){const e=this.url("/betting/GetBetSubCashier",api.LBC),s={code:t,culture:this.locale},{data:a,status:i,statusText:n}=await this.request(e).query(s).exec();return this.responseHandlerData(a,i,n)}}async loginIsExist(t){const e=this.url("/account/IsUserExists",api.LBC);return await this.GET(e,{userName:t})}async emailIsExist(t){const e=this.url("/account/IsEmailExists",api.LBC);return await this.GET(e,{email:t})}async changePersonalData(t){if(this.isSinged){const e=this.url("/account/ChangePersonalData",api.LBC);return await this.POST(e,t)||!1}return!1}async getMessagesAll({page:t,pageSize:e}){if(this.isSinged){const s=this.url("/messages/GetAllMessages",api.LBC),a=await this.GET(s,{page:t,pageSize:e});return null!=a?a:[]}return[]}async getMessageById(t){var e;if(this.isSinged){const s=this.url("/messages/GetMessagesById",api.LBC);return null!==(e=(await this.GET(s,{id:t}))[0])&&void 0!==e?e:{}}return{}}async sensMessage({ToUserId:t,Text:e,Subject:s,ParentId:a}){if(this.isSinged){const i=this.url("/messages/SendMessage",api.LBC),n=await this.POST(i,{ToUserId:t,Text:e,Subject:s,ParentId:a});return null!=n?n:null}return null}async markMessageAsRead({MessageId:t,MessageTypeId:e}){if(this.isSinged){const s=this.url("/messages/MarkMessageAsRead",api.LBC),a=await this.POST(s,{MessageId:t,MessageTypeId:e});return null!=a?a:null}return null}async deleteMessage({MessageId:t,MessageTypeId:e}){if(this.isSinged){const s=this.url("/messages/DeleteMessage",api.LBC),a=await this.POST(s,{MessageId:t,MessageTypeId:e});return null!=a?a:null}return null}async deleteMessagesAll(){if(this.isSinged){const t=this.url("/messages/DeleteAllMessages",api.LBC),e=await this.POST(t,{});return null!=e?e:null}return null}async getMessagesCount(){if(this.isSinged){const t=this.url("/messages/GetMessagesCount",api.LBC),e=await this.GET(t,{});return null!=e?e:null}return null}async getMessagesUnreadCount(){if(this.isSinged){const t=this.url("/messages/GetCountUnreadMessages",api.LBC),e=await this.GET(t,{});return null!=e?e:null}return null}async isUserTempExist(t){const e=this.url("/account/IsUserExistsInTemp",api.LBC),{data:s}=await this.request(e).query({userName:t}).exec();return null!=s?s:null}async createUserTemp(t){var e,s;const a=this.url(`/account/${this.locale}/UserRegistrationOnlyInTepm`),{data:i}=await this.request(a).POST(t).exec(),n=null!==(s=null===(e=null==i?void 0:i.Data)||void 0===e?void 0:e._isSuccessful)&&void 0!==s?s:null;return null!=n?n:null}async getGamesListGR(t={platforms:"desktop"}){const e=this.url("/Softquo/GetGamesList",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).POST(t).exec();return this.responseHandlerData(s,a,i)}async getGameFrameUrlGR(t){const e=this.url("/Softquo/InitGame",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).query(t).exec();return this.responseHandlerData(s,a,i)}async pingApi(){const t=this.url("/account/Ping",api.LBC),{data:e,status:s,statusText:a}=await this.request(t).exec();return this.responseHandlerData(e,s,a)}async intgrGetGamesList(t){const e=this.url("/Games/GetGamesList",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).POST(t).exec();return this.responseHandlerData(s,a,i)}async intgrGetGameTypes(t){const e=this.url("/Games/GetGameTypes",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).POST().query({groupId:t}).exec();return this.responseHandlerData(s,a,i)}async intgrGetProvidersList(t){const e=this.url("/Games/GetGameProviders",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).POST().query({groupId:t}).exec();return this.responseHandlerData(s,a,i)}async intgrGetTopGames(t){const e=this.url("/Games/GetTopGames",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).POST().query({groupId:t}).exec();return this.responseHandlerData(s,a,i)}async intgrInitGame(t){const e=this.url("/Games/InitGame",api.DIRECT),{data:s,status:a,statusText:i}=await this.request(e).query(t).exec();return this.responseHandlerData(s,a,i)}async checkPromocode(t){}async activatePromocode(t){}async sendSms(t){}async signUpPhone(t){}async passwordRecoveryRequest(t){}async passwordRecoveryEmail(t){}async passwordSetNewByPhone(t){}async passwordSetNewByEmail(t){}async signUpEmail(t){}async getUserPersonalInfo(){}async sendPayment(t,e){}async setUserPersonalInfo(t){}async getGamesToken(t){}async getProviderHedlines(t){}async createTempSignUp({login:t,password:e}){}async setRemoteLanguage(t){return null!=t||(t=this.lang),await this.setLanguageRemoteLocale(t)}convertBonuses(t){let e=[];return Object.keys(t).forEach((s=>{const a=s.match(/B_Koef(\d)_Value/);if(a){const s=a[1];e.push(["Koef",t[`B_Koef${s}`],t[`B_Koef${s}_Value`]])}const i=s.match(/B_Kolvo(\d)_Value/);if(i){const s=i[1];e.push(["Kolvo",t[`B_Kolvo${s}`],t[`B_Kolvo${s}_Value`]])}"B_Perestavka_Value"===s&&e.push(["Perestavka",!0,t.B_Perestavka_Value]),"B_MinOdds"===s&&e.push(["MinOdds",!0,t.B_MinOdds])})),e}async getBetslip_OLD(){var t,e;const s=this.url("/betting/GetBetslip",api.LBC),a=await this.GET(s,{});return a.bonuses=this.convertBonuses(null!==(t=null==a?void 0:a.Bonus)&&void 0!==t?t:{}),null!==(e=a.Bets)&&void 0!==e||(a.Bets=[]),delete a.Bonus,null!=a?a:{}}async getBetslip(){var t,e;const s=this.url("/betting/GetBetslip",api.LBC);let{data:a,status:i,statusText:n}=await this.request(s).exec();return null!=a||(a={}),a.bonuses=this.convertBonuses(null!==(t=null==a?void 0:a.Bonus)&&void 0!==t?t:{}),null!==(e=a.Bets)&&void 0!==e||(a.Bets=[]),delete a.Bonus,a}async clearBetslip(){const t=this.url("/betting/ClearBetslip",api.LBC),e=await this.POST(t);return null!=e&&e}async changeBetslipType(t){const e=this.url("/betting/ChangeBetslipType",api.LBC),s=await this.POST(e,{},{betslipType:t});return null!=s&&s}async setBetslipSettings(t){if(this.isSinged){const e=this.url("/betting/SetBetslipSettings",api.LBC),s=await this.POST(e,t);return null!=s?s:[]}return[]}async addToBetslip(t){t.culture=this.locale;const e=this.url("/betting/AddToBetslip",api.LBC),s=await this.POST(e,t);return null!=s?s:null}async removeFromBetslip(t){t.culture=this.locale;const e=this.url("/betting/RemoveFromBetslip",api.LBC);return await this.POST(e,t)||!1}async removeBonus(){const t=this.url("/betting/DeleteBonus",api.LBC),e=await this.POST(t);return null!=e&&e}async addBonus(t){const e=this.url("/betting/AddBonus",api.LBC),s=await this.POST(e,{},{odd:t});return null!=s?s:null}async updateBet(t){t.culture=this.locale;const e=this.url("/betting/UpdateBet",api.LBC);return null===await this.POST(e,t)}async getBetsLimits(){if(this.isSinged){const t=this.url("/betting/GetLimitations",api.LBC),e=await this.GET(t);return null!=e?e:{Min:0,Max:0}}return{Min:0,Max:0}}async getBetsLimitsNew(){var t,e,s;if(this.isSinged){const a=this.url("/betting/GetLimitations",api.LBC),{data:i,status:n,statusText:r}=await this.request(a).exec(),l={Min:null!==(t=null==i?void 0:i.Min)&&void 0!==t?t:0,Max:null!==(e=null==i?void 0:i.Max)&&void 0!==e?e:0,MaxOddForMulty:null!==(s=null==i?void 0:i.MaxOddForMulty)&&void 0!==s?s:250};return this.responseHandlerData(l,n,r)}return{data:{Min:0,Max:0,MaxOddForMulty:250},status:200,statusText:"OK"}}async getCurrencies(){if(this.isSinged){const t=this.url("/location/GetCurrencies",api.V2),e=await this.GET(t);return null!=e?e:[]}return null}async getCountries(){if(this.isSinged){const t=this.url("/location/GetCountries",api.V2),e=await this.GET(t);return null!=e?e:[]}return null}async getAllKeys(t){const e=this.url("/info/GetAllKeys",api.LBC),s=await this.GET(e,{key:t,culture:this.locale});return null!=s?s:[]}async getSlides(t){null!=t||(t="https://f004.backblazeb2.com/file/betroute/slides.json");const e=this.url(t),{data:s,status:a,statusText:i}=await this.request(e).deleteAllHeaders().exec();return this.responseHandlerData(s,a,i)}async getEventStatisticData(t){const e=this.url(`/stats/data/${t}/${this.locale}`,api.NV20),{data:s,status:a,statusText:i}=await this.request(e).exec();return this.responseHandlerData(s,a,i)}async getEventStatisticPage(t){const e=this.url(`/stats/page/${t}/${this.locale}`,api.NV20),{data:s,status:a,statusText:i}=await this.request(e).exec();return this.responseHandlerData(s,a,i)}async searchPrematchEventsNv20(t,e={}){var s;const a=this.url("/stats/pm/search",api.NV20);t=null!==(s=null==e?void 0:e.searchString)&&void 0!==s?s:t.split(/\s+/).filter((t=>!0!==/\d/.test(t)&&t.length>1)).join(" ").trim();const i=Object.assign(Object.assign(Object.assign(Object.assign({locale:this.locale,searchString:t},(null==e?void 0:e.LIMIT)?{LIMIT:e.LIMIT}:{LIMIT:{from:0,size:30}}),(null==e?void 0:e.negativeString)?{negativeString:e.negativeString}:{}),(null==e?void 0:e.sportId)?{sportId:e.sportId}:{}),(null==e?void 0:e.tournamentId)?{tournamentId:e.tournamentId}:{}),{data:n,status:r,statusText:l}=await this.request(a).POST(i).exec();return n.searchString=t,n.from=i.LIMIT.from,n.size=i.LIMIT.size,this.responseHandlerData(n,r,l)}async searchPrematchEventsIdsNv20(t){var e,s;const a=this.url("/stats/pm/search/ids",api.NV20);null!==(e=t.locale)&&void 0!==e||(t.locale=this.locale),null!==(s=t.LIMIT)&&void 0!==s||(t.LIMIT={from:0,size:30});const{data:i,status:n,statusText:r}=await this.request(a).POST(t).exec();return i.from=t.LIMIT.from,i.size=t.LIMIT.size,this.responseHandlerData(i,n,r)}async searchPrematchTournametsEventsNv20(t,e={}){var s,a,i;const{data:n,status:r,statusText:l}=await this.searchPrematchEventsNv20(t,e),o=(null!==(s=null==n?void 0:n.documents)&&void 0!==s?s:[]).reduce(((t,e)=>{const s=e.EventKeys.TurnirID;return t[s]||(t[s]=[]),t[s].push(e),t}),{}),u={tournaments:Object.entries(o).map((([t,e])=>({Id:t,Name:e[0].TourneyName.trim(),SportName:e[0].SportName,SportID:e[0].EventKeys.SportID,EventsHeaders:e}))),total:null!==(a=null==n?void 0:n.total)&&void 0!==a?a:0,searchString:null!==(i=null==n?void 0:n.searchString)&&void 0!==i?i:""};return this.responseHandlerData(u,r,l)}async sendErrInfo(t,e){const s=this.url("/err/send/front",api.NV20),{data:a,status:i,statusText:n}=await this.request(s).POST({text:t,code:e}).exec();return this.responseHandlerData(null==a?void 0:a.ok,i,n)}async cloneBetCoupon(t){var e,s;const a=this.url("/betting/TryGetBetCopy",api.LBC);null!==(e=t.betId)&&void 0!==e||(t.betId=null),null!==(s=t.code)&&void 0!==s||(t.code=null),t.culture=this.locale;const{data:i,status:n,statusText:r}=await this.request(a).query(t).exec();return this.responseHandlerData(i,n,r)}async getAllBanners(){const t=this.url("/info/GetAllBanners",api.LBC),e=await this.GET(t,{culture:this.locale});return null!=e?e:[]}async depositBetKiosk(t){const e=this.url("/betting/DepositMoneyBetshopPlayer",api.LBC),{data:s,status:a,statusText:i}=await this.request(e).query({sum:t}).exec();return this.responseHandlerData(s,a,i)}async getFaq(){const t=this.url("/info/GetFaq",api.LBC),e=await this.GET(t,{culture:this.locale});return null!=e?e:[]}async getFlatpagesList(){return[]}async test3(){return"test3 Ok"}async sellBet(t){}convertBasketToPost(t){return{a1:t.Add1,a2:t.Add2,bId:t.BetVarID,eId:t.LinesID,fs:t.HandSize,isLive:t.IsLive,r:t.Odds}}} //# sourceMappingURL=BetBoosterApi.min.js.map