crowous
Version:
A wrapper for the Crous Mobile internal API.
1 lines • 10.9 kB
JavaScript
import{t as e,rename as t,deserializeWith as o,u as r,deserialize as i}from"desero";import{HttpRequest as n,send as a}from"schwi";var s=Object.defineProperty,l=(e,t)=>s(e,"name",{value:t,configurable:!0}),c="http://webservices-v2.crous-mobile.fr/feed/";function p(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}l(p,"_ts_decorate");var d=class{static{l(this,"Article")}category=e.string();content=e.string();id=e.string();imageUrl=e.string();publishedAt=e.instance();title=e.string()};function u(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}p([t("image")],d.prototype,"imageUrl",void 0),p([o(e=>new Date(e)),t("date")],d.prototype,"publishedAt",void 0),l(u,"_ts_decorate");var f=class{static{l(this,"Contact")}email=e.option(e.string());phone=e.string()};u([o(r.falsyToNull)],f.prototype,"email",void 0),u([t("tel")],f.prototype,"phone",void 0);var y=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 g(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}l(g,"_ts_decorate");var v=class{static{l(this,"Feed")}identifier=e.string();isDefault=e.boolean();name=e.string();getNews(){return A(this.identifier)}getResidences(){return L(this.identifier)}getRestaurants(){return B(this.identifier)}getServices(){return $(this.identifier)}};function m(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}g([o(e=>e.split("/")[4]),t("url")],v.prototype,"identifier",void 0),g([t("is_default")],v.prototype,"isDefault",void 0),g([o(e=>e.replace("FLUX ",""))],v.prototype,"name",void 0),l(m,"_ts_decorate");var h=class{static{l(this,"FoodCategory")}dishes=e.array(e.string());name=e.string()};function b(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}m([o(r.pick("name"))],h.prototype,"dishes",void 0),l(b,"_ts_decorate");var R=class{static{l(this,"Image")}description=e.string();href=e.option(e.string())};function w(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}b([t("alt")],R.prototype,"description",void 0),b([o(r.falsyToNull),t("src")],R.prototype,"href",void 0),l(w,"_ts_decorate");var j=class{static{l(this,"Meal")}categories=e.array(e.reference(h));information=null;moment=e.enum(T);static handleFoodCategories(e,t){return e.map(e=>i(h,e)).filter(e=>"informations"!==e.name&&"Fermeture"!==e.name||(null===t.information&&(t.information=e.dishes[0]),!1))}};function O(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}w([o(j.handleFoodCategories),t("foodcategory")],j.prototype,"categories",void 0),w([t("name")],j.prototype,"moment",void 0),l(O,"_ts_decorate");var _=class{static{l(this,"Menu")}date=e.instance();meals=e.array(e.reference(j))};O([o(e=>new Date(e))],_.prototype,"date",void 0),O([t("meal")],_.prototype,"meals",void 0);var T=function(e){return e.Evening="soir",e.Lunch="midi",e.Morning="matin",e}({}),P=function(e){return e.Card="Carte bancaire",e.Cash="Espèce",e.Izly="IZLY",e.Moneo="Monéo",e}({});function S(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}l(S,"_ts_decorate");var N=class{static{l(this,"Residence")}address=e.option(e.string());albumUrl=e.option(e.string());appointmentUrl=e.option(e.string());area=e.string();bookingUrl=e.option(e.string());contact=e.string();crousAndGoUrl=e.option(e.string());description=e.option(e.string());email=e.string();fullInformation=e.string();id=e.string();images=e.array(e.string());inHomeServices=e.array(e.string());latitude=e.number();localServices=e.string();longitude=e.number();phone=e.option(e.string());title=e.string();troubleshootingUrl=e.option(e.string());virtualVisitUrl=e.option(e.string());websiteUrl=e.option(e.string())};function U(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}S([o(r.falsyToNull)],N.prototype,"address",void 0),S([o(r.falsyToNull)],N.prototype,"albumUrl",void 0),S([o(r.falsyToNull)],N.prototype,"appointmentUrl",void 0),S([t("zone")],N.prototype,"area",void 0),S([o(r.falsyToNull)],N.prototype,"bookingUrl",void 0),S([o(r.falsyToNull)],N.prototype,"crousAndGoUrl",void 0),S([o(r.falsyToNull),t("short_desc")],N.prototype,"description",void 0),S([t("mail")],N.prototype,"email",void 0),S([t("infos")],N.prototype,"fullInformation",void 0),S([o(e=>"object"==typeof e?e.url:[])],N.prototype,"images",void 0),S([o(e=>"object"==typeof e?e.house_service:[]),t("house_services")],N.prototype,"inHomeServices",void 0),S([o(parseFloat),t("lat")],N.prototype,"latitude",void 0),S([t("services")],N.prototype,"localServices",void 0),S([o(parseFloat),t("lon")],N.prototype,"longitude",void 0),S([o(r.falsyToNull)],N.prototype,"phone",void 0),S([o(r.falsyToNull)],N.prototype,"troubleshootingUrl",void 0),S([o(r.falsyToNull)],N.prototype,"virtualVisitUrl",void 0),S([o(r.falsyToNull),t("internetUrl")],N.prototype,"websiteUrl",void 0),l(U,"_ts_decorate");var D=class{static{l(this,"Restaurant")}access=e.option(e.string());accessibility=e.boolean();address=e.string();album=e.option(e.reference(R));area=e.string();closing=e.string();contact=e.reference(f);crousAndGoUrl=e.option(e.string());description=e.string();id=e.number();kind=e.enum(F);latitude=e.option(e.number());longitude=e.option(e.number());menus=e.array(e.reference(_));opening=e.string();operationalHours=e.option(e.string());paymentMethods=e.array(e.enum(P));photo=e.option(e.reference(R));shortDescription=e.string();title=e.string();wifi=e.boolean();getMeals(e){return this.menus.find(t=>t.date.getDate()===e.getDate()&&t.date.getMonth()===e.getMonth())?.meals??null}isOpen(e,t){let o;o=e instanceof Date?e.getDay():e;const r=t===T.Morning?0:t===T.Lunch?1:2;return"1"===this.opening.split(",")[o][r]}};U([o(r.falsyToNull)],D.prototype,"access",void 0),U([t("adresse")],D.prototype,"address",void 0),U([o(r.falsyToNull)],D.prototype,"album",void 0),U([o(r.falsyToNull),t("crousandgo")],D.prototype,"crousAndGoUrl",void 0),U([t("type")],D.prototype,"kind",void 0),U([o(r.falsyToNull),t("lat")],D.prototype,"latitude",void 0),U([o(r.falsyToNull),t("lon")],D.prototype,"longitude",void 0),U([t("operationalhours")],D.prototype,"operationalHours",void 0),U([o(r.pick("name")),t("payment")],D.prototype,"paymentMethods",void 0),U([t("shortdesc")],D.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 M(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a}l(M,"_ts_decorate");var C=class{static{l(this,"Service")}description=e.option(e.string());id=e.string();imageUrl=e.string();title=e.string();url=e.string()};async function k(){const e=new n.Builder(c+"feeds.json").build(),t=await a(e);return(await t.toJSON()).results.map(e=>i(v,e))}async function A(e){const t=new n.Builder(c+`${e}/externe/actu.xml`).build(),o=await a(t);return(await o.toXML()).root.article.map(e=>i(d,e))}async function L(e){const t=new n.Builder(c+`${e}/${e}-logement.xml`).build(),o=await a(t);return(await o.toXML()).root.residence.map(e=>i(N,e))}async function B(e){const t=new n.Builder(c+`${e}/externe/crous-${e}.min.json`).build(),o=await a(t);let r=await o.toString();r=r.replace(/[\u0000-\u001F]/g,"");const{restaurants:s}=JSON.parse(r);return s.map(e=>i(D,e))}async function $(e){const t=new n.Builder(c+`${e}/${e}-online.xml`).build(),o=await a(t);return(await o.toXML()).root.online.map(e=>i(C,e))}M([o(r.falsyToNull),t("short_desc")],C.prototype,"description",void 0),M([t("image")],C.prototype,"imageUrl",void 0),M([t("link")],C.prototype,"url",void 0),l(k,"getFeeds"),l(A,"getNewsFrom"),l(L,"getResidencesFrom"),l(B,"getRestaurantsFrom"),l($,"getServicesFrom");export{d as Article,f as Contact,y as Day,v as Feed,h as FoodCategory,R as Image,j as Meal,_ as Menu,T as Moment,P as PaymentMethod,N as Residence,D as Restaurant,F as RestaurantKind,C as Service,k as getFeeds,A as getNewsFrom,L as getResidencesFrom,B as getRestaurantsFrom,$ as getServicesFrom};//# sourceMappingURL=index.mjs.map