From 44c550013c99f7d93fe0309c7afec6a6056f633b Mon Sep 17 00:00:00 2001 From: Robin Guinant Date: Thu, 15 Jun 2023 14:29:27 +0200 Subject: [PATCH] feat!: add authentication - Add authentication support - Rename types - Rename methods --- README.md | 44 +++---- index.ts | 1 + .../{accessibilite.ts => accessibility.ts} | 29 ++--- methods/activite.ts | 39 ------- methods/activity.ts | 41 +++++++ methods/{erp.ts => establishment.ts} | 19 ++-- methods/index.ts | 6 +- types/accessibilite.ts | 107 ------------------ types/accessibility.ts | 105 +++++++++++++++++ types/activite.ts | 9 -- types/activity.ts | 11 ++ types/erp.ts | 32 ------ types/establishment.ts | 44 +++++++ types/index.ts | 6 +- utils/{accessibilite.ts => accessibility.ts} | 8 +- utils/{erp.ts => establishment.ts} | 6 +- utils/index.ts | 4 +- 17 files changed, 269 insertions(+), 242 deletions(-) rename methods/{accessibilite.ts => accessibility.ts} (50%) delete mode 100644 methods/activite.ts create mode 100644 methods/activity.ts rename methods/{erp.ts => establishment.ts} (64%) delete mode 100644 types/accessibilite.ts create mode 100644 types/accessibility.ts delete mode 100644 types/activite.ts create mode 100644 types/activity.ts delete mode 100644 types/erp.ts create mode 100644 types/establishment.ts rename utils/{accessibilite.ts => accessibility.ts} (80%) rename utils/{erp.ts => establishment.ts} (85%) diff --git a/README.md b/README.md index ef59f21..5e20096 100644 --- a/README.md +++ b/README.md @@ -21,25 +21,29 @@ En utilisant yarn: Node.js : ```javascript -const { getErps } = require("acceslibre-client"); +const { getEstablishments } = require("acceslibre-client"); + +const API_KEY = "YOUR_KEY" (async () => { - const erps = await getErps({ page: 1 }); + const erps = await getEstablishments(API_KEY, { page: 1 }); ) ``` React (Js) : ```js -import { getErps } from "acceslibre-client"; +import { getEstablishments } from "acceslibre-client"; import { useEffect, useState } from "react"; +const API_KEY = "YOUR_KEY"; + function App() { const [erps, setErps] = useState(undefined); useEffect(() => { (async () => { - const erps = await getErps(); + const erps = await getEstablishments(API_KEY); setErps(erps); })(); }, []); @@ -78,25 +82,25 @@ export default App; Obtenir une liste d'activités d'ERP : ```ts -const activities = await getActivites(); +const activities = await getActivities(API_KEY); ``` Obtenir une activité particulière par le biais de son slug : ```ts -const activity = await readActivite("accessoires"); +const activity = await readActivity(API_KEY, "accessoires"); ``` Demander une page spécifique d'une liste d'activités : ```ts -const activities = await getActivites({ page: 2 }); +const activities = await getActivities(API_KEY, { page: 2 }); ``` Récupérer la activités de l'ensemble des ERP de la ville de Bordeaux : ```ts -const activities = await getActivities({ commune: "Bordeaux" }); +const activities = await getActivities(API_KEY, { commune: "Bordeaux" }); ``` ### ERPs : @@ -106,31 +110,31 @@ const activities = await getActivities({ commune: "Bordeaux" }); Obtenir une liste d'ERP : ```ts -const erps = await getErps(); +const erps = await getEstablishments(API_KEY); ``` Obtenir un ERP en particulier par le biais de son slug : ```ts -const erp = await readErp("acdp-formation-82"); +const erp = await readEstablishment(API_KEY, "acdp-formation-82"); ``` Demander une page spécifique d'une liste d'ERP : ```ts -const erps = await getErps({ page: 2 }); +const erps = await getEstablishments(API_KEY, { page: 2 }); ``` Rechercher les ERPs contenant le terme "impôts" dans leur nom ou activité : ```ts -const erps = await getErps({ q: "impôts" }); +const erps = await getEstablishments(API_KEY, { q: "impôts" }); ``` Récupérer les ERPs de la ville de Bordeaux : ```ts -const erps = await getErps({ commune: "Bordeaux" }); +const erps = await getEstablishments(API_KEY, { commune: "Bordeaux" }); ``` La liste complète des paramètres de `getErps()` est disponible dans la [Documentation de l'API](https://acceslibre.beta.gouv.fr/api/docs/). @@ -142,19 +146,19 @@ La liste complète des paramètres de `getErps()` est disponible dans la [Docume Obtenir une liste des critères d'accessibilité de plusieurs ERPs : ```ts -const erpsRequirements = await getAccessibilites(); +const erpsRequirements = await getAccessibilites(API_KEY); ``` Obtenir les critères d'accessibilité d'un ERP spécifique en utilisant le slug d'un critère : ```ts -const requirements = await readAccessibilite("1234"); +const requirements = await readAccessibilite(API_KEY, "1234"); ``` Demander une page spécifique d'une liste des critères d'accessibilité d'ERPs : ```ts -const erpsRequirements = await getAccessibilites({ page: 1 }); +const erpsRequirements = await getAccessibilites(API_KEY, { page: 1 }); ``` ### Utilitaires : @@ -164,10 +168,12 @@ Les utilitaires sont disponibles dans `acceslibre-client/dist/utils`. La méthode `readAccessibilite()` a besoin d'un `id` que vous pouvez récupérer dans l'url disponible via la propriété `accessibilite` du type `IErp`. ```ts -import { IErp, readErp, readAccessibilite } from "acceslibre-client"; -import { extractAccessibiliteSlugFromApiUrl } from "acceslibre-client/dist/utils"; +import { IEstablishment readEstablishment, readAccessibility } from "acceslibre-client"; +import { extractAccessibilitiesSlugFromApiUrl } from "acceslibre-client/dist/utils"; + +const API_KEY = "YOUR_KEY" -const erp: IErp | null = await readErp("erp-slug"); +const erp: IEstablishment | null = await readEstablishment("erp-slug"); if (erp !== null) { const requirementsId = extractAccessibiliteSlugFromApiUrl(erp.accessibilite); if (requirementsId !== null) { diff --git a/index.ts b/index.ts index a22e9dd..ba56fb4 100644 --- a/index.ts +++ b/index.ts @@ -1,2 +1,3 @@ export * from "./types"; export * from "./methods"; +export * from "./utils"; diff --git a/methods/accessibilite.ts b/methods/accessibility.ts similarity index 50% rename from methods/accessibilite.ts rename to methods/accessibility.ts index 941a338..6afa0dd 100644 --- a/methods/accessibilite.ts +++ b/methods/accessibility.ts @@ -1,42 +1,43 @@ import axios from "axios"; -import { IAccessibilite, IAccessibilitePaginate } from "../types"; import { API_URL } from "../utils"; +import { IAccessibility, IPaginateAccessibilities } from "../types"; -interface IAccessibiliteOptions { +interface IAccessibilityOptions { /** A page number within the paginated result set. */ page?: number; - /** Écarter les valeurs nulles ou non-renseignées */ - // clean?: boolean - /** Formater les données d'accessibilité pour une lecture humaine */ - // readable?: boolean; + /** Number of results to return per page. */ + page_size?: number; } -/** Permer de récupérer une liste d'ERP. */ -export async function getAccessibilites(query: IAccessibiliteOptions = {}) { +/** Lists the accessibility criteria for establishments. */ +export async function getAccessibilites( + key: string, + query: IAccessibilityOptions = {} +) { try { - const r = await axios.get( + const r = await axios.get( `${API_URL}/accessibilite/`, { headers: { "Content-Type": "application/json", + Authorization: `Api-Key ${key}`, }, params: query, } ); return r.data; - } catch (error) { - return null; - } + } catch (error) {} } /* Permet de récupérer les données d'un ERP spécifique, par le biais de son id */ -export async function readAccessibilite(id: string) { +export async function readAccessibility(key: string, id: string) { try { - const r = await axios.get( + const r = await axios.get( `${API_URL}/accessibilite/${id}/`, { headers: { "Content-Type": "application/json", + Authorization: `Api-Key ${key}`, }, } ); diff --git a/methods/activite.ts b/methods/activite.ts deleted file mode 100644 index 337c15b..0000000 --- a/methods/activite.ts +++ /dev/null @@ -1,39 +0,0 @@ -import axios from "axios"; -import { IActivite, IActivitePaginate } from "../types"; -import { API_URL } from "../utils"; - -interface IActiviteOptions { - /** A page number within the paginated result set. */ - page?: number; - /** Nom de la commune (ex. Clichy) */ - commune?: string; -} - -/** Permer de récupérer une liste d'activités. */ -export async function getActivites(query: IActiviteOptions = {}) { - try { - const r = await axios.get(`${API_URL}/activites/`, { - headers: { - "Content-Type": "application/json", - }, - params: query, - }); - return r.data; - } catch (error) { - return null; - } -} - -/* Permet de récupérer les données d'une activité spécifique, par le biais de son slug */ -export async function readActivite(slug: string) { - try { - const r = await axios.get(`${API_URL}/activites/${slug}/`, { - headers: { - "Content-Type": "application/json", - }, - }); - return r.data; - } catch (error) { - return null; - } -} diff --git a/methods/activity.ts b/methods/activity.ts new file mode 100644 index 0000000..19b7ea2 --- /dev/null +++ b/methods/activity.ts @@ -0,0 +1,41 @@ +import axios from "axios"; +import { API_URL } from "../utils"; +import { IActivity, IEstablishment, IPaginateActivities } from "../types"; + +interface IActiviteOptions { + /** A page number within the paginated result set. */ + page?: number; + /** Name of the town (ex. Bordeaux) */ + commune?: string; +} + +/** Lists the activities of establishments. */ +export async function getActivities(key: string, query: IActiviteOptions = {}) { + try { + const r = await axios.get(`${API_URL}/activites/`, { + headers: { + "Content-Type": "application/json", + Authorization: `Api-Key ${key}`, + }, + params: query, + }); + return r.data; + } catch (error) { + return null; + } +} + +/** List the activities of an establishments. */ +export async function readActivity(key: string, slug: IActivity["slug"]) { + try { + const r = await axios.get(`${API_URL}/activites/${slug}/`, { + headers: { + "Content-Type": "application/json", + Authorization: `Api-Key ${key}`, + }, + }); + return r.data; + } catch (error) { + return null; + } +} diff --git a/methods/erp.ts b/methods/establishment.ts similarity index 64% rename from methods/erp.ts rename to methods/establishment.ts index d483ac6..ca2164f 100644 --- a/methods/erp.ts +++ b/methods/establishment.ts @@ -1,10 +1,12 @@ import axios from "axios"; -import { IErp, IErpPaginate } from "../types"; import { API_URL } from "../utils"; +import { IEstablishment, IPaginateEstablishments } from "../types"; interface IErpsOptions { /** A page number within the paginated result set. */ page?: number; + /** Number of results to return per page. */ + page_size?: number; /** Termes de recherche */ q?: string; /** Nom de la commune (ex. Clichy) */ @@ -21,18 +23,20 @@ interface IErpsOptions { source?: string; /** ID unique fourni par un fournisseur tier */ source_id?: string; + asp_id?: string; /** Identifiant unique OpenData */ uuid?: string; /** Biais de localisation géographique, au format `latitude,longitude` (par ex. `43.22,3.83`) */ around?: string; } -/** Permer de récupérer une liste d'ERP. */ -export async function getErps(query: IErpsOptions = {}) { +/** List of establishments. */ +export async function getEstablishments(key: string, query: IErpsOptions = {}) { try { - const r = await axios.get(`${API_URL}/erps/`, { + const r = await axios.get(`${API_URL}/erps/`, { headers: { "Content-Type": "application/json", + Authorization: `Api-Key ${key}`, }, params: query, }); @@ -42,12 +46,13 @@ export async function getErps(query: IErpsOptions = {}) { } } -/* Permet de récupérer les données d'un ERP spécifique, par le biais de son slug */ -export async function readErp(slug: string) { +/* Retrieve data from a specific establishment. */ +export async function readEstablishment(key: string, slug: string) { try { - const r = await axios.get(`${API_URL}/erps/${slug}/`, { + const r = await axios.get(`${API_URL}/erps/${slug}/`, { headers: { "Content-Type": "application/json", + Authorization: `Api-Key ${key}`, }, }); return r.data; diff --git a/methods/index.ts b/methods/index.ts index 195243b..c1188e9 100644 --- a/methods/index.ts +++ b/methods/index.ts @@ -1,3 +1,3 @@ -export * from "./accessibilite"; -export * from "./activite"; -export * from "./erp"; +export * from "./accessibility"; +export * from "./activity"; +export * from "./establishment"; diff --git a/types/accessibilite.ts b/types/accessibilite.ts deleted file mode 100644 index 90b30cf..0000000 --- a/types/accessibilite.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Paginate } from "../utils"; - -export interface IAccessibilite { - url: string; - erp: string; - labels: { - labels: Array<"autre" | "dpt" | "mobalib" | "th"> | null; - labels_familles_handicap: Array< - "auditif" | "mental" | "moteur" | "visuel" - > | null; - labels_autre: string | null; - }; - - transport: { - transport_station_presence: boolean | null; - transport_information: string | null; - }; - - stationnement: { - stationnement_presence: boolean | null; - stationnement_pmr: boolean | null; - stationnement_ext_presence: boolean | null; - stationnement_ext_pmr: boolean | null; - }; - - cheminement_ext: { - cheminement_ext_presence: boolean | null; - cheminement_ext_plain_pied: boolean | null; - cheminement_ext_terrain_stable: boolean | null; - cheminement_ext_nombre_marches: number | null; - cheminement_ext_sens_marches: "montant" | "descendant" | null; - cheminement_ext_reperage_marches: boolean | null; - cheminement_ext_main_courante: boolean | null; - cheminement_ext_rampe: "aucune" | "fixe" | "amovible" | null; - cheminement_ext_ascenseur: boolean | null; - cheminement_ext_pente_presence: boolean | null; - cheminement_ext_pente_degre_difficulte: "légère" | "importante" | null; - cheminement_ext_pente_longueur: "courte" | "moyenne" | "longue" | null; - cheminement_ext_devers: "aucun" | "léger" | "important"; - cheminement_ext_bande_guidage: boolean | null; - cheminement_ext_retrecissement: boolean | null; - }; - - entree: { - entree_reperage: boolean | null; - entree_porte_presence: boolean | null; - entree_porte_manoeuvre: - | "battante" - | "coulissante" - | "tourniquet" - | "tambour" - | null; - entree_porte_type: "manuelle" | "automatique" | null; - entree_vitree: boolean | null; - entree_vitree_vitrophanie: boolean | null; - entree_plain_pied: boolean | null; - entree_marches: number | null; - entree_marches_sens: "montant" | "descendant" | null; - entree_marches_reperage: boolean | null; - entree_marches_main_courante: boolean | null; - entree_marches_rampe: "aucune" | "fixe" | "amovible" | null; - entree_balise_sonore: boolean | null; - entree_dispositif_appel: boolean | null; - entree_dispositif_appel_type: Array< - "bouton" | "interphone" | "visiophone" - > | null; - entree_aide_humaine: boolean | null; - entree_ascenseur: boolean | null; - entree_largeur_mini: number | null; - entree_pmr: boolean | null; - entree_pmr_informations: string | null; - }; - - accueil: { - accueil_visibilite: boolean | null; - accueil_personnels: "aucun" | "formés" | "non-formés" | null; - accueil_equipements_malentendants_presence: boolean | null; - accueil_equipements_malentendants: Array< - "bim" | "bmp" | "lsf" | "lpc" | "sts" | "autres" - > | null; - accueil_cheminement_plain_pied: boolean | null; - accueil_cheminement_nombre_marches: number | null; - accueil_cheminement_sens_marches: "montant" | "descendant"; - accueil_cheminement_reperage_marches: boolean | null; - accueil_cheminement_main_courante: boolean | null; - accueil_cheminement_rampe: "aucune" | "fixe" | "amovible"; - accueil_cheminement_ascenseur: boolean | null; - accueil_retrecissement: boolean | null; - }; - - sanitaires: { - sanitaires_presence: boolean | null; - sanitaires_adaptes: boolean | null; - }; - - registre: { - registre_url: string | null; - }; - - conformite: { - conformite: boolean | null; - }; - - commentaire: string | null; -} - -export type IAccessibilitePaginate = Paginate; diff --git a/types/accessibility.ts b/types/accessibility.ts new file mode 100644 index 0000000..f1416fc --- /dev/null +++ b/types/accessibility.ts @@ -0,0 +1,105 @@ +import { Paginate } from "../utils"; + +export interface IAccessibility { + url: string; + erp: string; + transport: { + transport_station_presence: any; + transport_information: string | null; + stationnement_presence: any; + stationnement_pmr: any; + stationnement_ext_presence: any; + stationnement_ext_pmr: any; + }; + cheminement_ext: { + cheminement_ext_presence: any; + cheminement_ext_plain_pied: any; + cheminement_ext_terrain_stable: any; + cheminement_ext_nombre_marches: number | null; + cheminement_ext_sens_marches: any; + cheminement_ext_reperage_marches: any; + cheminement_ext_main_courante: any; + cheminement_ext_rampe: any; + cheminement_ext_ascenseur: any; + cheminement_ext_pente_presence: any; + cheminement_ext_pente_degre_difficulte: any; + cheminement_ext_pente_longueur: any; + cheminement_ext_devers: any; + cheminement_ext_bande_guidage: any; + cheminement_ext_retrecissement: any; + }; + entree: { + entree_reperage: any; + entree_porte_presence: boolean | null; + entree_porte_manoeuvre: any; + entree_porte_type: any; + entree_vitree: any; + entree_vitree_vitrophanie: any; + entree_plain_pied: any; + entree_marches: number | null; + entree_marches_sens: any; + entree_marches_reperage: any; + entree_marches_main_courante: any; + entree_marches_rampe: any; + entree_balise_sonore: any; + entree_dispositif_appel: any; + entree_dispositif_appel_type: Array< + "bouton" | "interphone" | "visiophone" + > | null; + entree_aide_humaine: any; + entree_ascenseur: any; + entree_largeur_mini: number | null; + entree_pmr: any; + entree_pmr_informations: string | null; + }; + accueil: { + accueil_visibilite: any; + accueil_personnels: any; + accueil_audiodescription_presence: any; + accueil_audiodescription: Array< + | "avec_équipement_permanent" + | "avec_app" + | "avec_équipement_occasionnel" + | "sans_équipement" + > | null; + accueil_equipements_malentendants_presence: any; + accueil_equipements_malentendants: Array< + "bim" | "bmp" | "lsf" | "lpc" | "sts" | "autres" + > | null; + accueil_cheminement_plain_pied: any; + accueil_cheminement_nombre_marches: number | null; + accueil_cheminement_sens_marches: any; + accueil_cheminement_reperage_marches: any; + accueil_cheminement_main_courante: any; + accueil_cheminement_rampe: any; + accueil_cheminement_ascenseur: any; + accueil_retrecissement: any; + accueil_chambre_nombre_accessibles: number | null; + accueil_chambre_douche_plain_pied: any; + accueil_chambre_douche_siege: any; + accueil_chambre_douche_barre_appui: any; + accueil_chambre_sanitaires_barre_appui: any; + accueil_chambre_sanitaires_espace_usage: any; + accueil_chambre_numero_visible: any; + accueil_chambre_equipement_alerte: any; + accueil_chambre_accompagnement: any; + sanitaires_presence: any; + sanitaires_adaptes: any; + }; + registre: { + registre_url: string | null; + }; + conformite: { + conformite: any; + }; + commentaire: { + labels: Array<"autre" | "dpt" | "mobalib" | "th"> | null; + labels_familles_handicap: Array< + "auditif" | "mental" | "moteur" | "visuel" + > | null; + labels_autre: string | null; + commentaire: string | null; + }; +} + +export type IPaginateAccessibilities = Paginate; diff --git a/types/activite.ts b/types/activite.ts deleted file mode 100644 index a30a09d..0000000 --- a/types/activite.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Paginate } from "../utils"; - -export interface IActivite { - nom: string; - slug: string; - count: number; -} - -export type IActivitePaginate = Paginate; diff --git a/types/activity.ts b/types/activity.ts new file mode 100644 index 0000000..9635809 --- /dev/null +++ b/types/activity.ts @@ -0,0 +1,11 @@ +import { Paginate } from "../utils"; + +export interface IActivity { + /** Activity name */ + nom: string; + /** URL identifier (slug) */ + slug: string; + count: number; +} + +export type IPaginateActivities = Paginate; diff --git a/types/erp.ts b/types/erp.ts deleted file mode 100644 index b8f67ee..0000000 --- a/types/erp.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Paginate } from "../utils"; - -export interface IErp { - url: string; - web_url: string; - uuid: string; - activite: { - nom: string; - slug: string; - }; - nom: string; - slug: string; - adresse: string; - commune: string; - code_insee: string; - geom: { - type: "Point"; - coordinates: [number, number]; - } | null; - siret: string | null; - telephone: string | null; - site_internet: string | null; - contact_email: string | null; - contact_url: string | null; - user_type: "admin" | "gestionnaire" | "public" | "system"; - /** URL to the accessibilite endpoint */ - accessibilite: string; - distance: string | null; - source_id: string | null; -} - -export type IErpPaginate = Paginate; diff --git a/types/establishment.ts b/types/establishment.ts new file mode 100644 index 0000000..c5c6258 --- /dev/null +++ b/types/establishment.ts @@ -0,0 +1,44 @@ +import { Paginate } from "../utils"; +import { IAccessibility } from "./accessibility"; + +export interface IEstablishment { + url: string; + web_url: string; + uuid: string; + activite: { + nom: string; + slug: string; + }; + /** Name of the establishment or sign */ + nom: string; + slug: string; + adresse: string; + commune: string; + code_insee: string | null; + code_postal: string; + geom: { + type: string; + coordinates: [number, number]; + } | null; + /** SIRET number if the establishment is a company */ + siret: string | null; + /** Phone number of the establishment */ + telephone: string | null; + /** Website of the establishment */ + site_internet: string | null; + /** Email address to contact the establishment */ + contact_email: string | null; + /** Hyperlink allowing to contact the establishment (form, chatbot, etc..) */ + contact_url: string | null; + user_type: "admin" | "gestionnaire" | "public" | "system"; + accessibilite: IAccessibility; + distance: string | null; + /** Establishment identifier in the initial data source */ + source_id: string | null; + /** Establishment identifier in the Service Public database */ + asp_id: string | null; + created_at: string; + updated_at: string; +} + +export type IPaginateEstablishments = Paginate; diff --git a/types/index.ts b/types/index.ts index 195243b..c1188e9 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,3 +1,3 @@ -export * from "./accessibilite"; -export * from "./activite"; -export * from "./erp"; +export * from "./accessibility"; +export * from "./activity"; +export * from "./establishment"; diff --git a/utils/accessibilite.ts b/utils/accessibility.ts similarity index 80% rename from utils/accessibilite.ts rename to utils/accessibility.ts index 8e2a0b5..b840c39 100644 --- a/utils/accessibilite.ts +++ b/utils/accessibility.ts @@ -3,13 +3,13 @@ import { urlRemoveQueryStrings } from "./url"; /** * Checks if a URL has the format of a valid Accessibilite api url. - * (eg. `https://acceslibre.beta.gouv.fr/api/accessibilite/16234/`) + * (eg. `https://acceslibre.beta.gouv.fr/api/accessibilite/132735/`) * * @param {string} url - The URL to validate. * * @returns A boolean. */ -export function isValidAccessibiliteApiUrl(url: string): boolean { +export function isValidAccessibilityApiUrl(url: string): boolean { let u: string = url.trim(); if (!u.startsWith(API_URL)) { return false; @@ -26,14 +26,14 @@ export function isValidAccessibiliteApiUrl(url: string): boolean { } /** - * Extract the slug from the api url of an Accessibilite. + * Extract the slug from the api url of an Accessibility. * * @param {string} url - The URL to extract the slug from. * * @returns The slug of the Accessibilite or null if not found. */ export function extractAccessibiliteSlugFromApiUrl(url: string): string | null { - if (!isValidAccessibiliteApiUrl(url)) { + if (!isValidAccessibilityApiUrl(url)) { return null; } diff --git a/utils/erp.ts b/utils/establishment.ts similarity index 85% rename from utils/erp.ts rename to utils/establishment.ts index d26ae37..22897b9 100644 --- a/utils/erp.ts +++ b/utils/establishment.ts @@ -9,7 +9,7 @@ import { urlRemoveQueryStrings } from "./url"; * * @returns A boolean. */ -export function isValidErpUrl(url: string): boolean { +export function isValidEstablishmentUrl(url: string): boolean { let u: string = url.trim(); if (!u.startsWith(BASE_URL)) { return false; @@ -32,8 +32,8 @@ export function isValidErpUrl(url: string): boolean { * * @returns The slug of the ERP or null if not found. */ -export function extractErpSlugFromUrl(url: string): string | null { - if (!isValidErpUrl(url)) { +export function extractEstablishmentSlugFromUrl(url: string): string | null { + if (!isValidEstablishmentUrl(url)) { return null; } diff --git a/utils/index.ts b/utils/index.ts index bc4dae9..b3937c7 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -1,5 +1,5 @@ export * from "./constants"; export * from "./paginate"; export * from "./url"; -export * from "./erp"; -export * from "./accessibilite"; +export * from "./establishment"; +export * from "./accessibility";