UNPKG

crowous

Version:

A wrapper for the Crous Mobile internal API.

1 lines 12 kB
"use strict";var e=require("desero"),t=require("schwi"),r=Object.defineProperty,o=(e,t)=>r(e,"name",{value:t,configurable:!0}),i="http://webservices-v2.crous-mobile.fr/feed/";function n(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}o(n,"_ts_decorate");var a=class{static{o(this,"Article")}category=e.t.string();content=e.t.string();id=e.t.string();imageUrl=e.t.string();publishedAt=e.t.instance();title=e.t.string()};function s(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}n([e.rename("image")],a.prototype,"imageUrl",void 0),n([e.deserializeWith(e=>new Date(e)),e.rename("date")],a.prototype,"publishedAt",void 0),o(s,"_ts_decorate");var l=class{static{o(this,"Contact")}email=e.t.option(e.t.string());phone=e.t.string()};s([e.deserializeWith(e.u.falsyToNull)],l.prototype,"email",void 0),s([e.rename("tel")],l.prototype,"phone",void 0);var c=function(e){return e[e.Friday=4]="Friday",e[e.Monday=0]="Monday",e[e.Saturday=5]="Saturday",e[e.Sunday=6]="Sunday",e[e.Thursday=3]="Thursday",e[e.Tuesday=1]="Tuesday",e[e.Wednesday=2]="Wednesday",e}({});function d(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}o(d,"_ts_decorate");var p=class{static{o(this,"Feed")}identifier=e.t.string();isDefault=e.t.boolean();name=e.t.string();getNews(){return P(this.identifier)}getResidences(){return T(this.identifier)}getRestaurants(){return N(this.identifier)}getServices(){return U(this.identifier)}};function u(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}d([e.deserializeWith(e=>e.split("/")[4]),e.rename("url")],p.prototype,"identifier",void 0),d([e.rename("is_default")],p.prototype,"isDefault",void 0),d([e.deserializeWith(e=>e.replace("FLUX ",""))],p.prototype,"name",void 0),o(u,"_ts_decorate");var f=class{static{o(this,"FoodCategory")}dishes=e.t.array(e.t.string());name=e.t.string()};function y(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}u([e.deserializeWith(e.u.pick("name"))],f.prototype,"dishes",void 0),o(y,"_ts_decorate");var g=class{static{o(this,"Image")}description=e.t.string();href=e.t.option(e.t.string())};function m(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}y([e.rename("alt")],g.prototype,"description",void 0),y([e.deserializeWith(e.u.falsyToNull),e.rename("src")],g.prototype,"href",void 0),o(m,"_ts_decorate");var h=class{static{o(this,"Meal")}categories=e.t.array(e.t.reference(f));information=null;moment=e.t.enum(R);static handleFoodCategories(t,r){return t.map(t=>e.deserialize(f,t)).filter(e=>"informations"!==e.name&&"Fermeture"!==e.name||(null===r.information&&(r.information=e.dishes[0]),!1))}};function v(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}m([e.deserializeWith(h.handleFoodCategories),e.rename("foodcategory")],h.prototype,"categories",void 0),m([e.rename("name")],h.prototype,"moment",void 0),o(v,"_ts_decorate");var b=class{static{o(this,"Menu")}date=e.t.instance();meals=e.t.array(e.t.reference(h))};v([e.deserializeWith(e=>new Date(e))],b.prototype,"date",void 0),v([e.rename("meal")],b.prototype,"meals",void 0);var R=function(e){return e.Evening="soir",e.Lunch="midi",e.Morning="matin",e}({}),z=function(e){return e.Card="Carte bancaire",e.Cash="Espèce",e.Izly="IZLY",e.Moneo="Monéo",e}({});function w(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}o(w,"_ts_decorate");var j=class{static{o(this,"Residence")}address=e.t.option(e.t.string());albumUrl=e.t.option(e.t.string());appointmentUrl=e.t.option(e.t.string());area=e.t.string();bookingUrl=e.t.option(e.t.string());contact=e.t.string();crousAndGoUrl=e.t.option(e.t.string());description=e.t.option(e.t.string());email=e.t.string();fullInformation=e.t.string();id=e.t.string();images=e.t.array(e.t.string());inHomeServices=e.t.array(e.t.string());latitude=e.t.number();localServices=e.t.string();longitude=e.t.number();phone=e.t.option(e.t.string());title=e.t.string();troubleshootingUrl=e.t.option(e.t.string());virtualVisitUrl=e.t.option(e.t.string());websiteUrl=e.t.option(e.t.string())};function O(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"address",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"albumUrl",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"appointmentUrl",void 0),w([e.rename("zone")],j.prototype,"area",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"bookingUrl",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"crousAndGoUrl",void 0),w([e.deserializeWith(e.u.falsyToNull),e.rename("short_desc")],j.prototype,"description",void 0),w([e.rename("mail")],j.prototype,"email",void 0),w([e.rename("infos")],j.prototype,"fullInformation",void 0),w([e.deserializeWith(e=>"object"==typeof e?e.url:[])],j.prototype,"images",void 0),w([e.deserializeWith(e=>"object"==typeof e?e.house_service:[]),e.rename("house_services")],j.prototype,"inHomeServices",void 0),w([e.deserializeWith(parseFloat),e.rename("lat")],j.prototype,"latitude",void 0),w([e.rename("services")],j.prototype,"localServices",void 0),w([e.deserializeWith(parseFloat),e.rename("lon")],j.prototype,"longitude",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"phone",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"troubleshootingUrl",void 0),w([e.deserializeWith(e.u.falsyToNull)],j.prototype,"virtualVisitUrl",void 0),w([e.deserializeWith(e.u.falsyToNull),e.rename("internetUrl")],j.prototype,"websiteUrl",void 0),o(O,"_ts_decorate");var W=class{static{o(this,"Restaurant")}access=e.t.option(e.t.string());accessibility=e.t.boolean();address=e.t.string();album=e.t.option(e.t.reference(g));area=e.t.string();closing=e.t.string();contact=e.t.reference(l);crousAndGoUrl=e.t.option(e.t.string());description=e.t.string();id=e.t.number();kind=e.t.enum(F);latitude=e.t.option(e.t.number());longitude=e.t.option(e.t.number());menus=e.t.array(e.t.reference(b));opening=e.t.string();operationalHours=e.t.option(e.t.string());paymentMethods=e.t.array(e.t.enum(z));photo=e.t.option(e.t.reference(g));shortDescription=e.t.string();title=e.t.string();wifi=e.t.boolean();getMeals(e){return this.menus.find(t=>t.date.getDate()===e.getDate()&&t.date.getMonth()===e.getMonth())?.meals??null}isOpen(e,t){let r;r=e instanceof Date?e.getDay():e;const o=t===R.Morning?0:t===R.Lunch?1:2;return"1"===this.opening.split(",")[r][o]}};O([e.deserializeWith(e.u.falsyToNull)],W.prototype,"access",void 0),O([e.rename("adresse")],W.prototype,"address",void 0),O([e.deserializeWith(e.u.falsyToNull)],W.prototype,"album",void 0),O([e.deserializeWith(e.u.falsyToNull),e.rename("crousandgo")],W.prototype,"crousAndGoUrl",void 0),O([e.rename("type")],W.prototype,"kind",void 0),O([e.deserializeWith(e.u.falsyToNull),e.rename("lat")],W.prototype,"latitude",void 0),O([e.deserializeWith(e.u.falsyToNull),e.rename("lon")],W.prototype,"longitude",void 0),O([e.rename("operationalhours")],W.prototype,"operationalHours",void 0),O([e.deserializeWith(e.u.pick("name")),e.rename("payment")],W.prototype,"paymentMethods",void 0),O([e.rename("shortdesc")],W.prototype,"shortDescription",void 0);var F=function(e){return e.AdministrativeRestaurant="Restaurant administratif",e.ApprovedRestaurant="Restaurant agréé",e.Brewery="Brasserie",e.Cafeteria="Cafétéria",e.CoffeeCorner="Coffee Corner",e.CrousAndGo="crous and go",e.FoodTruck="Foodtruck",e.GroceryStore="épicerie",e.Kiosk="Kiosque",e.ManagedRestaurant="Restaurant géré",e.Pizzeria="Pizzéria",e.Restaurant="Restaurant",e.SandwichShop="Sandwicherie",e.Scooter="Triporteur",e.SelfService="Libre-service",e.Space="Space",e}({});function S(e,t,r,o){var i,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,r,a):i(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}o(S,"_ts_decorate");var _=class{static{o(this,"Service")}description=e.t.option(e.t.string());id=e.t.string();imageUrl=e.t.string();title=e.t.string();url=e.t.string()};async function x(){const r=new t.HttpRequest.Builder(i+"feeds.json").build(),o=await t.send(r);return(await o.toJSON()).results.map(t=>e.deserialize(p,t))}async function P(r){const o=new t.HttpRequest.Builder(i+`${r}/externe/actu.xml`).build(),n=await t.send(o);return(await n.toXML()).root.article.map(t=>e.deserialize(a,t))}async function T(r){const o=new t.HttpRequest.Builder(i+`${r}/${r}-logement.xml`).build(),n=await t.send(o);return(await n.toXML()).root.residence.map(t=>e.deserialize(j,t))}async function N(r){const o=new t.HttpRequest.Builder(i+`${r}/externe/crous-${r}.min.json`).build(),n=await t.send(o);let a=await n.toString();a=a.replace(/[\u0000-\u001F]/g,"");const{restaurants:s}=JSON.parse(a);return s.map(t=>e.deserialize(W,t))}async function U(r){const o=new t.HttpRequest.Builder(i+`${r}/${r}-online.xml`).build(),n=await t.send(o);return(await n.toXML()).root.online.map(t=>e.deserialize(_,t))}S([e.deserializeWith(e.u.falsyToNull),e.rename("short_desc")],_.prototype,"description",void 0),S([e.rename("image")],_.prototype,"imageUrl",void 0),S([e.rename("link")],_.prototype,"url",void 0),o(x,"getFeeds"),o(P,"getNewsFrom"),o(T,"getResidencesFrom"),o(N,"getRestaurantsFrom"),o(U,"getServicesFrom"),exports.Article=a,exports.Contact=l,exports.Day=c,exports.Feed=p,exports.FoodCategory=f,exports.Image=g,exports.Meal=h,exports.Menu=b,exports.Moment=R,exports.PaymentMethod=z,exports.Residence=j,exports.Restaurant=W,exports.RestaurantKind=F,exports.Service=_,exports.getFeeds=x,exports.getNewsFrom=P,exports.getResidencesFrom=T,exports.getRestaurantsFrom=N,exports.getServicesFrom=U;//# sourceMappingURL=index.js.map