Prod (#118)
This commit is contained in:
commit
14d179072d
210
.circleci/config.yml
Normal file
210
.circleci/config.yml
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
version: 2.1
|
||||||
|
|
||||||
|
orbs:
|
||||||
|
kubernetes: circleci/kubernetes@1.0.0
|
||||||
|
helm: circleci/helm@2.0.1
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-push-docker-image:
|
||||||
|
docker:
|
||||||
|
- image: cimg/base:stable
|
||||||
|
parameters:
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_FC_CLIENT_ID:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_DOCAPOST_API_URL:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
NEXT_PUBLIC_DOCAPOST_APP_ID:
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
environment:
|
||||||
|
TAG: << pipeline.git.tag >>
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: << parameters.NEXT_PUBLIC_BACK_API_HOST >>
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: << parameters.NEXT_PUBLIC_BACK_API_PROTOCOL >>
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: << parameters.NEXT_PUBLIC_BACK_API_ROOT_URL >>
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: << parameters.NEXT_PUBLIC_BACK_API_VERSION >>
|
||||||
|
NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT: << parameters.NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT >>
|
||||||
|
NEXT_PUBLIC_FC_CLIENT_ID: << parameters.NEXT_PUBLIC_FC_CLIENT_ID >>
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: << parameters.NEXT_PUBLIC_FRONT_APP_HOST >>
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: << parameters.NEXT_PUBLIC_FRONT_APP_PORT >>
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: << parameters.NEXT_PUBLIC_IDNOT_BASE_URL >>
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: << parameters.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT >>
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: << parameters.NEXT_PUBLIC_IDNOT_CLIENT_ID >>
|
||||||
|
NEXT_PUBLIC_DOCAPOST_API_URL: << parameters.NEXT_PUBLIC_DOCAPOST_API_URL >>
|
||||||
|
NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID: << parameters.NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID >>
|
||||||
|
NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID: << parameters.NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID >>
|
||||||
|
NEXT_PUBLIC_DOCAPOST_APP_ID: << parameters.NEXT_PUBLIC_DOCAPOST_APP_ID >>
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- add_ssh_keys:
|
||||||
|
fingerprints:
|
||||||
|
- "39:25:57:64:62:43:1f:98:b1:5e:75:53:87:d8:e7:71"
|
||||||
|
- run: cp $HOME/.ssh/id_rsa_3925576462431f98b15e755387d8e771 id_rsa
|
||||||
|
- setup_remote_docker:
|
||||||
|
version: 20.10.12
|
||||||
|
docker_layer_caching: true
|
||||||
|
- run: docker login rg.fr-par.scw.cloud/lecoffre -u nologin -p $SCW_SECRET_KEY_BIS
|
||||||
|
- run: docker build --tag rg.fr-par.scw.cloud/lecoffre/front:${CIRCLE_SHA1:0:7} .
|
||||||
|
- run: docker push rg.fr-par.scw.cloud/lecoffre/front:${CIRCLE_SHA1:0:7}
|
||||||
|
|
||||||
|
deploy-docker-image:
|
||||||
|
docker:
|
||||||
|
- image: cimg/base:stable
|
||||||
|
environment:
|
||||||
|
TAG: << pipeline.git.tag >>
|
||||||
|
parameters:
|
||||||
|
env:
|
||||||
|
type: string
|
||||||
|
default: ppd
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- kubernetes/install-kubeconfig:
|
||||||
|
kubeconfig: KUBECONFIG_DATA
|
||||||
|
- helm/install-helm-client
|
||||||
|
- run:
|
||||||
|
name: Deploy
|
||||||
|
command: >
|
||||||
|
helm upgrade
|
||||||
|
lecoffre-front devops/ -i -f devops/<<parameters.env>>.values.yaml
|
||||||
|
-n lecoffre-<<parameters.env>>
|
||||||
|
--create-namespace
|
||||||
|
--set lecoffreFront.image.repository='rg.fr-par.scw.cloud/lecoffre/front'
|
||||||
|
--set lecoffreFront.image.tag=${CIRCLE_SHA1:0:7}
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build-and-register-stg:
|
||||||
|
jobs:
|
||||||
|
- build-push-docker-image:
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: api.stg.lecoffre.smart-chain.fr
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: https://
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: /api
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: /v1
|
||||||
|
NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT: https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize
|
||||||
|
NEXT_PUBLIC_FC_CLIENT_ID: 211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6e
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: https://app.stg.lecoffre.smart-chain.fr
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: "3000"
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: "https://qual-connexion.idnot.fr"
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: "/IdPOAuth2/authorize/idnot_idp_v1"
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: "4501646203F3EF67"
|
||||||
|
NEXT_PUBLIC_DOCAPOST_API_URL: "https://preprod.id360docaposte.com/api/1.0.0"
|
||||||
|
NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID: 49508376-b160-475d-9224-9bb6511215b8
|
||||||
|
NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID: 54c14875-f864-4819-8cd4-4fc6dd4a947b
|
||||||
|
NEXT_PUBLIC_DOCAPOST_APP_ID: leCoffre@smart_chain
|
||||||
|
context:
|
||||||
|
- sc-shared-prd
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: staging
|
||||||
|
- deploy-docker-image:
|
||||||
|
env: stg
|
||||||
|
requires:
|
||||||
|
- build-push-docker-image
|
||||||
|
context:
|
||||||
|
- sc-shared-prd
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: staging
|
||||||
|
|
||||||
|
build-and-register-ppd:
|
||||||
|
jobs:
|
||||||
|
- build-push-docker-image:
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: api.ppd.lecoffre.smart-chain.fr
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: https://
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: /api
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: /v1
|
||||||
|
NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT: https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize
|
||||||
|
NEXT_PUBLIC_FC_CLIENT_ID: 211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6e
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: https://app.ppd.lecoffre.smart-chain.fr
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: "3000"
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: "https://qual-connexion.idnot.fr"
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: "/IdPOAuth2/authorize/idnot_idp_v1"
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: "4501646203F3EF67"
|
||||||
|
NEXT_PUBLIC_DOCAPOST_API_URL: "https://preprod.id360docaposte.com/api/1.0.0"
|
||||||
|
NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID: 49508376-b160-475d-9224-9bb6511215b8
|
||||||
|
NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID: 54c14875-f864-4819-8cd4-4fc6dd4a947b
|
||||||
|
NEXT_PUBLIC_DOCAPOST_APP_ID: leCoffre@smart_chain
|
||||||
|
context:
|
||||||
|
- sc-shared-prd
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: preprod
|
||||||
|
- deploy-docker-image:
|
||||||
|
env: ppd
|
||||||
|
requires:
|
||||||
|
- build-push-docker-image
|
||||||
|
context:
|
||||||
|
- sc-shared-prd
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: preprod
|
||||||
|
|
||||||
|
build-and-register-prd:
|
||||||
|
jobs:
|
||||||
|
- build-push-docker-image:
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: api.lecoffre.smart-chain.fr
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: https://
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: /api
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: /v1
|
||||||
|
NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT: https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize
|
||||||
|
NEXT_PUBLIC_FC_CLIENT_ID: 211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6e
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: https://app.lecoffre.smart-chain.fr
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: "3000"
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: "https://qual-connexion.idnot.fr"
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: "/IdPOAuth2/authorize/idnot_idp_v1"
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: "4501646203F3EF67"
|
||||||
|
NEXT_PUBLIC_DOCAPOST_API_URL: "https://preprod.id360docaposte.com/api/1.0.0"
|
||||||
|
NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID: 49508376-b160-475d-9224-9bb6511215b8
|
||||||
|
NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID: 54c14875-f864-4819-8cd4-4fc6dd4a947b
|
||||||
|
NEXT_PUBLIC_DOCAPOST_APP_ID: leCoffre@smart_chain
|
||||||
|
context:
|
||||||
|
- sc-shared-prd
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
||||||
|
- deploy-docker-image:
|
||||||
|
env: prd
|
||||||
|
requires:
|
||||||
|
- build-push-docker-image
|
||||||
|
context:
|
||||||
|
- sc-shared-prd
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
6
.env.example
Normal file
6
.env.example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
BACK_API_PROTOCOL=
|
||||||
|
BACK_API_HOSTNAME=
|
||||||
|
BACK_API_PORT=
|
||||||
|
BACK_API_ROOT_URL=
|
||||||
|
BACK_API_VERSION=
|
||||||
|
|
9
.eslintrc.json
Normal file
9
.eslintrc.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "next/core-web-vitals",
|
||||||
|
"rules": {
|
||||||
|
"react/no-unescaped-entities": "off",
|
||||||
|
"@next/next/no-page-custom-font": "off",
|
||||||
|
"react/no-children-prop": "off"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env*.local
|
||||||
|
.env
|
||||||
|
|
||||||
|
# vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
|
node_modules
|
||||||
|
id_rsa
|
10
.prettierrc.json
Normal file
10
.prettierrc.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 140,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"useTabs": true,
|
||||||
|
"singleQuote": false,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"semi": true,
|
||||||
|
"bracketSameLine": true
|
||||||
|
}
|
1
.ssh/id_rsa.pub
Normal file
1
.ssh/id_rsa.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOfOFPvQNw5XguFuX1YNvED8ulP+tIA/5xw7LHcA0gRj3hwILCAEAjuDs+d13zCsnEb0yd+laT3PU9iRIKa28Tynu+sTjGDyfx8MX/HjJtbEzyd6jLn87uTvw/6lzg2y5ZDEa6PEqrPIv0KEhuq6HuU8qAA0nBpsTIAUTK3XR8qm3I6J9Rs1JyBjvIP5UeICApvoLmgHuz6mKdvoQ8qKDWamsL4pSc4Hr7HlQ8ITNhnyS8XMgQInU/I2TzT/I4Dxx5IeFUQ5KOfJJNgK1d+PByLSWUrn+eRXki8m1hjMiwGIehVAriFW1C309SEHxLHjQKUPXHSv4kH7zqjO+p3kY5gwp/lvsBRSnihj8s1lADsJlMqjnSLeIQ+sY2CNkmXXI8ABkzhuJKTGTl+8pzGGhIHzeU7e7lpSn3gLn4p217kIppHNAr6dZH9UaYbgnwVonwr5cLbatRPFyI1NfXKDyZtSYlGQxLQUt9KDrNvVTZzaTt3YwM/YCsRIADAagKosM= gisele-smartchain@MacBook-Pro-6.local
|
15
.vscode/custom.code-snippets
vendored
Normal file
15
.vscode/custom.code-snippets
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"Media queries": {
|
||||||
|
"prefix": "media",
|
||||||
|
"body": [
|
||||||
|
"@media(max-width: \\$screen-$1){$2}"
|
||||||
|
],
|
||||||
|
"description": "media queries"
|
||||||
|
},
|
||||||
|
"Default div": {
|
||||||
|
"prefix": "<div",
|
||||||
|
"body": [
|
||||||
|
"<div className={classes[\"$1\"]}>$2</div>"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
37
.vscode/settings.json
vendored
Normal file
37
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "vscode.json-language-features"
|
||||||
|
},
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"terminal.integrated.env.linux": {
|
||||||
|
"PATH": "${env:HOME}/elrondsdk/vendor-rust/bin:${env:HOME}/elrondsdk/erdpy-venv/bin:${env:HOME}/elrondsdk/vmtools:${env:HOME}/elrondsdk/nodejs/latest/bin:${env:PATH}",
|
||||||
|
"VIRTUAL_ENV": "${env:HOME}/elrondsdk/erdpy-venv",
|
||||||
|
"RUSTUP_HOME": "${env:HOME}/elrondsdk/vendor-rust",
|
||||||
|
"CARGO_HOME": "${env:HOME}/elrondsdk/vendor-rust"
|
||||||
|
},
|
||||||
|
"terminal.integrated.env.osx": {
|
||||||
|
"PATH": "${env:HOME}/elrondsdk/vendor-rust/bin:${env:HOME}/elrondsdk/erdpy-venv/bin:${env:HOME}/elrondsdk/vmtools:${env:HOME}/elrondsdk/nodejs/latest/bin:${env:PATH}",
|
||||||
|
"VIRTUAL_ENV": "${env:HOME}/elrondsdk/erdpy-venv",
|
||||||
|
"RUSTUP_HOME": "${env:HOME}/elrondsdk/vendor-rust",
|
||||||
|
"CARGO_HOME": "${env:HOME}/elrondsdk/vendor-rust"
|
||||||
|
},
|
||||||
|
"terminal.integrated.environmentChangesIndicator": "on",
|
||||||
|
"terminal.integrated.inheritEnv": true,
|
||||||
|
"workbench.dialogs.customEnabled": true,
|
||||||
|
"rust-client.rustupPath": "${env:HOME}/elrondsdk/vendor-rust/bin/rustup",
|
||||||
|
"rust-client.rlsPath": "${env:HOME}/elrondsdk/vendor-rust/bin/rls",
|
||||||
|
"rust-client.disableRustup": true,
|
||||||
|
"rust-client.autoStartRls": false,
|
||||||
|
"[typescriptreact]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
}
|
||||||
|
}
|
46
Dockerfile
Normal file
46
Dockerfile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Install dependencies only when needed
|
||||||
|
FROM node:19-alpine AS deps
|
||||||
|
|
||||||
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
|
COPY package.json ./
|
||||||
|
|
||||||
|
RUN apk update && apk add openssh-client git
|
||||||
|
|
||||||
|
COPY id_rsa /root/.ssh/id_rsa
|
||||||
|
RUN chmod 600 ~/.ssh/id_rsa
|
||||||
|
RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
||||||
|
RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
|
||||||
|
|
||||||
|
RUN npm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Rebuild the source code only when needed
|
||||||
|
FROM node:19-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
|
COPY --from=deps leCoffre-front/node_modules ./node_modules
|
||||||
|
COPY --from=deps leCoffre-front/package.json package.json
|
||||||
|
COPY tsconfig.json tsconfig.json
|
||||||
|
COPY next.config.js next.config.js
|
||||||
|
COPY src src
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Production image, copy all the files and run next
|
||||||
|
FROM node:19-alpine AS production
|
||||||
|
|
||||||
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
|
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
||||||
|
|
||||||
|
COPY public ./public
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/node_modules ./node_modules
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/.next ./.next
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/next.config.js ./next.config.js
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json
|
||||||
|
|
||||||
|
USER lecoffreuser
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start"]
|
||||||
|
EXPOSE 3000
|
44
Dockerfile.front
Normal file
44
Dockerfile.front
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Install dependencies only when needed
|
||||||
|
FROM node:19-alpine AS deps
|
||||||
|
|
||||||
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
|
COPY package.json ./
|
||||||
|
|
||||||
|
RUN apk update && apk add openssh-client git
|
||||||
|
|
||||||
|
COPY id_rsa /root/.ssh/id_rsa
|
||||||
|
RUN chmod 600 ~/.ssh/id_rsa
|
||||||
|
RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
||||||
|
RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
|
||||||
|
|
||||||
|
RUN npm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Rebuild the source code only when needed
|
||||||
|
FROM node:19-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
|
COPY --from=deps leCoffre-front/node_modules ./node_modules
|
||||||
|
COPY --from=deps leCoffre-front/package.json package.json
|
||||||
|
COPY tsconfig.json tsconfig.json
|
||||||
|
COPY src src
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Production image, copy all the files and run next
|
||||||
|
FROM node:19-alpine AS production
|
||||||
|
|
||||||
|
WORKDIR leCoffre-front
|
||||||
|
|
||||||
|
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
||||||
|
|
||||||
|
COPY public ./public
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/node_modules ./node_modules
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/.next ./.next
|
||||||
|
COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json
|
||||||
|
|
||||||
|
USER lecoffreuser
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start"]
|
||||||
|
EXPOSE 3000
|
40
README.md
40
README.md
@ -1,2 +1,38 @@
|
|||||||
# leCoffre-front
|
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||||
[owner: Hugo Lextrait] Le Coffre front
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
First, run the development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
# or
|
||||||
|
yarn dev
|
||||||
|
# or
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||||
|
|
||||||
|
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
|
||||||
|
|
||||||
|
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
|
||||||
|
|
||||||
|
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||||
|
|
||||||
|
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
To learn more about Next.js, take a look at the following resources:
|
||||||
|
|
||||||
|
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||||
|
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||||
|
|
||||||
|
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||||
|
|
||||||
|
## Deploy on Vercel
|
||||||
|
|
||||||
|
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||||
|
|
||||||
|
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||||
|
23
devops/.helmignore
Normal file
23
devops/.helmignore
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.orig
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
25
devops/Chart.yaml
Normal file
25
devops/Chart.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: leCoffre-back
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
|
||||||
|
# A chart can be either an 'application' or a 'library' chart.
|
||||||
|
#
|
||||||
|
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||||
|
# to be deployed.
|
||||||
|
#
|
||||||
|
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||||
|
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||||
|
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||||
|
type: application
|
||||||
|
|
||||||
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
|
# to the chart and its templates, including the app version.
|
||||||
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
|
version: 0.0.1
|
||||||
|
|
||||||
|
# This is the version number of the application being deployed. This version number should be
|
||||||
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
|
# It is recommended to use it with quotes.
|
||||||
|
appVersion: 0.5.6
|
||||||
|
|
33
devops/ppd.values.yaml
Normal file
33
devops/ppd.values.yaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
dockerPullSecret: docker-pull-secret
|
||||||
|
|
||||||
|
scwSecretKey: AgChoEnPitXp4Ny/rVMEcevaWKNVpyj2cJYAcq+yFqKwVwnLB+ffDvwqz9XBHu+6d4Nyyjkf37zUAMoaM21lEDWA7x3zfG2/D/j+rvX1qxzZgLD0mjBk7fGElVm332I6JA83oInes8AMMYEDPLElzHnpKRb9KtkIP4NzgOcCeW0ijft3N7Vroez6LEHsBPCA1I9XjKSkGEDvrO0MhWX3iJOlfz+SPMfJAV7rPawOs0ZmohTHrPW8qIvGDn8HCzKyU8zRBoMt+Ogpf5pH4U3JryEFuqD61KAQgablAM8edPIvsgNno9HAEuC2QtRLYA9aUhuKdaKuS58c9P2E80PHWXIlbpFCg6EugQTgNfnYp+3qDUNz8edeCfapYLvF4s9eCMGyMsGnpDR8EDNOyuGy7Y3l7okX8Xqu464gMp9E+hX7bHkcD6a4xfyIgJcWxsku0tm1TH1dpn4M1UXRuyZZif8P08nuE6MTUL67sAR9J1lpn4lVEL4kflk0pP2tZ5ncgPQFafJrRz05krMb0eU5tb2H4gs7ao/LL6idWo8MM9K1yr8lIuT5x2WW5CX+RjA+i50ex114V6vX3PNP5oVyt+DynTUB9QmXzVm3oLfDc3Cae1uqh7X0CFd+xiztJBtg0VtJaD/xUJcuWfY4cV2lERo9fRrykltzlJqiXHO4nowt8OtN0BcViVV8NJhPhYFzyb4ympxpOlTjm3GETuT2TYhUqdgS9nzleEAbOmOHZdIO2COunPE=
|
||||||
|
|
||||||
|
lecoffreFront:
|
||||||
|
serviceAccountName: lecoffre-front-sa
|
||||||
|
envSecrets: ppd-env
|
||||||
|
command: "'sh', '-c', 'export $(xargs </etc/env/.env) && npm run start'"
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: docker-pull-secret
|
||||||
|
image:
|
||||||
|
pullPolicy: Always
|
||||||
|
repository: "rg.fr-par.scw.cloud/lecoffre/front"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 1Gi
|
||||||
|
limits:
|
||||||
|
memory: 2Gi
|
||||||
|
ingress:
|
||||||
|
host: app.ppd.lecoffre.smart-chain.fr
|
||||||
|
tls:
|
||||||
|
hosts:
|
||||||
|
- app.ppd.lecoffre.smart-chain.fr
|
||||||
|
secretName: front-tls
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: nginx
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
env:
|
||||||
|
- key: .env
|
||||||
|
scwID: "id:430001f8-68ab-47b2-92e8-38024c35a80d"
|
34
devops/prd.values.yaml
Normal file
34
devops/prd.values.yaml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
dockerPullSecret: docker-pull-secret
|
||||||
|
|
||||||
|
scwSecretKey: AgBG2y7uQuap+2akNPGFxpCR+l0INO6Wxez5qljtY6t71GFGhJLYN9ZfefflKcFzD2Nv7DQMXXhpnCCaFti+9JMCMDuN324dDgtMMLTot+Pkxk/bAm+L8t3HfRharFdLz/vvzg77bvypi28TEoNYR/AM0e8VMYxBEgEp2TmP5uXcxZOgPzXMrfQoSdNRyzGTJ5tXZwe3PP7XvXyTNsZzHBtoQQM+nul9nL+VFA7CBRaaOpCmKOXjAlt7TyNXo4X5eYBNlxr+NuQw4dh4E/1zqdU/dDCE1+vx88BDbdydBA1qJaTOUSGTFquSK4kb9qAVAexBAIUqRwpfEW6Li945AXtnxLN42gEGPRsA9tSXL2c20k6thuRCqxwEOZljq2E03qtLAkxdP6WFBcb77o4PIEMZ8AmzPASnI+eW5z2mCoP3L+HZQrTLliDjmF4AMtOfZxRi0CCTrsSabOrimJC6v3y3ve0VcSsjA3rd5vvJ3Va4mZK4JAtYwEUx4PCHCGkUxc0w6jRwKB5tL/auZVT4SV/0z/WgW4Kq4AdvxsU6yGOqflt6e3ePIIuvCgjw+1yOYRpUiSGj36oOqNPMA4smxIB7p7Gi3csqt2TrQoW3TaLv/s7gbCcxHWSor+WT71WGg8AVmLm+FzUINmNop+c2RNo3O/Gj7h1uybX/pj+tRLNOuBQCqa+GQkY2bT2NcT9ifnAZB6K+2zAWXl+tdbMlDGV89P2yMYuRMdHGhuOoyuIUPWeA5i0=
|
||||||
|
|
||||||
|
lecoffreFront:
|
||||||
|
serviceAccountName: lecoffre-front-sa
|
||||||
|
command: "'sh', '-c', 'export $(xargs </etc/env/.env) && npm run cron'"
|
||||||
|
envSecrets: prd-env
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: docker-pull-secret
|
||||||
|
image:
|
||||||
|
pullPolicy: Always
|
||||||
|
repository: "rg.fr-par.scw.cloud/lecoffre/front"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 1Gi
|
||||||
|
limits:
|
||||||
|
memory: 2Gi
|
||||||
|
ingress:
|
||||||
|
host: app.lecoffre.smart-chain.fr
|
||||||
|
tls:
|
||||||
|
hosts:
|
||||||
|
- app.lecoffre.smart-chain.fr
|
||||||
|
secretName: front-tls
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: nginx
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
env:
|
||||||
|
- key: .env
|
||||||
|
scwID: "id:a131edea-84e0-49d6-b4a8-20ab417220c9"
|
||||||
|
|
34
devops/stg.values.yaml
Normal file
34
devops/stg.values.yaml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
dockerPullSecret: docker-pull-secret
|
||||||
|
|
||||||
|
scwSecretKey: AgChoEnPitXp4Ny/rVMEcevaWKNVpyj2cJYAcq+yFqKwVwnLB+ffDvwqz9XBHu+6d4Nyyjkf37zUAMoaM21lEDWA7x3zfG2/D/j+rvX1qxzZgLD0mjBk7fGElVm332I6JA83oInes8AMMYEDPLElzHnpKRb9KtkIP4NzgOcCeW0ijft3N7Vroez6LEHsBPCA1I9XjKSkGEDvrO0MhWX3iJOlfz+SPMfJAV7rPawOs0ZmohTHrPW8qIvGDn8HCzKyU8zRBoMt+Ogpf5pH4U3JryEFuqD61KAQgablAM8edPIvsgNno9HAEuC2QtRLYA9aUhuKdaKuS58c9P2E80PHWXIlbpFCg6EugQTgNfnYp+3qDUNz8edeCfapYLvF4s9eCMGyMsGnpDR8EDNOyuGy7Y3l7okX8Xqu464gMp9E+hX7bHkcD6a4xfyIgJcWxsku0tm1TH1dpn4M1UXRuyZZif8P08nuE6MTUL67sAR9J1lpn4lVEL4kflk0pP2tZ5ncgPQFafJrRz05krMb0eU5tb2H4gs7ao/LL6idWo8MM9K1yr8lIuT5x2WW5CX+RjA+i50ex114V6vX3PNP5oVyt+DynTUB9QmXzVm3oLfDc3Cae1uqh7X0CFd+xiztJBtg0VtJaD/xUJcuWfY4cV2lERo9fRrykltzlJqiXHO4nowt8OtN0BcViVV8NJhPhYFzyb4ympxpOlTjm3GETuT2TYhUqdgS9nzleEAbOmOHZdIO2COunPE=
|
||||||
|
|
||||||
|
lecoffreFront:
|
||||||
|
serviceAccountName: lecoffre-front-sa
|
||||||
|
envSecrets: stg-env
|
||||||
|
command: "'sh', '-c', 'export $(xargs </etc/env/.env) && npm run start'"
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: docker-pull-secret
|
||||||
|
image:
|
||||||
|
pullPolicy: Always
|
||||||
|
repository: "rg.fr-par.scw.cloud/lecoffre/front"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 1Gi
|
||||||
|
limits:
|
||||||
|
memory: 2Gi
|
||||||
|
ingress:
|
||||||
|
host: app.stg.lecoffre.smart-chain.fr
|
||||||
|
tls:
|
||||||
|
hosts:
|
||||||
|
- app.stg.lecoffre.smart-chain.fr
|
||||||
|
secretName: front-tls
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: nginx
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
# key is name of the environment variable, scwID is the secret ID in SCW with "id:" in front
|
||||||
|
env:
|
||||||
|
- key: .env
|
||||||
|
scwID: "id:2be9510b-bb1f-4fbe-ab3e-3dc11fb49051"
|
1
devops/templates/docker-pull-secret.yaml
Normal file
1
devops/templates/docker-pull-secret.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
### USE SECRET FROM BACK
|
74
devops/templates/lecoffre-front.yaml
Normal file
74
devops/templates/lecoffre-front.yaml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: lecoffre-front
|
||||||
|
{{if .Values.lecoffreFront.ingress.annotations}}
|
||||||
|
annotations:
|
||||||
|
{{toYaml .Values.lecoffreFront.ingress.annotations | indent 4 }}
|
||||||
|
{{end}}
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts: {{ .Values.lecoffreFront.ingress.tls.hosts }}
|
||||||
|
secretName: {{ .Values.lecoffreFront.ingress.tls.secretName }}
|
||||||
|
rules:
|
||||||
|
- host: {{ .Values.lecoffreFront.ingress.host }}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: lecoffre-front-svc
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: lecoffre-front-svc
|
||||||
|
labels:
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
name: http
|
||||||
|
targetPort: 3000
|
||||||
|
selector:
|
||||||
|
app: lecoffre-front
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: lecoffre-front
|
||||||
|
labels:
|
||||||
|
app: lecoffre-front
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: lecoffre-front
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
labels:
|
||||||
|
app: lecoffre-front
|
||||||
|
spec:
|
||||||
|
serviceAccountName: {{ .Values.lecoffreFront.serviceAccountName }}
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: docker-pull-secret
|
||||||
|
containers:
|
||||||
|
- name: lecoffre-front
|
||||||
|
image: "{{ .Values.lecoffreFront.image.repository }}:{{ .Values.lecoffreFront.image.tag }}"
|
||||||
|
{{if .Values.lecoffreFront.resources}}
|
||||||
|
resources:
|
||||||
|
{{toYaml .Values.lecoffreFront.resources | indent 10}}
|
||||||
|
{{end}}
|
||||||
|
imagePullPolicy: {{ .Values.lecoffreFront.image.pullPolicy }}
|
||||||
|
command: [{{ .Values.lecoffreFront.command }}]
|
||||||
|
volumeMounts:
|
||||||
|
- name: secret-volume
|
||||||
|
mountPath: /etc/env
|
||||||
|
volumes:
|
||||||
|
- name: secret-volume
|
||||||
|
secret:
|
||||||
|
secretName: {{ .Values.lecoffreFront.envSecrets }}
|
1
devops/templates/sealed-secret.yaml
Normal file
1
devops/templates/sealed-secret.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
## USE SEALED SECRET FROM BACK
|
1
devops/templates/secret-store.yaml
Normal file
1
devops/templates/secret-store.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
## USE SECRET STORE FROM BACK
|
1
devops/templates/secrets.yaml
Normal file
1
devops/templates/secrets.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
## same secret as back
|
14
devops/templates/service-account.yaml
Normal file
14
devops/templates/service-account.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.lecoffreFront.serviceAccountName }}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.lecoffreFront.serviceAccountName }}-token
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/service-account.name: {{ .Values.lecoffreFront.serviceAccountName }}
|
||||||
|
type: kubernetes.io/service-account-token
|
35
devops/values.yaml
Normal file
35
devops/values.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
dockerPullSecret: docker-pull-secret
|
||||||
|
|
||||||
|
scwSecretKey: ss
|
||||||
|
|
||||||
|
lecoffreFront:
|
||||||
|
serviceAccountName: lecoffre-front-sa
|
||||||
|
command: "npm run api:start"
|
||||||
|
envSecrets: env-env
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: docker-pull-secret
|
||||||
|
image:
|
||||||
|
pullPolicy: Always
|
||||||
|
repository: "rg.fr-par.scw.cloud/lecoffre/front"
|
||||||
|
tag:
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 1Gi
|
||||||
|
limits:
|
||||||
|
memory: 2Gi
|
||||||
|
ingress:
|
||||||
|
host: app.ppd.lecoffre.smart-chain.fr
|
||||||
|
tls:
|
||||||
|
hosts:
|
||||||
|
- app.ppd.lecoffre.smart-chain.fr
|
||||||
|
secretName: api-tls
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: nginx
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
|
||||||
|
env:
|
||||||
|
- key: a
|
||||||
|
scwID: b
|
57
next.config.js
Normal file
57
next.config.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
|
||||||
|
const nextConfig = {
|
||||||
|
reactStrictMode: false,
|
||||||
|
publicRuntimeConfig: {
|
||||||
|
// Will be available on both server and client
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: process.env.NEXT_PUBLIC_BACK_API_PROTOCOL,
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: process.env.NEXT_PUBLIC_BACK_API_HOST,
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: process.env.NEXT_PUBLIC_BACK_API_ROOT_URL,
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: process.env.NEXT_PUBLIC_BACK_API_VERSION,
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: process.env.NEXT_PUBLIC_FRONT_APP_HOST,
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: process.env.NEXT_PUBLIC_FRONT_APP_PORT,
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: process.env.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT,
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: process.env.NEXT_PUBLIC_IDNOT_CLIENT_ID,
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: process.env.NEXT_PUBLIC_IDNOT_BASE_URL,
|
||||||
|
NEXT_PUBLIC_DOCAPOSTE_API_URL: process.env.NEXT_PUBLIC_DOCAPOSTE_API_URL,
|
||||||
|
},
|
||||||
|
|
||||||
|
serverRuntimeConfig: {
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: process.env.NEXT_PUBLIC_BACK_API_PROTOCOL,
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: process.env.NEXT_PUBLIC_BACK_API_HOST,
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: process.env.NEXT_PUBLIC_BACK_API_ROOT_URL,
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: process.env.NEXT_PUBLIC_BACK_API_VERSION,
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: process.env.NEXT_PUBLIC_FRONT_APP_HOST,
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: process.env.NEXT_PUBLIC_FRONT_APP_PORT,
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: process.env.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT,
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: process.env.NEXT_PUBLIC_IDNOT_CLIENT_ID,
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: process.env.NEXT_PUBLIC_IDNOT_BASE_URL,
|
||||||
|
NEXT_PUBLIC_DOCAPOSTE_API_URL: process.env.NEXT_PUBLIC_DOCAPOSTE_API_URL,
|
||||||
|
},
|
||||||
|
|
||||||
|
env: {
|
||||||
|
NEXT_PUBLIC_BACK_API_PROTOCOL: process.env.NEXT_PUBLIC_BACK_API_PROTOCOL,
|
||||||
|
NEXT_PUBLIC_BACK_API_HOST: process.env.NEXT_PUBLIC_BACK_API_HOST,
|
||||||
|
NEXT_PUBLIC_BACK_API_ROOT_URL: process.env.NEXT_PUBLIC_BACK_API_ROOT_URL,
|
||||||
|
NEXT_PUBLIC_BACK_API_VERSION: process.env.NEXT_PUBLIC_BACK_API_VERSION,
|
||||||
|
NEXT_PUBLIC_FRONT_APP_HOST: process.env.NEXT_PUBLIC_FRONT_APP_HOST,
|
||||||
|
NEXT_PUBLIC_FRONT_APP_PORT: process.env.NEXT_PUBLIC_FRONT_APP_PORT,
|
||||||
|
NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: process.env.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT,
|
||||||
|
NEXT_PUBLIC_IDNOT_CLIENT_ID: process.env.NEXT_PUBLIC_IDNOT_CLIENT_ID,
|
||||||
|
NEXT_PUBLIC_IDNOT_BASE_URL: process.env.NEXT_PUBLIC_IDNOT_BASE_URL,
|
||||||
|
NEXT_PUBLIC_DOCAPOSTE_API_URL: process.env.NEXT_PUBLIC_DOCAPOSTE_API_URL,
|
||||||
|
},
|
||||||
|
|
||||||
|
// webpack: config => {
|
||||||
|
// config.node = {
|
||||||
|
// fs: 'empty',
|
||||||
|
// child_process: 'empty',
|
||||||
|
// net: 'empty',
|
||||||
|
// dns: 'empty',
|
||||||
|
// tls: 'empty',
|
||||||
|
// };
|
||||||
|
// return config;
|
||||||
|
// },
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = nextConfig;
|
5028
package-lock.json
generated
Normal file
5028
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
package.json
Normal file
38
package.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"name": "lecoffre-front",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "next lint",
|
||||||
|
"format": "prettier --write src"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@emotion/react": "^11.10.6",
|
||||||
|
"@emotion/styled": "^11.10.6",
|
||||||
|
"@mui/material": "^5.11.13",
|
||||||
|
"@types/node": "18.15.1",
|
||||||
|
"@types/react": "18.0.28",
|
||||||
|
"@types/react-dom": "18.0.11",
|
||||||
|
"class-validator": "^0.14.0",
|
||||||
|
"classnames": "^2.3.2",
|
||||||
|
"crypto-random-string": "^5.0.0",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
|
"eslint": "8.36.0",
|
||||||
|
"eslint-config-next": "13.2.4",
|
||||||
|
"form-data": "^4.0.0",
|
||||||
|
"jwt-decode": "^3.1.2",
|
||||||
|
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.104",
|
||||||
|
"next": "13.2.4",
|
||||||
|
"prettier": "^2.8.7",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"react-dom": "18.2.0",
|
||||||
|
"react-select": "^5.7.2",
|
||||||
|
"sass": "^1.59.2",
|
||||||
|
"sharp": "^0.32.1",
|
||||||
|
"typescript": "4.9.5",
|
||||||
|
"uuidv4": "^6.2.13"
|
||||||
|
}
|
||||||
|
}
|
BIN
public/CGU_LeCoffre_io.pdf
Normal file
BIN
public/CGU_LeCoffre_io.pdf
Normal file
Binary file not shown.
22
public/favicon.svg
Normal file
22
public/favicon.svg
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<svg width="44" height="56" viewBox="0 0 44 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_3466_113133)">
|
||||||
|
<path d="M43.8828 9.98633C43.9035 9.4084 43.5713 8.81895 42.8538 8.51041L24.3282 0.58968C22.8379 -0.0481226 21.0845 -0.0481226 19.5942 0.58968L1.17241 8.46666C0.443378 8.7798 0.0996282 9.37616 0.115778 9.96331V46.1454L4.25693 48.091L6.73008 46.9098L18.4499 51.7336V54.1858L22.0396 55.869L25.6617 54.1398V51.7544L37.3584 46.9397L39.8201 48.0887L43.8874 46.1477V9.98633H43.8828Z" fill="#C5B2D4"/>
|
||||||
|
<path d="M22.0369 55.9998L18.3318 54.2614V51.8115L6.73196 47.036L4.2565 48.2172L0 46.2209V9.85003C0.0322987 9.21222 0.454488 8.6481 1.12584 8.36259L19.5499 0.483307C21.061 -0.163706 22.8651 -0.163706 24.374 0.483307L42.8995 8.40403C43.5617 8.68725 43.9723 9.24216 43.9977 9.87075V46.2232L39.8173 48.2195L37.3534 47.0682L25.7743 51.8345V54.2153L22.0369 55.9998ZM18.5625 54.1163L22.0369 55.7465L25.5459 54.0725V51.6825L37.3626 46.8173L39.8196 47.9639L43.7716 46.0781V10.101H43.767V9.98127C43.7924 9.39412 43.4325 8.88296 42.8096 8.61587L24.284 0.69514C22.8305 0.073455 21.0956 0.073455 19.6422 0.69514L1.21812 8.57212C0.583683 8.84382 0.216862 9.36189 0.233012 9.96055V10.078V46.0712L4.25881 47.9616L6.72966 46.7827L18.5671 51.6549V54.1117L18.5625 54.1163Z" fill="#4E1480"/>
|
||||||
|
<path d="M18.0574 49.0688C17.5222 49.0688 16.9823 48.9629 16.4724 48.7441L4.4412 43.6325C2.94854 42.9993 1.98419 41.5441 1.98419 39.9254L1.97266 17.4319C1.97266 16.0711 2.65093 14.8116 3.79061 14.0633C4.93029 13.315 6.35835 13.1906 7.61108 13.7294L19.6539 18.9171C21.135 19.5549 22.0924 21.0078 22.0924 22.6195V45.037C22.0924 46.3932 21.4141 47.6504 20.2814 48.401C19.61 48.8454 18.8349 49.0711 18.0551 49.0711L18.0574 49.0688ZM6.00999 14.0863C5.36632 14.0863 4.72727 14.2728 4.17127 14.6366C3.22769 15.256 2.66246 16.3014 2.66477 17.4296L2.67631 39.9231C2.67631 41.2632 3.47685 42.4697 4.71343 42.9947L16.7447 48.1063C17.7805 48.5461 18.9617 48.4402 19.9007 47.8185C20.842 47.1991 21.4026 46.1561 21.4026 45.0324V22.6149C21.4026 21.2795 20.609 20.0775 19.3816 19.5479L7.33885 14.3603C6.91204 14.1761 6.45986 14.0863 6.00999 14.0863Z" fill="white"/>
|
||||||
|
<path d="M3.09274 20.3118V19.1352C3.09274 19.1052 3.07428 19.0776 3.0466 19.0661L1.58855 18.4375C1.53779 18.4168 1.48242 18.4536 1.48242 18.5066V19.6832C1.48242 19.7131 1.50088 19.7407 1.52856 19.7523L2.98431 20.3808C3.03506 20.4016 3.09043 20.3647 3.09043 20.3118H3.09274Z" fill="white"/>
|
||||||
|
<path d="M3.01696 20.7323C2.95929 20.7323 2.90392 20.7208 2.84855 20.6978L1.3928 20.0715C1.23823 20.0047 1.13672 19.8527 1.13672 19.6846V18.508C1.13672 18.3653 1.20824 18.234 1.3259 18.1558C1.44586 18.0775 1.59582 18.0637 1.72502 18.1212L3.18307 18.7498C3.33764 18.8166 3.43915 18.9686 3.43915 19.1366V20.3132C3.43915 20.456 3.36763 20.5872 3.24767 20.6655C3.17846 20.7116 3.09771 20.7346 3.01696 20.7346V20.7323ZM1.82883 19.505L2.74704 19.9011V19.3116L1.82883 18.9156V19.505Z" fill="white"/>
|
||||||
|
<path d="M3.14743 38.7512V37.5746C3.14743 37.5447 3.12897 37.5171 3.10129 37.5055L1.64323 36.877C1.59248 36.8562 1.53711 36.8931 1.53711 36.946V38.1226C1.53711 38.1526 1.55557 38.1802 1.58325 38.1917L3.039 38.8203C3.08975 38.841 3.14512 38.8042 3.14512 38.7512H3.14743Z" fill="white"/>
|
||||||
|
<path d="M3.0713 39.1721C3.01362 39.1721 2.95825 39.1606 2.90519 39.1376L1.44713 38.509C1.29256 38.4422 1.19336 38.2902 1.19336 38.1221V36.9455C1.19336 36.8051 1.26257 36.6715 1.38254 36.5933C1.5025 36.515 1.65015 36.5012 1.78166 36.5587L3.23971 37.1873C3.39428 37.2541 3.49349 37.4061 3.49349 37.5741V38.7507C3.49349 38.8935 3.42197 39.0247 3.30431 39.103C3.2351 39.1491 3.15435 39.1721 3.0713 39.1721ZM1.88317 37.9448L2.80137 38.3409V37.7514L1.88317 37.3554V37.9448Z" fill="white"/>
|
||||||
|
<path d="M22.415 26.6204V25.4438C22.415 25.4138 22.3965 25.3862 22.3689 25.3747L20.9108 24.7461C20.8601 24.7254 20.8047 24.7622 20.8047 24.8152V25.9918C20.8047 26.0217 20.8231 26.0493 20.8508 26.0608L22.3066 26.6894C22.3573 26.7102 22.4127 26.6733 22.4127 26.6204H22.415Z" fill="white"/>
|
||||||
|
<path d="M22.3392 27.0412C22.2816 27.0412 22.2262 27.0297 22.1708 27.0067L20.7151 26.3781C20.5605 26.3113 20.459 26.1594 20.459 25.9913V24.8147C20.459 24.6719 20.5305 24.5407 20.6482 24.4624C20.7681 24.3841 20.9158 24.3703 21.0473 24.4279L22.5053 25.0565C22.6599 25.1232 22.7614 25.2752 22.7614 25.4433V26.6199C22.7614 26.7626 22.6899 26.8939 22.5699 26.9722C22.5007 27.0182 22.42 27.0412 22.3392 27.0412ZM21.1511 25.814L22.0693 26.21V25.6206L21.1511 25.2245V25.814Z" fill="white"/>
|
||||||
|
<path d="M22.4677 45.0618V43.8852C22.4677 43.8552 22.4493 43.8276 22.4216 43.8161L20.9635 43.1875C20.9128 43.1668 20.8574 43.2036 20.8574 43.2566V44.4332C20.8574 44.4631 20.8759 44.4907 20.9036 44.5023L22.3593 45.1308C22.4101 45.1516 22.4654 45.1147 22.4654 45.0618H22.4677Z" fill="white"/>
|
||||||
|
<path d="M22.3916 45.4823C22.3339 45.4823 22.2786 45.4708 22.2232 45.4478L20.7674 44.8215C20.6129 44.7547 20.5137 44.6027 20.5137 44.4346V43.258C20.5137 43.1176 20.5829 42.984 20.7028 42.9058C20.8228 42.8275 20.9728 42.8137 21.102 42.8712L22.56 43.4998C22.7146 43.5666 22.8138 43.7186 22.8138 43.8866V45.0632C22.8138 45.206 22.7423 45.3372 22.6223 45.4155C22.5531 45.4616 22.4724 45.4846 22.3916 45.4846V45.4823ZM21.2035 44.255L22.1217 44.6511V44.0616L21.2035 43.6656V44.255Z" fill="white"/>
|
||||||
|
<path d="M8.47164 24.259C6.02617 25.2099 5.44248 29.5617 7.16585 33.9803C8.88921 38.3989 12.269 41.2126 14.7145 40.2616C17.16 39.3107 17.7437 34.9589 16.0203 30.5403C14.2969 26.1217 10.9171 23.308 8.47164 24.259ZM12.5989 32.3478C12.5713 32.2442 12.5367 32.1406 12.4974 32.037C12.4144 31.8228 12.3129 31.6294 12.1975 31.4567L12.7835 27.0911C13.7248 28.0098 14.5876 29.3177 15.1944 30.8742C15.7827 32.3823 16.0364 33.8813 15.9857 35.1661L12.5989 32.3478ZM9.10377 25.804C9.92738 25.4839 10.8802 25.6935 11.8122 26.3036L11.2216 30.6946C11.1178 30.6808 11.0163 30.69 10.924 30.7268C10.8664 30.7498 10.8156 30.7821 10.7671 30.8212L7.43347 28.0467C7.70339 26.9437 8.26862 26.1263 9.10377 25.804ZM8.04945 33.651C7.45192 32.1152 7.19815 30.591 7.26044 29.29L10.458 31.9518C10.4811 32.205 10.5457 32.479 10.6518 32.753C10.7187 32.9234 10.7971 33.08 10.8825 33.2251L10.3334 37.3075C9.4406 36.398 8.62852 35.1362 8.04945 33.651ZM11.3001 38.1341L11.8445 34.077C11.976 34.1092 12.1052 34.1069 12.2229 34.0609C12.3752 34.001 12.4905 33.879 12.5713 33.7132L15.8219 36.4187C15.5566 37.5515 14.9867 38.3897 14.1377 38.7212C13.2772 39.0551 12.2713 38.811 11.2978 38.1341H11.3001Z" fill="white"/>
|
||||||
|
<path d="M12.1448 31.9302C12.5924 32.6509 12.5878 33.4591 12.1656 33.7147C11.7434 33.9703 11.0167 33.595 10.6199 32.8466C10.1977 32.0523 10.1885 31.3339 10.583 31.0852C11.0421 30.7951 11.6904 31.1957 12.1471 31.9325L12.1448 31.9302Z" fill="#3FA79E"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_3466_113133">
|
||||||
|
<rect width="44" height="56" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 6.6 KiB |
15
public/manifest.json
Normal file
15
public/manifest.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"short_name": "lecoffre",
|
||||||
|
"name": "lecoffre",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/favicon.ico",
|
||||||
|
"sizes": "32x32 16x16",
|
||||||
|
"type": "image/x-icon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "light",
|
||||||
|
"background_color": "light"
|
||||||
|
}
|
5
src/common/Api/LeCoffreApi/Admin/BaseAdmin.ts
Normal file
5
src/common/Api/LeCoffreApi/Admin/BaseAdmin.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseAdmin extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/admin");
|
||||||
|
}
|
94
src/common/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes.ts
Normal file
94
src/common/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostDeedTypesParams = {
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IGetDeedTypesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseAdmin {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new DeedTypes();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/common/Api/LeCoffreApi/Admin/Deeds/Deeds.ts
Normal file
49
src/common/Api/LeCoffreApi/Admin/Deeds/Deeds.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Deed } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetDeedsParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Deeds();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string;
|
||||||
|
office: {
|
||||||
|
uid: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseAdmin {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: DocumentType): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/common/Api/LeCoffreApi/Admin/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/Admin/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
import { Document } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseAdmin {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/common/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts
Normal file
81
src/common/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
import { OfficeRole } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetRolesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutRoleParams = {
|
||||||
|
uid: OfficeRole["uid"];
|
||||||
|
rules: OfficeRole["rules"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostRoleParams = {
|
||||||
|
name: OfficeRole["name"];
|
||||||
|
office: OfficeRole["office"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class OfficeRoles extends BaseAdmin {
|
||||||
|
private static instance: OfficeRoles;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/office-roles");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new OfficeRoles();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetRolesParams): Promise<OfficeRole[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeRole[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeRole> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeRole>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutRoleParams): Promise<OfficeRole> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<OfficeRole>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostRoleParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<OfficeRole>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
src/common/Api/LeCoffreApi/Admin/Roles/Roles.ts
Normal file
96
src/common/Api/LeCoffreApi/Admin/Roles/Roles.ts
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import { Role } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetRolesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutRoleParams = {
|
||||||
|
uid: Role["uid"];
|
||||||
|
rules: Role["rules"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostRoleParams = {
|
||||||
|
name: Role["name"];
|
||||||
|
};
|
||||||
|
export default class Roles extends BaseAdmin {
|
||||||
|
private static instance: Roles;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/roles");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Roles();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetRolesParams): Promise<Role[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Role[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostRoleParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Role>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOne(q?: IGetRolesParams): Promise<Role | null> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await this.getRequest<Role[]>(url);
|
||||||
|
if (!res) return null;
|
||||||
|
if (res.length > 1) throw new Error("More than one role found");
|
||||||
|
return res[0] ? res[0] : null;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Role> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Role>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutRoleParams): Promise<Role> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Role>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/common/Api/LeCoffreApi/Admin/Rules/Rules.ts
Normal file
49
src/common/Api/LeCoffreApi/Admin/Rules/Rules.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Rule } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetRulesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Rules extends BaseAdmin {
|
||||||
|
private static instance: Rules;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/rules");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Rules();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetRulesParams): Promise<Rule[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Rule[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Rule> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Rule>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
91
src/common/Api/LeCoffreApi/Admin/Users/Users.ts
Normal file
91
src/common/Api/LeCoffreApi/Admin/Users/Users.ts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetUsersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutUsersParams = {
|
||||||
|
uid?: User["uid"];
|
||||||
|
idNot?: User["idNot"];
|
||||||
|
contact?: User["contact"];
|
||||||
|
office_membership?: User["office_membership"];
|
||||||
|
documents?: User["documents"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Users extends BaseAdmin {
|
||||||
|
private static instance: Users;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all Users
|
||||||
|
*/
|
||||||
|
public async get(q: IGetUsersparams): Promise<User[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a User
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutUsersParams): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<User>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/common/Api/LeCoffreApi/Customer/BaseCustomer.ts
Normal file
5
src/common/Api/LeCoffreApi/Customer/BaseCustomer.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseNotary extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/customer");
|
||||||
|
}
|
67
src/common/Api/LeCoffreApi/Customer/Customers/Customers.ts
Normal file
67
src/common/Api/LeCoffreApi/Customer/Customers/Customers.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import Customer, { Contact } from "le-coffre-resources/dist/Customer";
|
||||||
|
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetCustomersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutCustomersParams = {
|
||||||
|
uid?: Customer["uid"];
|
||||||
|
contact?: Customer["contact"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostCustomersParams {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
cell_phone_number: string;
|
||||||
|
civility: ECivility;
|
||||||
|
address?: Contact["address"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Customers extends BaseCustomer {
|
||||||
|
private static instance: Customers;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/common/Api/LeCoffreApi/Customer/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/Customer/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { Document } from "le-coffre-resources/dist/Customer";
|
||||||
|
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseCustomer {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/common/Api/LeCoffreApi/Customer/Files/Files.ts
Normal file
93
src/common/Api/LeCoffreApi/Customer/Files/Files.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { File } from "le-coffre-resources/dist/Customer";
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFilesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutFilesParams = {};
|
||||||
|
|
||||||
|
export interface IPostFilesParams {}
|
||||||
|
|
||||||
|
export default class Files extends BaseCustomer {
|
||||||
|
private static instance: Files;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/files");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return (this.instance ??= new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetFilesparams): Promise<File[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const files = await this.getRequest<File[]>(url);
|
||||||
|
return files;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a File
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequestFormData<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getUploadLink(uid: string): string {
|
||||||
|
return this.baseURl.concat(`/download/${uid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const file = await this.getRequest<File>(url);
|
||||||
|
return file;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutFilesParams): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<File>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
src/common/Api/LeCoffreApi/Customer/Folders/Folders.ts
Normal file
57
src/common/Api/LeCoffreApi/Customer/Folders/Folders.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import { type OfficeFolder } from "le-coffre-resources/dist/Customer";
|
||||||
|
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFoldersParams {
|
||||||
|
q?: {
|
||||||
|
select?: {};
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Folders extends BaseCustomer {
|
||||||
|
private static instance: Folders;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all folders
|
||||||
|
*/
|
||||||
|
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/common/Api/LeCoffreApi/Customer/Users/Users.ts
Normal file
49
src/common/Api/LeCoffreApi/Customer/Users/Users.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import BaseNotary from "../BaseCustomer";
|
||||||
|
import User from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
export default class Users extends BaseNotary {
|
||||||
|
private static instance: Users;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/Users");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Users();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(): Promise<User[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOne(uid: string): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// public async post(params: User): Promise<User> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<User>(url, params);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
5
src/common/Api/LeCoffreApi/Notary/BaseNotary.ts
Normal file
5
src/common/Api/LeCoffreApi/Notary/BaseNotary.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseNotary extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/notary");
|
||||||
|
}
|
90
src/common/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
90
src/common/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Contact, Customer } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetCustomersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutCustomersParams = {
|
||||||
|
uid?: Customer["uid"];
|
||||||
|
contact?: Customer["contact"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostCustomersParams {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
cell_phone_number: string;
|
||||||
|
civility: ECivility;
|
||||||
|
address?: Contact["address"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Customers extends BaseNotary {
|
||||||
|
private static instance: Customers;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Customer
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
src/common/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
84
src/common/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostDeedTypesParams = {
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IGetDeedTypesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseNotary {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new DeedTypes();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
72
src/common/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
72
src/common/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseNotary";
|
||||||
|
|
||||||
|
export type IGetDeedsParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutDeedsParams = {
|
||||||
|
uid?: OfficeFolder["uid"];
|
||||||
|
folder_number?: OfficeFolder["folder_number"];
|
||||||
|
name?: OfficeFolder["name"];
|
||||||
|
description?: OfficeFolder["description"];
|
||||||
|
archived_description?: OfficeFolder["archived_description"];
|
||||||
|
status?: OfficeFolder["status"];
|
||||||
|
document_types?: Deed["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Deeds();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Deed>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string | null;
|
||||||
|
office?: {
|
||||||
|
uid?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseNotary {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/common/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
import { Document } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseNotary {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
119
src/common/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
119
src/common/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
import { type OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFoldersParams {
|
||||||
|
q?: {
|
||||||
|
select?: {};
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Folders extends BaseNotary {
|
||||||
|
private static instance: Folders;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all folders
|
||||||
|
*/
|
||||||
|
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a folder
|
||||||
|
*/
|
||||||
|
public async post(officeFolder: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest(url, officeFolder);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const targetedFolder = await this.getByUid(uid);
|
||||||
|
if (targetedFolder.customers) return Promise.reject(`The folder ${uid} contains customers`);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async archive(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
body.status = EFolderStatus.ARCHIVED;
|
||||||
|
try {
|
||||||
|
return await this.put(uid, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async restore(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
body.status = EFolderStatus.LIVE;
|
||||||
|
try {
|
||||||
|
return await this.put(uid, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
src/common/Api/LeCoffreApi/Notary/Users/Users.ts
Normal file
48
src/common/Api/LeCoffreApi/Notary/Users/Users.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import User from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
export type IGetUsersParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Users extends BaseNotary {
|
||||||
|
private static instance: Users;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Users();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetUsersParams): Promise<User[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/common/Api/LeCoffreApi/SuperAdmin/BaseSuperAdmin.ts
Normal file
5
src/common/Api/LeCoffreApi/SuperAdmin/BaseSuperAdmin.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseSuperAdmin extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/super-admin");
|
||||||
|
}
|
90
src/common/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts
Normal file
90
src/common/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Contact, Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetCustomersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutCustomersParams = {
|
||||||
|
uid?: Customer["uid"];
|
||||||
|
contact?: Customer["contact"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostCustomersParams {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
cell_phone_number: string;
|
||||||
|
civility: ECivility;
|
||||||
|
address?: Contact["address"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Customers extends BaseSuperAdmin {
|
||||||
|
private static instance: Customers;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Customer
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
92
src/common/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts
Normal file
92
src/common/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDeedTypesParams {
|
||||||
|
q?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseSuperAdmin {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all DeedTypes
|
||||||
|
*/
|
||||||
|
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if(q){
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a deed
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedTypesParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
90
src/common/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts
Normal file
90
src/common/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDeedsParams {
|
||||||
|
q?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDeedsParams = {
|
||||||
|
uid?: OfficeFolder["uid"];
|
||||||
|
folder_number?: OfficeFolder["folder_number"];
|
||||||
|
name?: OfficeFolder["name"];
|
||||||
|
description?: OfficeFolder["description"];
|
||||||
|
archived_description?: OfficeFolder["archived_description"];
|
||||||
|
status?: OfficeFolder["status"];
|
||||||
|
document_types?: Deed["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseSuperAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all deeds
|
||||||
|
*/
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a deed
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Deed>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string;
|
||||||
|
office: {
|
||||||
|
uid: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseSuperAdmin {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/common/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts
Normal file
93
src/common/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { Document } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseSuperAdmin {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/common/Api/LeCoffreApi/SuperAdmin/Files/Files.ts
Normal file
93
src/common/Api/LeCoffreApi/SuperAdmin/Files/Files.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { File } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFilesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutFilesParams = {};
|
||||||
|
|
||||||
|
export interface IPostFilesParams {}
|
||||||
|
|
||||||
|
export default class Files extends BaseSuperAdmin {
|
||||||
|
private static instance: Files;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/files");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return (this.instance ??= new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetFilesparams): Promise<File[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const files = await this.getRequest<File[]>(url);
|
||||||
|
return files;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a File
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequestFormData<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getUploadLink(uid: string): string {
|
||||||
|
return this.baseURl.concat(`/download/${uid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const file = await this.getRequest<File>(url);
|
||||||
|
return file;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutFilesParams): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<File>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
119
src/common/Api/LeCoffreApi/SuperAdmin/Folders/Folders.ts
Normal file
119
src/common/Api/LeCoffreApi/SuperAdmin/Folders/Folders.ts
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
import { type OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFoldersParams {
|
||||||
|
q?: {
|
||||||
|
select?: {};
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Folders extends BaseSuperAdmin {
|
||||||
|
private static instance: Folders;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all folders
|
||||||
|
*/
|
||||||
|
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a folder
|
||||||
|
*/
|
||||||
|
public async post(officeFolder: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest(url, officeFolder);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const targetedFolder = await this.getByUid(uid);
|
||||||
|
if (targetedFolder.customers) return Promise.reject(`The folder ${uid} contains customers`);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async archive(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
body.status = EFolderStatus.ARCHIVED;
|
||||||
|
try {
|
||||||
|
return await this.put(uid, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async restore(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
body.status = EFolderStatus.LIVE;
|
||||||
|
try {
|
||||||
|
return await this.put(uid, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/common/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts
Normal file
49
src/common/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Appointment } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetLiveVotessparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IPostLiveVotesParams = {
|
||||||
|
appointment: Appointment;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LiveVote = {
|
||||||
|
uid: string;
|
||||||
|
appointment: Appointment;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class LiveVotes extends BaseSuperAdmin {
|
||||||
|
private static instance: LiveVotes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/live-votes");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a LiveVotes
|
||||||
|
*/
|
||||||
|
public async post(body: IPostLiveVotesParams): Promise<LiveVote> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<LiveVote>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
53
src/common/Api/LeCoffreApi/SuperAdmin/Offices/Offices.ts
Normal file
53
src/common/Api/LeCoffreApi/SuperAdmin/Offices/Offices.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { Office } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
export interface IGetOfficesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Offices extends BaseSuperAdmin {
|
||||||
|
private static instance: Offices;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/offices");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetOfficesparams): Promise<Office[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Office[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Office> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Office>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
91
src/common/Api/LeCoffreApi/SuperAdmin/Users/Users.ts
Normal file
91
src/common/Api/LeCoffreApi/SuperAdmin/Users/Users.ts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetUsersparams {
|
||||||
|
where?:{},
|
||||||
|
include?:{},
|
||||||
|
select?:{},
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutUsersParams = {
|
||||||
|
uid?: User["uid"];
|
||||||
|
idNot?: User["idNot"];
|
||||||
|
contact?: User["contact"];
|
||||||
|
office_membership?: User["office_membership"];
|
||||||
|
documents?: User["documents"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Users extends BaseSuperAdmin {
|
||||||
|
private static instance: Users;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all Users
|
||||||
|
*/
|
||||||
|
public async get(q: IGetUsersparams): Promise<User[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a User
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutUsersParams): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<User>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
src/common/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts
Normal file
44
src/common/Api/LeCoffreApi/SuperAdmin/Votes/Votes.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { Vote } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetVotessparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IDeleteVotesParams = {
|
||||||
|
uid: Vote["uid"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Votes extends BaseSuperAdmin {
|
||||||
|
private static instance: Votes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/votes");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Votes
|
||||||
|
*/
|
||||||
|
public async delete(body: IDeleteVotesParams): Promise<Vote> {
|
||||||
|
const url = new URL(this.baseURl + "/" + body.uid);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Vote>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
118
src/front/Api/Auth/Customer/Auth.ts
Normal file
118
src/front/Api/Auth/Customer/Auth.ts
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
import { ICustomerTokens } from "../Id360/Customers/Customers";
|
||||||
|
import { TotpCodesReasons } from "le-coffre-resources/dist/Customer/TotpCodes";
|
||||||
|
|
||||||
|
export type IMailVerifyParams = {
|
||||||
|
email: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IMailVerifyReturn = {
|
||||||
|
partialPhoneNumber: string;
|
||||||
|
totpCodeUid: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IVerifyTotpCodeParams = {
|
||||||
|
totpCode: string;
|
||||||
|
email: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IVerifyTotpCodeReturn = {
|
||||||
|
validCode: boolean;
|
||||||
|
reason: TotpCodesReasons;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ISetPasswordParams = {
|
||||||
|
password: string;
|
||||||
|
email: string;
|
||||||
|
totpCode: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ILoginParams = {
|
||||||
|
password: string;
|
||||||
|
email: string;
|
||||||
|
totpCode: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IAskNewPasswordParams = {
|
||||||
|
email: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IAskAnotherCodeParams = {
|
||||||
|
email: string;
|
||||||
|
totpCodeUid: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IAskAnotherCodeReturn = {
|
||||||
|
partialPhoneNumber: string;
|
||||||
|
totpCodeUid: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Auth extends BaseApiService {
|
||||||
|
private static instance: Auth;
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/customer");
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/auth");
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return (this.instance ??= new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async mailVerifySms(body: IMailVerifyParams): Promise<IMailVerifyReturn> {
|
||||||
|
const url = new URL(this.baseURl.concat("/mail/verify-sms"));
|
||||||
|
try {
|
||||||
|
return this.postRequest<IMailVerifyReturn>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async verifyTotpCode(body: IVerifyTotpCodeParams): Promise<IVerifyTotpCodeReturn> {
|
||||||
|
const url = new URL(this.baseURl.concat("/verify-totp-code"));
|
||||||
|
try {
|
||||||
|
return this.postRequest<IVerifyTotpCodeReturn>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async setPassword(body: ISetPasswordParams): Promise<ICustomerTokens> {
|
||||||
|
const url = new URL(this.baseURl.concat("/set-password"));
|
||||||
|
try {
|
||||||
|
return this.postRequest<ICustomerTokens>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async login(body: ILoginParams): Promise<ICustomerTokens> {
|
||||||
|
const url = new URL(this.baseURl.concat("/login"));
|
||||||
|
try {
|
||||||
|
return this.postRequest<ICustomerTokens>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async askNewPassword(body: IAskNewPasswordParams): Promise<IMailVerifyReturn> {
|
||||||
|
const url = new URL(this.baseURl.concat("/ask-new-password"));
|
||||||
|
try {
|
||||||
|
return this.postRequest<IMailVerifyReturn>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendAnotherCode(body: IAskAnotherCodeParams): Promise<IAskAnotherCodeReturn> {
|
||||||
|
const url = new URL(this.baseURl.concat("/send-another-code"));
|
||||||
|
try {
|
||||||
|
return this.postRequest<IAskAnotherCodeReturn>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/front/Api/Auth/Id360/BaseId360.ts
Normal file
5
src/front/Api/Auth/Id360/BaseId360.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseNotary extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/id360");
|
||||||
|
}
|
50
src/front/Api/Auth/Id360/Customers/Customers.ts
Normal file
50
src/front/Api/Auth/Id360/Customers/Customers.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import BaseId360 from "../BaseId360";
|
||||||
|
|
||||||
|
export interface IConnectionUrlResponse {
|
||||||
|
enrollment: {
|
||||||
|
franceConnectUrl: string;
|
||||||
|
processId: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICustomerTokens {
|
||||||
|
accessToken: string;
|
||||||
|
refreshToken: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Customers extends BaseId360 {
|
||||||
|
private static instance: Customers;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async login(): Promise<IConnectionUrlResponse> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/login`));
|
||||||
|
try {
|
||||||
|
return await this.postRequest<IConnectionUrlResponse>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async loginCallback(callbackToken: string | string[]): Promise<ICustomerTokens> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/login-callback/${callbackToken}`));
|
||||||
|
try {
|
||||||
|
return await this.postRequest<ICustomerTokens>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
src/front/Api/Auth/IdNot/User.ts
Normal file
38
src/front/Api/Auth/IdNot/User.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default class User extends BaseApiService {
|
||||||
|
private static instance: User;
|
||||||
|
private readonly baseURl = `${this.getBaseUrl()}/idnot/user`;
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new User();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async login(uid: string) {
|
||||||
|
const url = new URL(`${this.baseURl}/login/${uid}`);
|
||||||
|
try {
|
||||||
|
return await this.postRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async verifyJwt(jwt: string) {
|
||||||
|
const url = new URL(`${this.baseURl}/verify-token/${jwt}`);
|
||||||
|
try {
|
||||||
|
return await this.postRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
src/front/Api/Auth/IdNot/index.ts
Normal file
51
src/front/Api/Auth/IdNot/index.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
||||||
|
//import User from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
export default class Auth extends BaseApiService {
|
||||||
|
private static instance: Auth;
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance(): Auth {
|
||||||
|
return (this.instance = this.instance ?? new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async logOutWithIdNot() {
|
||||||
|
const variables = FrontendVariables.getInstance();
|
||||||
|
const url = new URL(`${variables.IDNOT_BASE_URL}/user/auth/logout?post_logout_redirect_uri=${variables.FRONT_APP_HOST}`);
|
||||||
|
try {
|
||||||
|
return await fetch(url);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async loginWithIdNot() {
|
||||||
|
const variables = FrontendVariables.getInstance();
|
||||||
|
const url = new URL(`${variables.IDNOT_BASE_URL + variables.IDNOT_AUTHORIZE_ENDPOINT}?client_id=${variables.IDNOT_CLIENT_ID}&redirect_uri=${variables.FRONT_APP_HOST}/authorized-client&scope=openid,profile&response_type=code`);
|
||||||
|
try {
|
||||||
|
return await this.getRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getIdnotJwt(autorizationCode: string | string[]): Promise<{accessToken: string, refreshToken: string}> {
|
||||||
|
const variables = FrontendVariables.getInstance();
|
||||||
|
const baseBackUrl = variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
|
||||||
|
const url = new URL(`${baseBackUrl}/api/v1/idnot/user/${autorizationCode}`);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<{accessToken: string, refreshToken: string}>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
164
src/front/Api/BaseApiService.ts
Normal file
164
src/front/Api/BaseApiService.ts
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
import { FrontendVariables } from "@Front/Config/VariablesFront";
|
||||||
|
import CookieService from "@Front/Services/CookieService/CookieService";
|
||||||
|
|
||||||
|
export enum ContentType {
|
||||||
|
JSON = "application/json",
|
||||||
|
PDF = "application/pdf",
|
||||||
|
FORM_DATA = "multipart/form-data;",
|
||||||
|
PNG = "image/png",
|
||||||
|
}
|
||||||
|
export default abstract class BaseApiService {
|
||||||
|
private static baseUrl: string;
|
||||||
|
protected readonly variables = FrontendVariables.getInstance();
|
||||||
|
|
||||||
|
protected constructor() {
|
||||||
|
BaseApiService.baseUrl ??=
|
||||||
|
this.variables.BACK_API_PROTOCOL +
|
||||||
|
this.variables.BACK_API_HOST +
|
||||||
|
this.variables.BACK_API_ROOT_URL +
|
||||||
|
this.variables.BACK_API_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getBaseUrl(): string {
|
||||||
|
return BaseApiService.baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected buildHeaders(contentType: ContentType) {
|
||||||
|
const token = CookieService.getInstance().getCookie("leCoffreAccessToken");
|
||||||
|
|
||||||
|
const headers = new Headers();
|
||||||
|
|
||||||
|
if (contentType === ContentType.JSON || contentType === ContentType.PDF) {
|
||||||
|
headers.set("Content-Type", contentType);
|
||||||
|
}
|
||||||
|
headers.set("Authorization", `Bearer ${token}`);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected buildBody(body: { [key: string]: unknown }): string {
|
||||||
|
return JSON.stringify(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async getRequest<T>(url: URL, token?: string, contentType?: ContentType, filename?: string) {
|
||||||
|
const request = async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "GET",
|
||||||
|
headers: this.buildHeaders(contentType ?? ContentType.JSON),
|
||||||
|
});
|
||||||
|
return this.sendRequest<T>(request, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async postRequest<T>(url: URL, body: { [key: string]: unknown } = {}, token?: string) {
|
||||||
|
return this.sendRequest<T>(
|
||||||
|
async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: this.buildHeaders(ContentType.JSON),
|
||||||
|
body: this.buildBody(body),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async postRequestFormData<T>(url: URL, body: FormData) {
|
||||||
|
return this.sendRequest<T>(
|
||||||
|
async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: this.buildHeaders(ContentType.FORM_DATA),
|
||||||
|
body,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async putRequest<T>(url: URL, body: { [key: string]: unknown } = {}, token?: string) {
|
||||||
|
const request = async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: this.buildHeaders(ContentType.JSON),
|
||||||
|
body: this.buildBody(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.sendRequest<T>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async patchRequest<T>(url: URL, body: { [key: string]: unknown } = {}) {
|
||||||
|
const request = async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: this.buildHeaders(ContentType.JSON),
|
||||||
|
body: this.buildBody(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.sendRequest<T>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async deleteRequest<T>(url: URL, body: { [key: string]: unknown } = {}, token?: string) {
|
||||||
|
const request = async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: this.buildHeaders(ContentType.JSON),
|
||||||
|
body: this.buildBody(body),
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.sendRequest<T>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async putFormDataRequest<T>(url: URL, body: FormData, token?: string) {
|
||||||
|
const request = async () =>
|
||||||
|
await fetch(url, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: this.buildHeaders(ContentType.FORM_DATA),
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.sendRequest<T>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async sendRequest<T>(request: () => Promise<Response>, filename?: string): Promise<T> {
|
||||||
|
const response = await request();
|
||||||
|
return this.processResponse<T>(response, request, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async processResponse<T>(response: Response, request: () => Promise<Response>, filename?: string): Promise<T> {
|
||||||
|
let responseContent: T;
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
// Check the Content-Type header to determine the response type
|
||||||
|
const contentType = response.headers.get("Content-Type");
|
||||||
|
|
||||||
|
if (contentType && !contentType.includes("application/json")) {
|
||||||
|
responseContent = (await response.blob()) as T;
|
||||||
|
} else {
|
||||||
|
// Handle JSON response
|
||||||
|
try {
|
||||||
|
responseContent = await response.json();
|
||||||
|
} catch (err) {
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Handle error response
|
||||||
|
const responseCopy = response.clone();
|
||||||
|
try {
|
||||||
|
const responseJson = await response.json();
|
||||||
|
return Promise.reject(responseJson);
|
||||||
|
} catch (err) {
|
||||||
|
const responseText = await responseCopy.text();
|
||||||
|
return Promise.reject({
|
||||||
|
http_status: response.status,
|
||||||
|
message: responseText,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onError(error: unknown) {
|
||||||
|
//console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IResponse {
|
||||||
|
http_status: number;
|
||||||
|
}
|
20
src/front/Api/Entities/rule.ts
Normal file
20
src/front/Api/Entities/rule.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
export interface IAppRule {
|
||||||
|
name: AppRuleNames;
|
||||||
|
action: AppRuleActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AppRuleActions {
|
||||||
|
read = "GET",
|
||||||
|
create = "POST",
|
||||||
|
update = "PUT",
|
||||||
|
delete = "DELETE",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AppRuleNames {
|
||||||
|
users = "users",
|
||||||
|
officeFolders = "folders",
|
||||||
|
officeRoles = "office-roles",
|
||||||
|
deedTypes = "deed-types",
|
||||||
|
offices = "offices",
|
||||||
|
documents = "documents",
|
||||||
|
}
|
5
src/front/Api/LeCoffreApi/Admin/BaseAdmin.ts
Normal file
5
src/front/Api/LeCoffreApi/Admin/BaseAdmin.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseAdmin extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/admin");
|
||||||
|
}
|
94
src/front/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes.ts
Normal file
94
src/front/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostDeedTypesParams = {
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IGetDeedTypesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseAdmin {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new DeedTypes();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/front/Api/LeCoffreApi/Admin/Deeds/Deeds.ts
Normal file
49
src/front/Api/LeCoffreApi/Admin/Deeds/Deeds.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Deed } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetDeedsParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Deeds();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string;
|
||||||
|
office: {
|
||||||
|
uid: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseAdmin {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: DocumentType): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/front/Api/LeCoffreApi/Admin/Documents/Documents.ts
Normal file
93
src/front/Api/LeCoffreApi/Admin/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
import { Document } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseAdmin {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts
Normal file
81
src/front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
import { OfficeRole } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetRolesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutRoleParams = {
|
||||||
|
uid: OfficeRole["uid"];
|
||||||
|
rules: OfficeRole["rules"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostRoleParams = {
|
||||||
|
name: OfficeRole["name"];
|
||||||
|
office: OfficeRole["office"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class OfficeRoles extends BaseAdmin {
|
||||||
|
private static instance: OfficeRoles;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/office-roles");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new OfficeRoles();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetRolesParams): Promise<OfficeRole[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeRole[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeRole> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeRole>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutRoleParams): Promise<OfficeRole> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<OfficeRole>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostRoleParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<OfficeRole>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
src/front/Api/LeCoffreApi/Admin/Roles/Roles.ts
Normal file
96
src/front/Api/LeCoffreApi/Admin/Roles/Roles.ts
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import { Role } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetRolesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutRoleParams = {
|
||||||
|
uid: Role["uid"];
|
||||||
|
rules: Role["rules"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostRoleParams = {
|
||||||
|
name: Role["name"];
|
||||||
|
};
|
||||||
|
export default class Roles extends BaseAdmin {
|
||||||
|
private static instance: Roles;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/roles");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Roles();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetRolesParams): Promise<Role[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Role[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostRoleParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Role>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getOne(q?: IGetRolesParams): Promise<Role | null> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await this.getRequest<Role[]>(url);
|
||||||
|
if (!res) return null;
|
||||||
|
if (res.length > 1) throw new Error("More than one role found");
|
||||||
|
return res[0] ? res[0] : null;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Role> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Role>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutRoleParams): Promise<Role> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Role>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/front/Api/LeCoffreApi/Admin/Rules/Rules.ts
Normal file
49
src/front/Api/LeCoffreApi/Admin/Rules/Rules.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { Rule } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
export type IGetRulesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Rules extends BaseAdmin {
|
||||||
|
private static instance: Rules;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/rules");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Rules();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetRulesParams): Promise<Rule[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Rule[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Rule> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Rule>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
91
src/front/Api/LeCoffreApi/Admin/Users/Users.ts
Normal file
91
src/front/Api/LeCoffreApi/Admin/Users/Users.ts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetUsersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutUsersParams = {
|
||||||
|
uid?: User["uid"];
|
||||||
|
idNot?: User["idNot"];
|
||||||
|
contact?: User["contact"];
|
||||||
|
office_membership?: User["office_membership"];
|
||||||
|
documents?: User["documents"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Users extends BaseAdmin {
|
||||||
|
private static instance: Users;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all Users
|
||||||
|
*/
|
||||||
|
public async get(q: IGetUsersparams): Promise<User[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a User
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutUsersParams): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<User>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/front/Api/LeCoffreApi/Customer/BaseCustomer.ts
Normal file
5
src/front/Api/LeCoffreApi/Customer/BaseCustomer.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseNotary extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/customer");
|
||||||
|
}
|
93
src/front/Api/LeCoffreApi/Customer/Documents/Documents.ts
Normal file
93
src/front/Api/LeCoffreApi/Customer/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { Document } from "le-coffre-resources/dist/Customer";
|
||||||
|
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseCustomer {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/front/Api/LeCoffreApi/Customer/Files/Files.ts
Normal file
93
src/front/Api/LeCoffreApi/Customer/Files/Files.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { File } from "le-coffre-resources/dist/Customer";
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFilesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutFilesParams = {};
|
||||||
|
|
||||||
|
export interface IPostFilesParams {}
|
||||||
|
|
||||||
|
export default class Files extends BaseCustomer {
|
||||||
|
private static instance: Files;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/files");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return (this.instance ??= new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetFilesparams): Promise<File[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const files = await this.getRequest<File[]>(url);
|
||||||
|
return files;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a File
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequestFormData<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getUploadLink(uid: string): string {
|
||||||
|
return this.baseURl.concat(`/download/${uid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const file = await this.getRequest<File>(url);
|
||||||
|
return file;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutFilesParams): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<File>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
58
src/front/Api/LeCoffreApi/Customer/Folders/Folders.ts
Normal file
58
src/front/Api/LeCoffreApi/Customer/Folders/Folders.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import { type OfficeFolder } from "le-coffre-resources/dist/Customer";
|
||||||
|
|
||||||
|
import BaseCustomer from "../BaseCustomer";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFoldersParams {
|
||||||
|
q?: {
|
||||||
|
select?: {};
|
||||||
|
where?: {};
|
||||||
|
orderBy?: {}[];
|
||||||
|
include?: {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Folders extends BaseCustomer {
|
||||||
|
private static instance: Folders;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all folders
|
||||||
|
*/
|
||||||
|
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/front/Api/LeCoffreApi/Notary/BaseNotary.ts
Normal file
5
src/front/Api/LeCoffreApi/Notary/BaseNotary.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseNotary extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/notary");
|
||||||
|
}
|
90
src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
90
src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Contact, Customer } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetCustomersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutCustomersParams = {
|
||||||
|
uid?: Customer["uid"];
|
||||||
|
contact?: Customer["contact"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostCustomersParams {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
cell_phone_number: string;
|
||||||
|
civility: ECivility;
|
||||||
|
address?: Contact["address"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Customers extends BaseNotary {
|
||||||
|
private static instance: Customers;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Customer
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
85
src/front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
85
src/front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostDeedTypesParams = {
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IGetDeedTypesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
orderBy?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseNotary {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new DeedTypes();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
72
src/front/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
72
src/front/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseNotary";
|
||||||
|
|
||||||
|
export type IGetDeedsParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutDeedsParams = {
|
||||||
|
uid?: OfficeFolder["uid"];
|
||||||
|
folder_number?: OfficeFolder["folder_number"];
|
||||||
|
name?: OfficeFolder["name"];
|
||||||
|
description?: OfficeFolder["description"];
|
||||||
|
archived_description?: OfficeFolder["archived_description"];
|
||||||
|
status?: OfficeFolder["status"];
|
||||||
|
document_types?: Deed["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Deeds();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Deed>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
orderBy?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string | null;
|
||||||
|
office?: {
|
||||||
|
uid?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseNotary {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
src/front/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
105
src/front/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
import { Document } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseNotary {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async refuse(uid: string, refused_reason: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}/refuse`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, {
|
||||||
|
refused_reason,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
103
src/front/Api/LeCoffreApi/Notary/Files/Files.ts
Normal file
103
src/front/Api/LeCoffreApi/Notary/Files/Files.ts
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
import { File } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFilesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutFilesParams = {};
|
||||||
|
|
||||||
|
export interface IPostFilesParams {}
|
||||||
|
|
||||||
|
export default class Files extends BaseNotary {
|
||||||
|
private static instance: Files;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/files");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return (this.instance ??= new this());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetFilesparams): Promise<File[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const files = await this.getRequest<File[]>(url);
|
||||||
|
return files;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a File
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequestFormData<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getUploadLink(uid: string): string {
|
||||||
|
return this.baseURl.concat(`/download/${uid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
const file = await this.getRequest<File>(url);
|
||||||
|
return file;
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutFilesParams): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<File>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<File> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<File>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async download(uid: string): Promise<any> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/download/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<any>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
130
src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
130
src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
import { type OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetFoldersParams {
|
||||||
|
q?: {
|
||||||
|
select?: {};
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Folders extends BaseNotary {
|
||||||
|
private static instance: Folders;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all folders
|
||||||
|
*/
|
||||||
|
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a folder
|
||||||
|
*/
|
||||||
|
public async post(officeFolder: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest(url, officeFolder);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const targetedFolder = await this.getByUid(uid);
|
||||||
|
if (targetedFolder.customers) return Promise.reject(`The folder ${uid} contains customers`);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async archive(uid: string, archived_description: string): Promise<OfficeFolder> {
|
||||||
|
try {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}/archive`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest(url, {
|
||||||
|
archived_description,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async restore(uid: string): Promise<OfficeFolder> {
|
||||||
|
try {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}/restore`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import { UserNotification } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetNotificationsParams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
orderBy?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type IPutNotificationsParams = {
|
||||||
|
read?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Notifications extends BaseNotary {
|
||||||
|
private static instance: Notifications;
|
||||||
|
private baseUrl = this.namespaceUrl.concat("/notifications");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetNotificationsParams): Promise<UserNotification[]> {
|
||||||
|
const url = new URL(this.baseUrl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<UserNotification[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutNotificationsParams): Promise<UserNotification> {
|
||||||
|
const url = new URL(this.baseUrl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<UserNotification>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
import { ContentType } from "@Front/Api/BaseApiService";
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import { OfficeFolderAnchor } from "le-coffre-resources/dist/Notary";
|
||||||
|
export interface IGetAnchorsParams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class OfficeFolderAnchors extends BaseNotary {
|
||||||
|
private static instance: OfficeFolderAnchors;
|
||||||
|
private readonly baseUrl = this.namespaceUrl.concat("/anchors");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetAnchorsParams): Promise<OfficeFolderAnchor[]> {
|
||||||
|
const url = new URL(this.baseUrl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolderAnchor[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string): Promise<OfficeFolderAnchor> {
|
||||||
|
const url = new URL(this.baseUrl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolderAnchor>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(uid: string): Promise<OfficeFolderAnchor> {
|
||||||
|
const url = new URL(this.baseUrl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.postRequest<OfficeFolderAnchor>(url, {});
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async download(uid: string): Promise<any> {
|
||||||
|
const url = new URL(this.baseUrl.concat(`/download/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<any>(url, undefined, ContentType.PDF, `${uid}.pdf`);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
src/front/Api/LeCoffreApi/Notary/Users/Users.ts
Normal file
48
src/front/Api/LeCoffreApi/Notary/Users/Users.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import User from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
export type IGetUsersParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Users extends BaseNotary {
|
||||||
|
private static instance: Users;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Users();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetUsersParams): Promise<User[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<User> {
|
||||||
|
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<User>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
src/front/Api/LeCoffreApi/SuperAdmin/BaseSuperAdmin.ts
Normal file
5
src/front/Api/LeCoffreApi/SuperAdmin/BaseSuperAdmin.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import BaseApiService from "@Front/Api/BaseApiService";
|
||||||
|
|
||||||
|
export default abstract class BaseSuperAdmin extends BaseApiService {
|
||||||
|
protected readonly namespaceUrl = this.getBaseUrl().concat("/super-admin");
|
||||||
|
}
|
90
src/front/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts
Normal file
90
src/front/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Contact, Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetCustomersparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutCustomersParams = {
|
||||||
|
uid?: Customer["uid"];
|
||||||
|
contact?: Customer["contact"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostCustomersParams {
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
email: string;
|
||||||
|
cell_phone_number: string;
|
||||||
|
civility: ECivility;
|
||||||
|
address?: Contact["address"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Customers extends BaseSuperAdmin {
|
||||||
|
private static instance: Customers;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/customers");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetCustomersparams): Promise<Customer[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Customer
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Customer>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
92
src/front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts
Normal file
92
src/front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDeedTypesParams {
|
||||||
|
q?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseSuperAdmin {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all DeedTypes
|
||||||
|
*/
|
||||||
|
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if(q){
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a deed
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedTypesParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
90
src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts
Normal file
90
src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDeedsParams {
|
||||||
|
q?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDeedsParams = {
|
||||||
|
uid?: OfficeFolder["uid"];
|
||||||
|
folder_number?: OfficeFolder["folder_number"];
|
||||||
|
name?: OfficeFolder["name"];
|
||||||
|
description?: OfficeFolder["description"];
|
||||||
|
archived_description?: OfficeFolder["archived_description"];
|
||||||
|
status?: OfficeFolder["status"];
|
||||||
|
document_types?: Deed["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseSuperAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all deeds
|
||||||
|
*/
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a deed
|
||||||
|
*/
|
||||||
|
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
|
||||||
|
// const url = new URL(this.baseURl);
|
||||||
|
// try {
|
||||||
|
// return await this.postRequest<OfficeFolder>(url, body);
|
||||||
|
// } catch (err) {
|
||||||
|
// this.onError(err);
|
||||||
|
// return Promise.reject(err);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Deed>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
|
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string;
|
||||||
|
office: {
|
||||||
|
uid: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseSuperAdmin {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user