From ad61f96d0e8368b9108e1c4094622e2a93645d04 Mon Sep 17 00:00:00 2001 From: runarvestmann Date: Thu, 12 Dec 2024 10:05:41 +0000 Subject: [PATCH 1/4] Init project --- apps/api/infra/api.ts | 3 + apps/api/src/app/app.module.ts | 4 + libs/api/domains/verdicts/.eslintrc.json | 18 + libs/api/domains/verdicts/README.md | 7 + libs/api/domains/verdicts/jest.config.ts | 11 + libs/api/domains/verdicts/project.json | 19 + libs/api/domains/verdicts/src/index.ts | 1 + .../verdicts/src/lib/verdicts.module.ts | 10 + .../verdicts/src/lib/verdicts.resolver.ts | 7 + .../verdicts/src/lib/verdicts.service.ts | 7 + libs/api/domains/verdicts/tsconfig.json | 22 + libs/api/domains/verdicts/tsconfig.lib.json | 16 + libs/api/domains/verdicts/tsconfig.spec.json | 14 + libs/clients/verdicts/.eslintrc.json | 18 + libs/clients/verdicts/README.md | 19 + libs/clients/verdicts/jest.config.ts | 11 + libs/clients/verdicts/project.json | 37 + libs/clients/verdicts/src/clientConfig.json | 2313 +++++++++++++++++ libs/clients/verdicts/src/index.ts | 3 + .../src/lib/verdicts-client.config.ts | 18 + .../src/lib/verdicts-client.module.ts | 9 + .../src/lib/verdicts-client.provider.ts | 29 + .../src/lib/verdicts-client.service.ts | 43 + libs/clients/verdicts/tsconfig.json | 22 + libs/clients/verdicts/tsconfig.lib.json | 16 + libs/clients/verdicts/tsconfig.spec.json | 14 + tsconfig.base.json | 4 + 27 files changed, 2695 insertions(+) create mode 100644 libs/api/domains/verdicts/.eslintrc.json create mode 100644 libs/api/domains/verdicts/README.md create mode 100644 libs/api/domains/verdicts/jest.config.ts create mode 100644 libs/api/domains/verdicts/project.json create mode 100644 libs/api/domains/verdicts/src/index.ts create mode 100644 libs/api/domains/verdicts/src/lib/verdicts.module.ts create mode 100644 libs/api/domains/verdicts/src/lib/verdicts.resolver.ts create mode 100644 libs/api/domains/verdicts/src/lib/verdicts.service.ts create mode 100644 libs/api/domains/verdicts/tsconfig.json create mode 100644 libs/api/domains/verdicts/tsconfig.lib.json create mode 100644 libs/api/domains/verdicts/tsconfig.spec.json create mode 100644 libs/clients/verdicts/.eslintrc.json create mode 100644 libs/clients/verdicts/README.md create mode 100644 libs/clients/verdicts/jest.config.ts create mode 100644 libs/clients/verdicts/project.json create mode 100644 libs/clients/verdicts/src/clientConfig.json create mode 100644 libs/clients/verdicts/src/index.ts create mode 100644 libs/clients/verdicts/src/lib/verdicts-client.config.ts create mode 100644 libs/clients/verdicts/src/lib/verdicts-client.module.ts create mode 100644 libs/clients/verdicts/src/lib/verdicts-client.provider.ts create mode 100644 libs/clients/verdicts/src/lib/verdicts-client.service.ts create mode 100644 libs/clients/verdicts/tsconfig.json create mode 100644 libs/clients/verdicts/tsconfig.lib.json create mode 100644 libs/clients/verdicts/tsconfig.spec.json diff --git a/apps/api/infra/api.ts b/apps/api/infra/api.ts index 471e4f82759b..820b912863f1 100644 --- a/apps/api/infra/api.ts +++ b/apps/api/infra/api.ts @@ -394,6 +394,9 @@ export const serviceSetup = (services: { '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL', VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY', + // TODO: Add to AWS param store + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME', + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD', }) .xroad( AdrAndMachine, diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index 0cae9d7fa483..d9f845f41da1 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -204,6 +204,8 @@ import { UmbodsmadurSkuldaraModule } from '@island.is/api/domains/umbodsmadur-sk import { UmbodsmadurSkuldaraClientConfig } from '@island.is/clients/ums-cost-of-living-calculator' import { emailModuleConfig } from '@island.is/email-service' import { ZendeskServiceConfig } from '@island.is/clients/zendesk' +import { VerdictsClientConfig } from '@island.is/clients/verdicts' +import { VerdictsModule } from '@island.is/api/domains/verdicts' const environment = getConfig @@ -342,6 +344,7 @@ const environment = getConfig LawAndOrderModule, UmbodsmadurSkuldaraModule, HealthDirectorateModule, + VerdictsModule, ConfigModule.forRoot({ isGlobal: true, load: [ @@ -442,6 +445,7 @@ const environment = getConfig WorkAccidentClientConfig, ZendeskServiceConfig, emailModuleConfig, + VerdictsClientConfig, ], }), ], diff --git a/libs/api/domains/verdicts/.eslintrc.json b/libs/api/domains/verdicts/.eslintrc.json new file mode 100644 index 000000000000..632e9b0e2225 --- /dev/null +++ b/libs/api/domains/verdicts/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/api/domains/verdicts/README.md b/libs/api/domains/verdicts/README.md new file mode 100644 index 000000000000..de9f604470e9 --- /dev/null +++ b/libs/api/domains/verdicts/README.md @@ -0,0 +1,7 @@ +# api-domains-verdicts + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test api-domains-verdicts` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/api/domains/verdicts/jest.config.ts b/libs/api/domains/verdicts/jest.config.ts new file mode 100644 index 000000000000..6c5a2fe687d3 --- /dev/null +++ b/libs/api/domains/verdicts/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'api-domains-verdicts', + preset: '../../../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../../../coverage/libs/api/domains/verdicts', +} diff --git a/libs/api/domains/verdicts/project.json b/libs/api/domains/verdicts/project.json new file mode 100644 index 000000000000..2863c2170964 --- /dev/null +++ b/libs/api/domains/verdicts/project.json @@ -0,0 +1,19 @@ +{ + "name": "api-domains-verdicts", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/api/domains/verdicts/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/api/domains/verdicts/jest.config.ts" + } + } + } +} diff --git a/libs/api/domains/verdicts/src/index.ts b/libs/api/domains/verdicts/src/index.ts new file mode 100644 index 000000000000..406fc3fab9da --- /dev/null +++ b/libs/api/domains/verdicts/src/index.ts @@ -0,0 +1 @@ +export * from './lib/verdicts.module' diff --git a/libs/api/domains/verdicts/src/lib/verdicts.module.ts b/libs/api/domains/verdicts/src/lib/verdicts.module.ts new file mode 100644 index 000000000000..9990bf6e0537 --- /dev/null +++ b/libs/api/domains/verdicts/src/lib/verdicts.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common' +import { VerdictsClientModule } from '@island.is/clients/verdicts' +import { VerdictsResolver } from './verdicts.resolver' +import { VerdictsService } from './verdicts.service' + +@Module({ + imports: [VerdictsClientModule], + providers: [VerdictsResolver, VerdictsService], +}) +export class VerdictsModule {} diff --git a/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts b/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts new file mode 100644 index 000000000000..130d069f1f5f --- /dev/null +++ b/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts @@ -0,0 +1,7 @@ +import { Resolver } from '@nestjs/graphql' +import { VerdictsService } from './verdicts.service' + +@Resolver() +export class VerdictsResolver { + constructor(private readonly verdictsService: VerdictsService) {} +} diff --git a/libs/api/domains/verdicts/src/lib/verdicts.service.ts b/libs/api/domains/verdicts/src/lib/verdicts.service.ts new file mode 100644 index 000000000000..18799fc7d9cf --- /dev/null +++ b/libs/api/domains/verdicts/src/lib/verdicts.service.ts @@ -0,0 +1,7 @@ +import { Injectable } from '@nestjs/common' +import { VerdictsClientService } from '@island.is/clients/verdicts' + +@Injectable() +export class VerdictsService { + constructor(private readonly verdictsClientService: VerdictsClientService) {} +} diff --git a/libs/api/domains/verdicts/tsconfig.json b/libs/api/domains/verdicts/tsconfig.json new file mode 100644 index 000000000000..4022fd4d0ad7 --- /dev/null +++ b/libs/api/domains/verdicts/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/api/domains/verdicts/tsconfig.lib.json b/libs/api/domains/verdicts/tsconfig.lib.json new file mode 100644 index 000000000000..e6b77320ab6a --- /dev/null +++ b/libs/api/domains/verdicts/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "declaration": true, + "types": ["node"], + "target": "es2021", + "strictNullChecks": true, + "noImplicitAny": true, + "strictBindCallApply": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/libs/api/domains/verdicts/tsconfig.spec.json b/libs/api/domains/verdicts/tsconfig.spec.json new file mode 100644 index 000000000000..6668655fc397 --- /dev/null +++ b/libs/api/domains/verdicts/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/libs/clients/verdicts/.eslintrc.json b/libs/clients/verdicts/.eslintrc.json new file mode 100644 index 000000000000..3456be9b9036 --- /dev/null +++ b/libs/clients/verdicts/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/clients/verdicts/README.md b/libs/clients/verdicts/README.md new file mode 100644 index 000000000000..746c93e088a8 --- /dev/null +++ b/libs/clients/verdicts/README.md @@ -0,0 +1,19 @@ +# clients-verdicts + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test clients-verdicts` to execute the unit tests via [Jest](https://jestjs.io). + +### Updating the open api definition (clientConfig.json) + +```sh +yarn nx run clients-verdicts:update-openapi-document +``` + +### Regenerating the client: + +```sh +yarn nx run clients-verdicts:codegen/backend-client +``` diff --git a/libs/clients/verdicts/jest.config.ts b/libs/clients/verdicts/jest.config.ts new file mode 100644 index 000000000000..5cc456bf4f73 --- /dev/null +++ b/libs/clients/verdicts/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'clients-verdicts', + preset: '../../../jest.preset.js', + testEnvironment: 'node', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../../coverage/libs/clients/verdicts', +} diff --git a/libs/clients/verdicts/project.json b/libs/clients/verdicts/project.json new file mode 100644 index 000000000000..ad49687fc6e4 --- /dev/null +++ b/libs/clients/verdicts/project.json @@ -0,0 +1,37 @@ +{ + "name": "clients-verdicts", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/clients/verdicts/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/clients/verdicts/jest.config.ts" + } + }, + "update-openapi-document": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "curl https://foris.gopro.net/domssm/services/swagger/docs/v1 > src/clientConfig.json", + "prettier --write src/clientConfig.json" + ], + "parallel": false, + "cwd": "libs/clients/verdicts" + } + }, + "codegen/backend-client": { + "executor": "nx:run-commands", + "options": { + "command": "yarn openapi-generator -o libs/clients/verdicts/gen/fetch -i libs/clients/verdicts/src/clientConfig.json" + }, + "outputs": ["{projectRoot}/gen/fetch"] + } + } +} diff --git a/libs/clients/verdicts/src/clientConfig.json b/libs/clients/verdicts/src/clientConfig.json new file mode 100644 index 000000000000..d70f499e1101 --- /dev/null +++ b/libs/clients/verdicts/src/clientConfig.json @@ -0,0 +1,2313 @@ +{ + "swagger": "2.0", + "info": { + "version": "v1", + "title": "GoPro External Integration REST Services" + }, + "host": "foris.gopro.net", + "basePath": "/domssm/services", + "schemes": ["https"], + "paths": { + "/Case/GetCaseContacts": { + "post": { + "tags": ["Case"], + "summary": "Retrieve contacts associated with a specific case", + "operationId": "GetCaseContacts", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetCaseContactsRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetCaseContactsResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/CreateCase": { + "post": { + "tags": ["Case"], + "summary": "Create a new case in GoPro with linked contacts and documents attached.\r\nAPI: 1.0", + "operationId": "CreateCase", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/CreateCaseRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/CreateQuickCase": { + "post": { + "tags": ["Case"], + "summary": "Create a new case in GoPro", + "operationId": "CreateQuickCase", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/CreateQuickCaseRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/GetCase": { + "post": { + "tags": ["Case"], + "summary": "Retrieve basic info for specified GoPro case", + "operationId": "GetCase", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetCaseRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetCaseResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/UpdateCase": { + "post": { + "tags": ["Case"], + "summary": "Update a case by case number or record ID", + "operationId": "UpdateCase", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/UpdateCaseRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/GetUpdates": { + "post": { + "tags": ["Case"], + "summary": "Returns a list of cases that had been updated since startingDate argument.\r\nAPI: 1.0", + "operationId": "GetUpdates", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "required": true, + "schema": { "$ref": "#/definitions/StartingTimeRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/CasesResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/SearchCases": { + "post": { + "tags": ["Case"], + "summary": "Search cases by case template (optional) and contact. If template is not specified, search is not filtered by case type. Contact must be specified", + "operationId": "SearchCases", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/TemplateAndContactFilterRequest" + } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/CasesResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/LinkContactToCase": { + "post": { + "tags": ["Case"], + "summary": "Associate an individual or company contact with a case", + "operationId": "LinkContactToCase", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/LinkContactRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/GetFolder": { + "post": { + "tags": ["Case"], + "summary": "Returns information about a folder by specified folder name and parent ID", + "operationId": "GetFolder", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetFolderRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetFolderResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/GetDefaultStatus": { + "post": { + "tags": ["Case"], + "summary": "Returns default status for a list", + "operationId": "GetDefaultStatus", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetFormRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/NamedReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Case/CreateFolder": { + "post": { + "tags": ["Case"], + "summary": "Creates a folder under specified case", + "operationId": "CreateFolder", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/CreateFolderRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Clients/CreateCompany": { + "post": { + "tags": ["Clients"], + "summary": "Create a new company partner in GoPro", + "operationId": "CreateCompany", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/Company" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Clients/CreateIndividual": { + "post": { + "tags": ["Clients"], + "summary": "Create a new person (individual) partner in GoPro", + "operationId": "CreateIndividual", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/Individual" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Clients/CreateContact": { + "post": { + "tags": ["Clients"], + "summary": "Create a new partner contact in GoPro", + "operationId": "CreateContact", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/Contact" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Clients/GetCompany": { + "post": { + "tags": ["Clients"], + "summary": "Retrieve company info from GoPro", + "operationId": "GetCompany", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetClientRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetCompanyResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Clients/GetIndividual": { + "post": { + "tags": ["Clients"], + "summary": "Retrieve person (individual) parter info from GoPro", + "operationId": "GetIndividual", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetClientRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetIndividualResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Clients/GetContact": { + "post": { + "tags": ["Clients"], + "summary": "Retrieve contact info from GoPro", + "operationId": "GetContact", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetContactRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetContactResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Documents/CreateDocument": { + "post": { + "tags": ["Document"], + "summary": "Create a new file document in GoPro", + "operationId": "CreateDocument", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/CreateDocumentRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Forms/CreateForm": { + "post": { + "tags": ["Forms"], + "summary": "Create a new custom form (custom GoPro object type)\r\nAPI: 1.0", + "operationId": "CreateForm", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/CreateFormRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Forms/UpdateForm": { + "post": { + "tags": ["Forms"], + "summary": "Update an existing custom Gopro object / form\r\nAPI: 1.0", + "operationId": "UpdateForm", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/UpdateFormRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Forms/GetForm": { + "post": { + "tags": ["Forms"], + "summary": "Retrieve a custom Gopro object / form\r\nAPI: 1.0", + "operationId": "GetForm", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/GetFormRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetFormResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Memos/CreateMemo": { + "post": { + "tags": ["Memo"], + "summary": "Create a new GoPro memo", + "operationId": "CreateMemo", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "description": "", + "required": true, + "schema": { "$ref": "#/definitions/CreateMemoRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Authenticate": { + "get": { + "tags": ["Security"], + "summary": "Authenticate with username and password. Returns authenticationToken that is used when calling other API methods. API: 1.0", + "operationId": "Authenticate", + "consumes": [], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "username", + "in": "query", + "description": "The username", + "required": true, + "type": "string" + }, + { + "name": "password", + "in": "query", + "description": "The password", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { "description": "OK", "schema": { "type": "string" } } + } + } + }, + "/Verdict/getVerdicts": { + "post": { + "tags": ["Verdict"], + "operationId": "GetVerdicts", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "required": true, + "schema": { "$ref": "#/definitions/GetVerdictsRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetVerdictsResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Verdict/{id}": { + "get": { + "tags": ["Verdict"], + "operationId": "GetVerdict", + "consumes": [], + "produces": ["application/json", "text/json"], + "parameters": [ + { "name": "id", "in": "path", "required": true, "type": "string" }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetVerdictResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Verdict/publishVerdict": { + "post": { + "tags": ["Verdict"], + "operationId": "PublishVerdict", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "required": true, + "schema": { "$ref": "#/definitions/PublishVerdictRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Verdict/addVerdictDocument": { + "post": { + "tags": ["Verdict"], + "operationId": "AddVerdictDocument", + "consumes": ["application/json", "text/json"], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "requestData", + "in": "body", + "required": true, + "schema": { "$ref": "#/definitions/AddVerdictDocumentRequest" } + }, + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/ReferenceResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Verdict/getCaseTypes": { + "post": { + "tags": ["Verdict"], + "operationId": "GetCaseTypes", + "consumes": [], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetCaseTypesResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Verdict/getCaseCategories": { + "post": { + "tags": ["Verdict"], + "operationId": "GetCaseCategories", + "consumes": [], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetCaseCategoriesResponse" } + } + }, + "security": [{ "basic": [] }] + } + }, + "/Verdict/getKeywords": { + "post": { + "tags": ["Verdict"], + "operationId": "GetKeywords", + "consumes": [], + "produces": ["application/json", "text/json"], + "parameters": [ + { + "name": "Token", + "in": "header", + "description": "Token returned by Authenticate method.", + "required": false, + "type": "string", + "default": "" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { "$ref": "#/definitions/GetKeywordsResponse" } + } + }, + "security": [{ "basic": [] }] + } + } + }, + "definitions": { + "GetCaseContactsRequest": { + "description": "GetCaseContacts method request structure", + "type": "object", + "properties": { + "caseNumber": { + "description": "Case number or record ID", + "type": "string" + } + } + }, + "GetCaseContactsResponse": { + "description": "General case contacts response collection", + "type": "object", + "properties": { + "contacts": { + "description": "A collection of contact structures", + "type": "array", + "items": { "$ref": "#/definitions/CaseContact" } + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CaseContact": { + "description": "GoPro case contact data model", + "type": "object", + "properties": { + "contactID": { "description": "Contact ID", "type": "string" }, + "role": { "description": "This contact's role", "type": "string" }, + "primary": { + "description": "Indicates if this is the primary contact for a case", + "type": "string" + }, + "name": { "description": "This contact's name", "type": "string" }, + "idnumber": { + "description": "This contact's ID number", + "type": "string" + }, + "type": { "description": "The type of contact", "type": "string" }, + "address": { "description": "", "type": "string" }, + "email": { "description": "This contact's address", "type": "string" }, + "webPage": { + "description": "This contact's web page", + "type": "string" + }, + "phone": { "description": "This contact's phone", "type": "string" }, + "postalCode": { + "description": "This contact's postal code", + "type": "string" + }, + "city": { "description": "This contact's city", "type": "string" }, + "caseContactID": { "description": "Case Contact ID", "type": "string" } + } + }, + "CreateCaseRequest": { + "description": "CreateCase method request structure", + "required": ["template", "subject"], + "type": "object", + "properties": { + "template": { "description": "Case template name", "type": "string" }, + "subject": { + "description": "Subject (name) of the case", + "type": "string" + }, + "category": { "description": "Case category name", "type": "string" }, + "organization": { + "description": "Name path or ID of organization to search for the case template.\r\nUse special word \"all\" (lower case only) to look in all organizations.\r\nSkip parameter or pass empty to assume current user organization", + "type": "string" + }, + "deadline": { "description": "Deadline date", "type": "string" }, + "keywords": { + "description": "Keywords", + "type": "array", + "items": { "type": "string" } + }, + "journalKeys": { + "description": "Optional collection of related journal keys", + "type": "array", + "items": { "$ref": "#/definitions/JournalKey" } + }, + "metadata": { + "description": "List of metadata values", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + }, + "physicalLocation": { + "description": "Physical location (if existing and specified)", + "type": "string" + }, + "contacts": { + "description": "List of clients (individuals or companies) who will be linked to the case by different roles. If client is not registered (missing from system) - they will be created first", + "type": "array", + "items": { "$ref": "#/definitions/LinkedRoleContact" } + }, + "searchInactiveContacts": { + "description": "Optional. When true then searches for both active and inactive contacts. Default: false", + "type": "boolean" + }, + "documents": { + "description": "List of document attached under case", + "type": "array", + "items": { "$ref": "#/definitions/DocumentInfo" } + }, + "ignoreDefaultEmployees": { + "description": "When false then default employees for the case template are ignored and not assigned to the case on creation.\r\nWhen true default workers are added. Note that this flag has no effect on handling the ResponsibleEmployees list.\r\nThese are always assigned to the case.", + "type": "boolean" + }, + "responsibleEmployees": { + "description": "List of users that will be assigned as responsible workers for the case. The case template (see property) specifies default set of responsibles which may or may not be added to the case. See ", + "type": "array", + "items": { "$ref": "#/definitions/ResponsibleWorker" } + } + } + }, + "JournalKey": { + "description": "Journal key category", + "type": "object", + "properties": { + "journalKeyID": { + "format": "uuid", + "description": "Journal key ID", + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "isPrimary": { + "description": "Gets or sets binary flag for the journal key being a primary for the target", + "type": "boolean" + } + } + }, + "Metadata": { + "description": "Metadata value with definition reference", + "type": "object", + "properties": { + "definitionID": { + "description": "Metadata definition ID", + "type": "string" + }, + "name": { "description": "Name of the metadata", "type": "string" }, + "value": { + "description": "String representation of metadata value", + "type": "string" + }, + "valueType": { + "format": "int32", + "description": "Data type of the metadata (0: String (default), 1: Guid; 2: Integer; 3: DateTime; 4: Boolean; 5: Decimal (currency))", + "type": "integer" + } + } + }, + "LinkedRoleContact": { + "description": "Contact information. Used in relation with cases\r\nwhere multiple contacts can be linked by specific role and priority", + "required": ["name", "idnumber"], + "type": "object", + "properties": { + "role": { + "description": "Role for this contact relation", + "type": "string" + }, + "primary": { + "description": "Flag that shows whether contact is primary for the case (main involved party). Can be either false/true or 0/1 or nei/já or no/yes", + "type": "string" + }, + "id": { + "description": "Unique record ID (a GUID) of an existing contact", + "type": "string" + }, + "name": { + "description": "Full name of the person or company", + "type": "string" + }, + "idnumber": { + "description": "National identification number", + "type": "string" + }, + "type": { + "description": "Type of client. Possible values: Individual, Company, Contact", + "type": "string" + }, + "address": { + "description": "Street address of the client", + "type": "string" + }, + "email": { "description": "Email address", "type": "string" }, + "webPage": { + "description": "Web address, home page", + "type": "string" + }, + "phone": { + "description": "Main (default) phone number for contact", + "type": "string" + }, + "postalCode": { "description": "Postal code", "type": "string" }, + "city": { "description": "City name", "type": "string" } + } + }, + "DocumentInfo": { + "description": "GoPro document", + "type": "object", + "properties": { + "subject": { + "description": "Subject (title) of the document", + "type": "string" + }, + "type": { + "description": "Document class name. One of the values in \"Document classes\" GoPro list", + "type": "string" + }, + "fileName": { + "description": "File name of the document content uploaded", + "type": "string" + }, + "content": { + "description": "Binary content represented as Base64 encoded string", + "type": "string" + }, + "metadata": { + "description": "List of metadata values", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + } + } + }, + "ResponsibleWorker": { + "description": "Represents a GoPro user. Used for denoting a case responsible worker", + "type": "object", + "properties": { + "userId": { "description": "Record ID of the user", "type": "string" }, + "primary": { + "description": "Flag that shows whether this user is the primary responsible for the case. Can be either false/true or 0/1 or nei/já or no/yes", + "type": "boolean" + } + } + }, + "ReferenceResponse": { + "description": "General GoPro reference response", + "type": "object", + "properties": { + "identifier": { + "description": "GoPro target record id", + "type": "string" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CreateQuickCaseRequest": { + "description": "CreateQuickCase method request structure", + "required": ["template", "subject"], + "type": "object", + "properties": { + "template": { "description": "Case template name", "type": "string" }, + "subject": { + "description": "Subject (name) of the case", + "type": "string" + }, + "category": { "description": "Case category name", "type": "string" }, + "organization": { + "description": "Name path or ID of organization to search for the case template.\r\nUse special word \"all\" (lower case only) to look in all organizations.\r\nSkip parameter or pass empty to assume current user organization", + "type": "string" + }, + "deadline": { "description": "Deadline date", "type": "string" }, + "keywords": { + "description": "Keywords", + "type": "array", + "items": { "type": "string" } + }, + "journalKeys": { + "description": "Optional collection of related journal keys", + "type": "array", + "items": { "$ref": "#/definitions/JournalKey" } + }, + "metadata": { + "description": "List of metadata values", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + } + } + }, + "GetCaseRequest": { + "description": "GetCase method request structure", + "type": "object", + "properties": { + "caseNumber": { + "description": "Case number or record ID", + "type": "string" + }, + "caseName": { "description": "Subject of the case", "type": "string" }, + "caseTemplate": { + "description": "Case template name", + "type": "string" + } + } + }, + "GetCaseResponse": { + "description": "General single case response structure", + "type": "object", + "properties": { + "case": { + "$ref": "#/definitions/Case", + "description": "Case structure" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "Case": { + "description": "GoPro case data model", + "type": "object", + "properties": { + "subject": { "description": "Case subject (name)", "type": "string" }, + "archiveNumber": { "description": "Archive number", "type": "string" }, + "templateName": { + "description": "Name of case template", + "type": "string" + }, + "categoryName": { "description": "Case category", "type": "string" }, + "responsibleEmployeeName": { + "description": "User names of main responsible worker for the case", + "type": "string" + }, + "responsibleEmployeeID": { + "description": "Record ID of main responsible worker for the case", + "type": "string" + }, + "coResponsibleEmployees": { + "description": "List of other responsible workers for the case", + "type": "array", + "items": { "type": "string" } + }, + "priorityName": { "description": "Priority", "type": "string" }, + "personalSensitive": { + "description": "GDPR protection applied", + "type": "boolean" + }, + "confidential": { "description": "Confidentiality", "type": "boolean" }, + "body": { "description": "General comments", "type": "string" }, + "statusName": { "description": "Status", "type": "string" }, + "keywords": { + "description": "List of associated keywords", + "type": "array", + "items": { "type": "string" } + }, + "publishTo": { + "description": "Publish targets. A combination of one or more values:\r\nShowGeneral, ShowCitizen, HiddenIndividual, Teams", + "type": "array", + "items": { "type": "string" } + }, + "creationDate": { + "format": "date-time", + "description": "Date and time of case creation", + "type": "string" + }, + "createdByName": { + "description": "Name of the user who created the case", + "type": "string" + }, + "modifiedDate": { + "format": "date-time", + "description": "Date and time of latest edition", + "type": "string" + }, + "modifiedByName": { + "description": "Name of the user who last edited the case", + "type": "string" + }, + "closingDate": { + "format": "date-time", + "description": "Date and time when the case was closed.", + "type": "string" + }, + "metaDataEntries": { + "description": "List of related metadata with values", + "type": "array", + "items": { "$ref": "#/definitions/MetaValue" } + }, + "id": { + "description": "Unique record ID (a GUID) of the case in GoPro system", + "type": "string" + }, + "caseNumber": { "description": "Case number", "type": "string" } + } + }, + "MetaValue": { + "description": "Metadata value", + "type": "object", + "properties": { + "name": { "description": "Name of the metadata", "type": "string" }, + "value": { + "description": "String representation of metadata value", + "type": "string" + }, + "valueType": { + "format": "int32", + "description": "Data type of the metadata (0: String (default), 1: Guid; 2: Integer; 3: DateTime; 4: Boolean; 5: Decimal (currency))", + "type": "integer" + } + } + }, + "UpdateCaseRequest": { + "description": "UpdateCase method request structure", + "type": "object", + "properties": { + "caseId": { + "description": "Record id or case number of target case", + "type": "string" + }, + "subject": { + "description": "Subject (name) of the case", + "type": "string" + }, + "status": { "description": "Status name", "type": "string" }, + "metadata": { + "description": "Collection of associated metadata values with definitions", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + }, + "overwrite": { + "description": "Flag to control full overwriting of properties\r\nWhen true - all properties are cleared and reset with the new value. Missing properties will be cleared to empty/default value(s). Object should be retrieved first before updating\r\nWhen false - only passed arguments will be updated.", + "type": "boolean" + } + } + }, + "StartingTimeRequest": { + "description": "GetUpdates method request structure", + "type": "object", + "properties": { + "startingDate": { + "description": "Starting date limiter", + "type": "string" + } + } + }, + "CasesResponse": { + "description": "General case response collection", + "type": "object", + "properties": { + "cases": { + "description": "A collection of case structures", + "type": "array", + "items": { "$ref": "#/definitions/Case" } + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "TemplateAndContactFilterRequest": { + "description": "SearchCases method request structure", + "required": ["contactIdNumber"], + "type": "object", + "properties": { + "contactIdNumber": { + "description": "National identification number or GoPro record ID of target client that is expected to be linked to cases", + "type": "string" + }, + "caseTemplate": { + "description": "Name of case template to filter results. Optional. If not specified, cases of all types are searched.", + "type": "string" + } + } + }, + "LinkContactRequest": { + "description": "LinkContactToCase method request structure", + "type": "object", + "properties": { + "caseNumber": { + "description": "Case number or record id (GUID) of the target case", + "type": "string" + }, + "customerID": { + "description": "Record ID of the contact (individual/company) who needs to be linked", + "type": "string" + }, + "role": { + "description": "Role name for this contact relation. See \"Roles\" list in GoPro system for predefined roles", + "type": "string" + } + } + }, + "GetFolderRequest": { + "description": "GetFolder method request structure", + "type": "object", + "properties": { + "name": { "description": "Folder name", "type": "string" }, + "parentID": { + "description": "Record id of parent object to search under", + "type": "string" + } + } + }, + "GetFolderResponse": { + "description": "GetFolder method response structure", + "type": "object", + "properties": { + "folder": { + "$ref": "#/definitions/Folder", + "description": "Folder object" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "Folder": { + "description": "GoPro folder data model", + "type": "object", + "properties": { + "name": { "description": "Name of folder", "type": "string" }, + "journalkey": { "description": "Journal key", "type": "string" }, + "keywords": { + "description": "List of associated keywords", + "type": "array", + "items": { "type": "string" } + }, + "statusName": { "description": "Folder status", "type": "string" }, + "body": { "description": "Notes and comments", "type": "string" } + } + }, + "GetFormRequest": { + "description": "GetForm method request structure", + "type": "object", + "properties": { + "id": { "description": "Record ID of custom form", "type": "string" } + } + }, + "NamedReferenceResponse": { + "description": "General GoPro reference response with name", + "type": "object", + "properties": { + "name": { + "description": "Name (subject) of the record", + "type": "string" + }, + "identifier": { + "description": "GoPro target record id", + "type": "string" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CreateFolderRequest": { + "description": "CreateFolder method request structure", + "type": "object", + "properties": { + "caseNumber": { + "description": "Case number or record ID of the parent case", + "type": "string" + }, + "parentID": { + "description": "Record ID of the immediate parent under which will be placed this folder. When this is not the top case then is required", + "type": "string" + }, + "subject": { "description": "Folder name", "type": "string" }, + "body": { "description": "Description / comments", "type": "string" } + } + }, + "Company": { + "description": "A company partner", + "type": "object", + "properties": { + "name": { "description": "Company name", "type": "string" }, + "clientNumber": { "description": "Client number", "type": "string" }, + "webPage": { + "description": "Web address, home page", + "type": "string" + }, + "isatNumber": { "description": "ISAT Number", "type": "string" }, + "isatName": { "description": "ISAT Name", "type": "string" }, + "id": { + "description": "Unique record ID (a GUID) of the client", + "type": "string" + }, + "idNumber": { + "description": "National identification number", + "type": "string" + }, + "address": { + "description": "Street address of the client", + "type": "string" + }, + "postCode": { "description": "Postal code", "type": "string" }, + "city": { "description": "City", "type": "string" }, + "country": { "description": "Country name", "type": "string" }, + "language": { + "description": "Primary language used", + "type": "string" + }, + "mobilePhone": { + "description": "Mobile phone number", + "type": "string" + }, + "homePhone": { "description": "Home phone number", "type": "string" }, + "workPhone": { "description": "Work phone number", "type": "string" }, + "faxNumber": { "description": "Fax number", "type": "string" }, + "email": { "description": "Email address", "type": "string" }, + "statusName": { + "description": "GoPro status of the client", + "type": "string" + } + } + }, + "Individual": { + "description": "Data model for GoPro person (individual) partner", + "type": "object", + "properties": { + "firstName": { + "description": "First name of the person", + "type": "string" + }, + "middleName": { + "description": "Middle name of the person", + "type": "string" + }, + "lastName": { + "description": "Surname of the person", + "type": "string" + }, + "jobTitle": { "description": "Job title", "type": "string" }, + "id": { + "description": "Unique record ID (a GUID) of the client", + "type": "string" + }, + "idNumber": { + "description": "National identification number", + "type": "string" + }, + "address": { + "description": "Street address of the client", + "type": "string" + }, + "postCode": { "description": "Postal code", "type": "string" }, + "city": { "description": "City", "type": "string" }, + "country": { "description": "Country name", "type": "string" }, + "language": { + "description": "Primary language used", + "type": "string" + }, + "mobilePhone": { + "description": "Mobile phone number", + "type": "string" + }, + "homePhone": { "description": "Home phone number", "type": "string" }, + "workPhone": { "description": "Work phone number", "type": "string" }, + "faxNumber": { "description": "Fax number", "type": "string" }, + "email": { "description": "Email address", "type": "string" }, + "statusName": { + "description": "GoPro status of the client", + "type": "string" + } + } + }, + "Contact": { + "description": "Contact data model", + "type": "object", + "properties": { + "companyID": { + "description": "GoPro record ID of the company represented by this person", + "type": "string" + }, + "contactRole": { + "description": "Role of this contact relation", + "type": "string" + }, + "firstName": { + "description": "First name of contact person", + "type": "string" + }, + "middleName": { + "description": "Middle name of contact person", + "type": "string" + }, + "lastName": { + "description": "Surname of contact person", + "type": "string" + }, + "jobTitle": { "description": "Job title", "type": "string" }, + "id": { + "description": "Unique record ID (a GUID) of the client", + "type": "string" + }, + "idNumber": { + "description": "National identification number", + "type": "string" + }, + "address": { + "description": "Street address of the client", + "type": "string" + }, + "postCode": { "description": "Postal code", "type": "string" }, + "city": { "description": "City", "type": "string" }, + "country": { "description": "Country name", "type": "string" }, + "language": { + "description": "Primary language used", + "type": "string" + }, + "mobilePhone": { + "description": "Mobile phone number", + "type": "string" + }, + "homePhone": { "description": "Home phone number", "type": "string" }, + "workPhone": { "description": "Work phone number", "type": "string" }, + "faxNumber": { "description": "Fax number", "type": "string" }, + "email": { "description": "Email address", "type": "string" }, + "statusName": { + "description": "GoPro status of the client", + "type": "string" + } + } + }, + "GetClientRequest": { + "description": "Request for a single client (individual or company)", + "required": ["identifier"], + "type": "object", + "properties": { + "identifier": { + "description": "Identity number (SSN) or unique record ID (GUID) of the client", + "type": "string" + }, + "searchInactive": { + "description": "Optional. When true then search for inactive clients as well. Default is false.", + "type": "boolean" + } + } + }, + "GetCompanyResponse": { + "description": "GetCompany method response structure", + "type": "object", + "properties": { + "company": { + "$ref": "#/definitions/Company", + "description": "Company structure" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "GetIndividualResponse": { + "description": "GetIndividual method response structure", + "type": "object", + "properties": { + "individual": { + "$ref": "#/definitions/Individual", + "description": "Person (individual) object" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "GetContactRequest": { + "description": "GetContact method request structure", + "required": ["contactId"], + "type": "object", + "properties": { + "contactId": { + "description": "Unique record ID (GUID) of the contact or identity number (SSN) of the related individual", + "type": "string" + }, + "companyId": { + "description": "Identity number (SSN) or unique record ID (GUID) of the company which is represented by the individual", + "type": "string" + }, + "searchInactive": { + "description": "Optional. When true then search for inactive contact/company as well. Default is false.", + "type": "boolean" + } + } + }, + "GetContactResponse": { + "description": "GetContact method response structure", + "type": "object", + "properties": { + "contact": { + "$ref": "#/definitions/Contact", + "description": "Contact structure" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CreateDocumentRequest": { + "description": "CreateDocument method request structure", + "type": "object", + "properties": { + "caseNumber": { + "description": "Case number or record ID of the parent case", + "type": "string" + }, + "parentID": { + "description": "Record ID of the immediate parent under which resides the document. When this is not the case itself then CaseNumber is required", + "type": "string" + }, + "subject": { + "description": "Subject/title of the new document", + "type": "string" + }, + "fileName": { + "description": "File name of the document", + "type": "string" + }, + "content": { + "description": "Binary content that will be uploaed. Represented as Base64 encoded string", + "type": "string" + }, + "metadata": { + "description": "List of metadata values", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + } + } + }, + "CreateFormRequest": { + "description": "CreateForm method request structure", + "type": "object", + "properties": { + "caseNumber": { + "description": "Case number or record ID of the top parent case", + "type": "string" + }, + "parentID": { + "description": "Record ID of the immediate parent under which will be placed the form. When this is not the top case then is required", + "type": "string" + }, + "template": { + "description": "Form template specified by name", + "type": "string" + }, + "name": { "description": "Name of custom form", "type": "string" }, + "contact": { + "$ref": "#/definitions/LinkedContact", + "description": "Client (individual or company) who will be linked to the form. If client is not registered (missing from system) - they will be created first" + }, + "keywords": { + "description": "Keywords", + "type": "array", + "items": { "type": "string" } + }, + "metadata": { + "description": "List of metadata values", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + } + } + }, + "LinkedContact": { + "description": "Single contact information. Used in relation with forms, documents, etc.\r\nwhere only a single contact can be assigned", + "required": ["name", "idnumber"], + "type": "object", + "properties": { + "id": { + "description": "Unique record ID (a GUID) of an existing contact", + "type": "string" + }, + "name": { + "description": "Full name of the person or company", + "type": "string" + }, + "idnumber": { + "description": "National identification number", + "type": "string" + }, + "type": { + "description": "Type of client. Possible values: Individual, Company, Contact", + "type": "string" + }, + "address": { + "description": "Street address of the client", + "type": "string" + }, + "email": { "description": "Email address", "type": "string" }, + "webPage": { + "description": "Web address, home page", + "type": "string" + }, + "phone": { + "description": "Main (default) phone number for contact", + "type": "string" + }, + "postalCode": { "description": "Postal code", "type": "string" }, + "city": { "description": "City name", "type": "string" } + } + }, + "UpdateFormRequest": { + "description": "UpdateForm method request structure", + "type": "object", + "properties": { + "formID": { + "description": "Record id of target form", + "type": "string" + }, + "name": { "description": "Form name", "type": "string" }, + "contact": { + "$ref": "#/definitions/LinkedContact", + "description": "Linked contact" + }, + "keywords": { + "description": "List of keywords", + "type": "array", + "items": { "type": "string" } + }, + "metadata": { + "description": "Collection of associated metadata values with definitions", + "type": "array", + "items": { "$ref": "#/definitions/Metadata" } + }, + "overwrite": { + "description": "Flag to control full overwriting of properties\r\nWhen true - all properties are cleared and reset with the new value. Missing properties will be cleared to empty/default value(s). Object should be retrieved first before updating\r\nWhen false - only passed arguments will be updated.", + "type": "boolean" + } + } + }, + "GetFormResponse": { + "description": "GetForm method response structure", + "type": "object", + "properties": { + "form": { + "$ref": "#/definitions/CustomForm", + "description": "Form object" + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CustomForm": { + "description": "GoPro custom form data model", + "type": "object", + "properties": { + "id": { "description": "Record id of this form", "type": "string" }, + "subject": { + "description": "Subject (title/name) of custom form", + "type": "string" + }, + "templateName": { "description": "Form template", "type": "string" }, + "personalSensitive": { + "description": "GDPR protection applied", + "type": "boolean" + }, + "statusName": { "description": "Form status", "type": "string" }, + "keywords": { + "description": "List of associated keywords", + "type": "array", + "items": { "type": "string" } + }, + "creationDate": { + "format": "date-time", + "description": "Date and time of form creation", + "type": "string" + }, + "createdByName": { + "description": "Name of the user who created the form", + "type": "string" + }, + "modifiedDate": { + "format": "date-time", + "description": "Date and time of latest edition", + "type": "string" + }, + "modifiedByName": { + "description": "Name of the user who last edited the form", + "type": "string" + }, + "metaDataEntries": { + "description": "List of related metadata with values", + "type": "array", + "items": { "$ref": "#/definitions/MetaValue" } + }, + "parent": { + "$ref": "#/definitions/CaseReference", + "description": "Parent case" + } + } + }, + "CaseReference": { + "description": "Base case reference data model", + "type": "object", + "properties": { + "id": { + "description": "Unique record ID (a GUID) of the case in GoPro system", + "type": "string" + }, + "caseNumber": { "description": "Case number", "type": "string" } + } + }, + "CreateMemoRequest": { + "description": "CreateMemo method request structure", + "type": "object", + "properties": { + "subject": { + "description": "Subject (title) of the memo", + "type": "string" + }, + "body": { + "description": "The content (body text) of the memo", + "type": "string" + }, + "caseNumber": { + "description": "Top parent case number or record ID.", + "type": "string" + }, + "parentID": { + "description": "Record ID of the immediate parent under which memo resides. When this is not the case itself then CaseNumber is required", + "type": "string" + } + } + }, + "GetVerdictsRequest": { + "type": "object", + "properties": { + "searchTerm": { "type": "string" }, + "courtLevel": { "type": "string" }, + "caseCategory": { "type": "string" }, + "caseType": { "type": "string" }, + "caseNumber": { "type": "string" }, + "title": { "type": "string" }, + "keywords": { "type": "array", "items": { "type": "string" } }, + "laws": { "type": "array", "items": { "type": "string" } }, + "dateFrom": { "type": "string" }, + "dateTo": { "type": "string" }, + "orderBy": { "type": "string" }, + "pageNumber": { "format": "int32", "type": "integer" }, + "itemsPerPage": { "format": "int32", "type": "integer" } + } + }, + "GetVerdictsResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { "$ref": "#/definitions/DetailedVerdictData" } + }, + "total": { "format": "int32", "type": "integer" }, + "currentPage": { "format": "int32", "type": "integer" }, + "itemsPerPage": { "format": "int32", "type": "integer" }, + "identifier": { "type": "string" }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "DetailedVerdictData": { + "type": "object", + "properties": { + "court": { "type": "string" }, + "caseId": { + "format": "uuid", + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "caseNumber": { "type": "string" }, + "caseType": { "type": "string" }, + "caseCategory": { "type": "string" }, + "title": { "type": "string" }, + "verdict": { "type": "string" }, + "verdictHtml": { "type": "string" }, + "presentings": { "type": "string" }, + "presentingsHtml": { "type": "string" }, + "verdictDate": { "format": "date-time", "type": "string" }, + "publishDate": { "format": "date-time", "type": "string" }, + "judges": { + "type": "array", + "items": { "$ref": "#/definitions/JuryJudge" } + }, + "keywords": { "type": "array", "items": { "type": "string" } }, + "lawCitations": { + "type": "array", + "items": { "$ref": "#/definitions/CaseLaw" } + } + } + }, + "JuryJudge": { + "type": "object", + "properties": { + "isPresident": { "type": "boolean" }, + "name": { "type": "string" }, + "title": { "type": "string" } + } + }, + "CaseLaw": { + "type": "object", + "properties": { + "position": { "format": "int32", "type": "integer" }, + "citation": { "type": "string" } + } + }, + "GetVerdictResponse": { + "type": "object", + "properties": { + "item": { "$ref": "#/definitions/DetailedVerdictData" }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "PublishVerdictRequest": { + "type": "object", + "properties": { + "court": { "type": "string" }, + "caseId": { + "format": "uuid", + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "caseNumber": { "type": "string" }, + "caseType": { "type": "string" }, + "caseCategory": { "type": "string" }, + "title": { "type": "string" }, + "verdict": { "type": "string" }, + "verdictHtml": { "type": "string" }, + "presentings": { "type": "string" }, + "presentingsHtml": { "type": "string" }, + "verdictDate": { "type": "string" }, + "publishDate": { "type": "string" }, + "judges": { + "type": "array", + "items": { "$ref": "#/definitions/JuryJudge" } + }, + "keywords": { "type": "array", "items": { "type": "string" } }, + "lawCitations": { + "type": "array", + "items": { "$ref": "#/definitions/CaseLaw" } + } + } + }, + "AddVerdictDocumentRequest": { + "type": "object", + "properties": { + "verdictID": { "type": "string" }, + "subject": { "type": "string" }, + "fileName": { "type": "string" }, + "content": { "type": "string" } + } + }, + "GetCaseTypesResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { "$ref": "#/definitions/CaseTypeInfo" } + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CaseTypeInfo": { + "type": "object", + "properties": { + "id": { "format": "int32", "type": "integer" }, + "label": { "type": "string" } + } + }, + "GetCaseCategoriesResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { "$ref": "#/definitions/CaseCategoryInfo" } + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "CaseCategoryInfo": { + "type": "object", + "properties": { + "id": { "format": "int32", "type": "integer" }, + "label": { "type": "string" } + } + }, + "GetKeywordsResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { "$ref": "#/definitions/KeywordInfo" } + }, + "succeeded": { + "description": "General success indicator", + "type": "boolean" + }, + "returnCode": { + "format": "int32", + "description": "HTTP response status code", + "type": "integer" + }, + "message": { + "description": "Additional message containing information or error message", + "type": "string" + } + } + }, + "KeywordInfo": { + "type": "object", + "properties": { + "id": { "format": "int32", "type": "integer" }, + "label": { "type": "string" } + } + } + }, + "securityDefinitions": { + "basic": { "type": "basic", "description": "Basic HTTP Authentication" } + } +} diff --git a/libs/clients/verdicts/src/index.ts b/libs/clients/verdicts/src/index.ts new file mode 100644 index 000000000000..f53340f61040 --- /dev/null +++ b/libs/clients/verdicts/src/index.ts @@ -0,0 +1,3 @@ +export * from './lib/verdicts-client.module' +export * from './lib/verdicts-client.service' +export * from './lib/verdicts-client.config' diff --git a/libs/clients/verdicts/src/lib/verdicts-client.config.ts b/libs/clients/verdicts/src/lib/verdicts-client.config.ts new file mode 100644 index 000000000000..465e7c6818ec --- /dev/null +++ b/libs/clients/verdicts/src/lib/verdicts-client.config.ts @@ -0,0 +1,18 @@ +import { z } from 'zod' +import { defineConfig } from '@island.is/nest/config' + +const schema = z.object({ + goproUsername: z.string(), + goproPassword: z.string(), +}) + +export const VerdictsClientConfig = defineConfig({ + name: 'VerdictsClient', + schema, + load(env) { + return { + goproUsername: env.required('VERDICTS_GOPRO_USERNAME'), + goproPassword: env.required('VERDICTS_GOPRO_PASSWORD'), + } + }, +}) diff --git a/libs/clients/verdicts/src/lib/verdicts-client.module.ts b/libs/clients/verdicts/src/lib/verdicts-client.module.ts new file mode 100644 index 000000000000..27f98082f28b --- /dev/null +++ b/libs/clients/verdicts/src/lib/verdicts-client.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common' +import { ApiConfig, ApiProviders } from './verdicts-client.provider' +import { VerdictsClientService } from './verdicts-client.service' + +@Module({ + providers: [ApiConfig, ...ApiProviders, VerdictsClientService], + exports: [VerdictsClientService], +}) +export class VerdictsClientModule {} diff --git a/libs/clients/verdicts/src/lib/verdicts-client.provider.ts b/libs/clients/verdicts/src/lib/verdicts-client.provider.ts new file mode 100644 index 000000000000..ada5ac355d96 --- /dev/null +++ b/libs/clients/verdicts/src/lib/verdicts-client.provider.ts @@ -0,0 +1,29 @@ +import { LazyDuringDevScope } from '@island.is/nest/config' +import { createEnhancedFetch } from '@island.is/clients/middlewares' +import { SecurityApi, VerdictApi, Configuration } from '../../gen/fetch' +import { VerdictsClientConfig } from './verdicts-client.config' + +export const ApiConfig = { + provide: 'VerdictsClientConfig', + scope: LazyDuringDevScope, + useFactory: () => { + return new Configuration({ + fetchApi: createEnhancedFetch({ + name: 'clients-gopro-verdicts', + logErrorResponseBody: true, + }), + headers: { + Accept: 'application/json', + }, + }) + }, + inject: [VerdictsClientConfig.KEY], +} + +export const ApiProviders = [SecurityApi, VerdictApi].map((api) => ({ + provide: api, + useFactory: (config: Configuration) => { + return new api(config) + }, + inject: [ApiConfig.provide], +})) diff --git a/libs/clients/verdicts/src/lib/verdicts-client.service.ts b/libs/clients/verdicts/src/lib/verdicts-client.service.ts new file mode 100644 index 000000000000..75bb1b421da2 --- /dev/null +++ b/libs/clients/verdicts/src/lib/verdicts-client.service.ts @@ -0,0 +1,43 @@ +import { Inject, Injectable } from '@nestjs/common' + +import { + GetVerdictsOperationRequest, + SecurityApi, + VerdictApi, +} from '../../gen/fetch/apis/' +import { VerdictsClientConfig } from './verdicts-client.config' +import { ConfigType } from '@nestjs/config' + +@Injectable() +export class VerdictsClientService { + constructor( + @Inject(VerdictsClientConfig.KEY) + private readonly clientConfig: ConfigType, + private readonly securityApi: SecurityApi, + private readonly verdictApi: VerdictApi, + ) {} + + // TODO: Don't authenticate on every request, reuse token and refresh if it expires + private async getAuthenticationToken() { + return this.securityApi.authenticate({ + username: this.clientConfig.goproUsername, + password: this.clientConfig.goproPassword, + }) + } + + async getVerdicts(input: GetVerdictsOperationRequest['requestData']) { + const token = await this.getAuthenticationToken() + return this.verdictApi.getVerdicts({ + requestData: input, + token, + }) + } + + async getSingleVerdictById(id: string) { + const token = await this.getAuthenticationToken() + return this.verdictApi.getVerdict({ + id, + token, + }) + } +} diff --git a/libs/clients/verdicts/tsconfig.json b/libs/clients/verdicts/tsconfig.json new file mode 100644 index 000000000000..8122543a9ab0 --- /dev/null +++ b/libs/clients/verdicts/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/clients/verdicts/tsconfig.lib.json b/libs/clients/verdicts/tsconfig.lib.json new file mode 100644 index 000000000000..dbf54fd7d68c --- /dev/null +++ b/libs/clients/verdicts/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "declaration": true, + "types": ["node"], + "target": "es2021", + "strictNullChecks": true, + "noImplicitAny": true, + "strictBindCallApply": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/libs/clients/verdicts/tsconfig.spec.json b/libs/clients/verdicts/tsconfig.spec.json new file mode 100644 index 000000000000..69a251f328ce --- /dev/null +++ b/libs/clients/verdicts/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 7be0f1c28845..da7b30f8963f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -239,6 +239,9 @@ "@island.is/api/domains/vehicles": [ "libs/api/domains/vehicles/src/index.ts" ], + "@island.is/api/domains/verdicts": [ + "libs/api/domains/verdicts/src/index.ts" + ], "@island.is/api/domains/watson-assistant-chat": [ "libs/api/domains/watson-assistant-chat/src/index.ts" ], @@ -840,6 +843,7 @@ "@island.is/clients/vehicles-mileage": [ "libs/clients/vehicles-mileage/src/index.ts" ], + "@island.is/clients/verdicts": ["libs/clients/verdicts/src/index.ts"], "@island.is/clients/vmst": ["libs/clients/vmst/src/index.ts"], "@island.is/clients/work-accident-ver": [ "libs/clients/work-accident-ver/src/index.ts" From e95da62c05a62ba27f9255bc484334728cea8376 Mon Sep 17 00:00:00 2001 From: andes-it Date: Thu, 12 Dec 2024 10:30:59 +0000 Subject: [PATCH 2/4] chore: charts update dirty files --- charts/islandis/values.dev.yaml | 2 ++ charts/islandis/values.prod.yaml | 2 ++ charts/islandis/values.staging.yaml | 2 ++ charts/services/api/values.dev.yaml | 2 ++ charts/services/api/values.prod.yaml | 2 ++ charts/services/api/values.staging.yaml | 2 ++ 6 files changed, 12 insertions(+) diff --git a/charts/islandis/values.dev.yaml b/charts/islandis/values.dev.yaml index e0f5e81d1937..17ec5041a4fa 100644 --- a/charts/islandis/values.dev.yaml +++ b/charts/islandis/values.dev.yaml @@ -553,6 +553,8 @@ api: UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL' UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY' VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS' + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD' + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME' VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY' VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY' WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY' diff --git a/charts/islandis/values.prod.yaml b/charts/islandis/values.prod.yaml index d08668a62457..21cc6837b15a 100644 --- a/charts/islandis/values.prod.yaml +++ b/charts/islandis/values.prod.yaml @@ -541,6 +541,8 @@ api: UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL' UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY' VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS' + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD' + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME' VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY' VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY' WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY' diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index 2cd78ddb6714..59631faa3e92 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -550,6 +550,8 @@ api: UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL' UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY' VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS' + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD' + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME' VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY' VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY' WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY' diff --git a/charts/services/api/values.dev.yaml b/charts/services/api/values.dev.yaml index e1ea92a280b8..ee01fb2040e4 100644 --- a/charts/services/api/values.dev.yaml +++ b/charts/services/api/values.dev.yaml @@ -302,6 +302,8 @@ secrets: UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL' UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY' VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS' + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD' + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME' VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY' VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY' WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY' diff --git a/charts/services/api/values.prod.yaml b/charts/services/api/values.prod.yaml index ccea0dbcdf76..14cfedad36b6 100644 --- a/charts/services/api/values.prod.yaml +++ b/charts/services/api/values.prod.yaml @@ -302,6 +302,8 @@ secrets: UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL' UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY' VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS' + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD' + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME' VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY' VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY' WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY' diff --git a/charts/services/api/values.staging.yaml b/charts/services/api/values.staging.yaml index d200690c8557..a813cc47affc 100644 --- a/charts/services/api/values.staging.yaml +++ b/charts/services/api/values.staging.yaml @@ -299,6 +299,8 @@ secrets: UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL' UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY' VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS' + VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD' + VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME' VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY' VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY' WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY' From 08f2d062bba049efc66cc796620b2ae40fc28f5e Mon Sep 17 00:00:00 2001 From: runarvestmann Date: Thu, 12 Dec 2024 14:03:01 +0000 Subject: [PATCH 3/4] Fix imports --- apps/api/src/app/app.module.ts | 2 +- apps/web/pages/domar/index.ts | 12 ++++ apps/web/screens/Verdicts/VerdictsList.tsx | 38 +++++++++++++ apps/web/screens/queries/Verdicts.ts | 14 +++++ libs/api/domains/verdicts/project.json | 2 +- .../verdicts/src/lib/dto/verdicts.input.ts | 10 ++++ .../verdicts/src/lib/dto/verdicts.response.ts | 22 ++++++++ .../verdicts/src/lib/verdicts.resolver.ts | 18 +++++- .../verdicts/src/lib/verdicts.service.ts | 12 ++++ libs/clients/verdicts/project.json | 2 +- .../src/lib/verdicts-client.provider.ts | 5 +- .../src/lib/verdicts-client.service.ts | 55 +++++++++---------- 12 files changed, 159 insertions(+), 33 deletions(-) create mode 100644 apps/web/pages/domar/index.ts create mode 100644 apps/web/screens/Verdicts/VerdictsList.tsx create mode 100644 apps/web/screens/queries/Verdicts.ts create mode 100644 libs/api/domains/verdicts/src/lib/dto/verdicts.input.ts create mode 100644 libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index d9f845f41da1..0a6c931399b4 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -141,7 +141,7 @@ import { SyslumennClientConfig } from '@island.is/clients/syslumenn' import { HuntingLicenseClientConfig } from '@island.is/clients/hunting-license' import { VehiclesClientConfig } from '@island.is/clients/vehicles' import { WorkMachinesClientConfig } from '@island.is/clients/work-machines' -import { CmsModule, Form, PowerBiConfig } from '@island.is/cms' +import { CmsModule, PowerBiConfig } from '@island.is/cms' import { CmsTranslationsModule } from '@island.is/cms-translations' import { FileStorageConfig } from '@island.is/file-storage' import { AuditModule } from '@island.is/nest/audit' diff --git a/apps/web/pages/domar/index.ts b/apps/web/pages/domar/index.ts new file mode 100644 index 000000000000..b1b4a823aec8 --- /dev/null +++ b/apps/web/pages/domar/index.ts @@ -0,0 +1,12 @@ +import withApollo from '@island.is/web/graphql/withApollo' +import { withLocale } from '@island.is/web/i18n' +import VerdictsList from '@island.is/web/screens/Verdicts/VerdictsList' +import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper' + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore make web strict +const Screen = withApollo(withLocale('is')(VerdictsList)) + +export default Screen + +export const getServerSideProps = getServerSidePropsWrapper(Screen) diff --git a/apps/web/screens/Verdicts/VerdictsList.tsx b/apps/web/screens/Verdicts/VerdictsList.tsx new file mode 100644 index 000000000000..0119168ddd6f --- /dev/null +++ b/apps/web/screens/Verdicts/VerdictsList.tsx @@ -0,0 +1,38 @@ +import { + GetVerdictsQuery, + GetVerdictsQueryVariables, +} from '@island.is/web/graphql/schema' +import { withMainLayout } from '@island.is/web/layouts/main' +import { Screen } from '@island.is/web/types' + +import { GET_VERDICTS_QUERY } from '../queries/Verdicts' + +interface VerdictsListProps { + items: GetVerdictsQuery['webVerdicts']['items'] +} + +const VerdictsList: Screen = ({ items }) => { + return
VerdictsList {JSON.stringify(items)}
+} + +VerdictsList.getProps = async ({ apolloClient }) => { + const verdictListResponse = await apolloClient.query< + GetVerdictsQuery, + GetVerdictsQueryVariables + >({ + query: GET_VERDICTS_QUERY, + variables: { + input: { + searchTerm: '', + }, + }, + }) + + console.log(verdictListResponse) + + return { + items: verdictListResponse.data.webVerdicts.items, + } +} + +export default withMainLayout(VerdictsList) diff --git a/apps/web/screens/queries/Verdicts.ts b/apps/web/screens/queries/Verdicts.ts new file mode 100644 index 000000000000..0cfebef1480b --- /dev/null +++ b/apps/web/screens/queries/Verdicts.ts @@ -0,0 +1,14 @@ +import gql from 'graphql-tag' + +export const GET_VERDICTS_QUERY = gql` + query GetVerdicts($input: WebVerdictsInput!) { + webVerdicts(input: $input) { + items { + title + } + input { + searchTerm + } + } + } +` diff --git a/libs/api/domains/verdicts/project.json b/libs/api/domains/verdicts/project.json index 2863c2170964..79a9aa341467 100644 --- a/libs/api/domains/verdicts/project.json +++ b/libs/api/domains/verdicts/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "libs/api/domains/verdicts/src", "projectType": "library", - "tags": [], + "tags": ["lib:api", "scope:api"], "targets": { "lint": { "executor": "@nx/eslint:lint" diff --git a/libs/api/domains/verdicts/src/lib/dto/verdicts.input.ts b/libs/api/domains/verdicts/src/lib/dto/verdicts.input.ts new file mode 100644 index 000000000000..7fdfb207d64f --- /dev/null +++ b/libs/api/domains/verdicts/src/lib/dto/verdicts.input.ts @@ -0,0 +1,10 @@ +import { Field, InputType, ObjectType } from '@nestjs/graphql' + +@InputType('WebVerdictsInput') +@ObjectType('WebVerdictsInputResponse') +export class VerdictsInput { + @Field(() => String, { nullable: true }) + searchTerm?: string + + // TODO: Add more fields +} diff --git a/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts b/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts new file mode 100644 index 000000000000..3eec55b0af60 --- /dev/null +++ b/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts @@ -0,0 +1,22 @@ +import { CacheField } from '@island.is/nest/graphql' +import { Field, ObjectType } from '@nestjs/graphql' +import { VerdictsInput } from './verdicts.input' + +@ObjectType('WebVerdictsItem') +class VerdictItem { + @Field(() => String) + title!: string + + // TODO: Add more fields +} + +@ObjectType('WebVerdictsResponse') +export class VerdictsResponse { + @CacheField(() => VerdictItem) + items!: VerdictItem[] + + @CacheField(() => VerdictsInput) + input!: VerdictsInput + + // TODO: Add total? +} diff --git a/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts b/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts index 130d069f1f5f..b0f37f26c0ed 100644 --- a/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts +++ b/libs/api/domains/verdicts/src/lib/verdicts.resolver.ts @@ -1,7 +1,23 @@ -import { Resolver } from '@nestjs/graphql' +import { Args, Query, Resolver } from '@nestjs/graphql' +import { CacheControl, CacheControlOptions } from '@island.is/nest/graphql' +import { CACHE_CONTROL_MAX_AGE } from '@island.is/shared/constants' import { VerdictsService } from './verdicts.service' +import { VerdictsResponse } from './dto/verdicts.response' +import { VerdictsInput } from './dto/verdicts.input' + +const defaultCache: CacheControlOptions = { maxAge: CACHE_CONTROL_MAX_AGE } @Resolver() export class VerdictsResolver { constructor(private readonly verdictsService: VerdictsService) {} + + @CacheControl(defaultCache) + @Query(() => VerdictsResponse, { + name: 'webVerdicts', + }) + async verdicts( + @Args('input') input: VerdictsInput, + ): Promise { + return this.verdictsService.getVerdicts(input) + } } diff --git a/libs/api/domains/verdicts/src/lib/verdicts.service.ts b/libs/api/domains/verdicts/src/lib/verdicts.service.ts index 18799fc7d9cf..18d367810edd 100644 --- a/libs/api/domains/verdicts/src/lib/verdicts.service.ts +++ b/libs/api/domains/verdicts/src/lib/verdicts.service.ts @@ -1,7 +1,19 @@ import { Injectable } from '@nestjs/common' import { VerdictsClientService } from '@island.is/clients/verdicts' +import { VerdictsInput } from './dto/verdicts.input' +import { VerdictsResponse } from './dto/verdicts.response' @Injectable() export class VerdictsService { constructor(private readonly verdictsClientService: VerdictsClientService) {} + + async getVerdicts(input: VerdictsInput): Promise { + const response = await this.verdictsClientService.getVerdicts({ + searchTerm: input.searchTerm, + }) + return { + items: response.items, + input, + } + } } diff --git a/libs/clients/verdicts/project.json b/libs/clients/verdicts/project.json index ad49687fc6e4..a120865cd29c 100644 --- a/libs/clients/verdicts/project.json +++ b/libs/clients/verdicts/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "libs/clients/verdicts/src", "projectType": "library", - "tags": [], + "tags": ["lib:nest", "scope:nest"], "targets": { "lint": { "executor": "@nx/eslint:lint" diff --git a/libs/clients/verdicts/src/lib/verdicts-client.provider.ts b/libs/clients/verdicts/src/lib/verdicts-client.provider.ts index ada5ac355d96..f507081ae9fe 100644 --- a/libs/clients/verdicts/src/lib/verdicts-client.provider.ts +++ b/libs/clients/verdicts/src/lib/verdicts-client.provider.ts @@ -2,11 +2,12 @@ import { LazyDuringDevScope } from '@island.is/nest/config' import { createEnhancedFetch } from '@island.is/clients/middlewares' import { SecurityApi, VerdictApi, Configuration } from '../../gen/fetch' import { VerdictsClientConfig } from './verdicts-client.config' +import { ConfigType } from '@nestjs/config' export const ApiConfig = { provide: 'VerdictsClientConfig', scope: LazyDuringDevScope, - useFactory: () => { + useFactory: (config: ConfigType) => { return new Configuration({ fetchApi: createEnhancedFetch({ name: 'clients-gopro-verdicts', @@ -15,6 +16,8 @@ export const ApiConfig = { headers: { Accept: 'application/json', }, + username: config.goproUsername, + password: config.goproPassword, }) }, inject: [VerdictsClientConfig.KEY], diff --git a/libs/clients/verdicts/src/lib/verdicts-client.service.ts b/libs/clients/verdicts/src/lib/verdicts-client.service.ts index 75bb1b421da2..47115a69dd22 100644 --- a/libs/clients/verdicts/src/lib/verdicts-client.service.ts +++ b/libs/clients/verdicts/src/lib/verdicts-client.service.ts @@ -1,43 +1,42 @@ -import { Inject, Injectable } from '@nestjs/common' +import { Injectable } from '@nestjs/common' -import { - GetVerdictsOperationRequest, - SecurityApi, - VerdictApi, -} from '../../gen/fetch/apis/' -import { VerdictsClientConfig } from './verdicts-client.config' -import { ConfigType } from '@nestjs/config' +import { GetVerdictsOperationRequest, VerdictApi } from '../../gen/fetch/apis/' @Injectable() export class VerdictsClientService { - constructor( - @Inject(VerdictsClientConfig.KEY) - private readonly clientConfig: ConfigType, - private readonly securityApi: SecurityApi, - private readonly verdictApi: VerdictApi, - ) {} - - // TODO: Don't authenticate on every request, reuse token and refresh if it expires - private async getAuthenticationToken() { - return this.securityApi.authenticate({ - username: this.clientConfig.goproUsername, - password: this.clientConfig.goproPassword, - }) - } + constructor(private readonly verdictApi: VerdictApi) {} async getVerdicts(input: GetVerdictsOperationRequest['requestData']) { - const token = await this.getAuthenticationToken() - return this.verdictApi.getVerdicts({ - requestData: input, - token, + // TODO: use input + const response = await this.verdictApi.getVerdicts({ + requestData: { + courtLevel: '', + caseCategory: '', + caseType: '', + caseNumber: '', + title: '', + keywords: [''], + laws: [''], + dateFrom: '', + dateTo: '', + orderBy: 'title', + pageNumber: 1, + itemsPerPage: 10, + }, }) + + return { + items: ( + (response.items?.filter((item) => Boolean(item.title)) ?? []) as { + title: string + }[] + ).map((item) => ({ title: item.title })), + } } async getSingleVerdictById(id: string) { - const token = await this.getAuthenticationToken() return this.verdictApi.getVerdict({ id, - token, }) } } From 52e6ef11ff4cd7ac6da3a6488b14c7f12b7ea7db Mon Sep 17 00:00:00 2001 From: runarvestmann Date: Thu, 12 Dec 2024 15:40:59 +0000 Subject: [PATCH 4/4] Display content in cards --- apps/web/screens/Verdicts/VerdictsList.tsx | 110 +++++++++++++++++- apps/web/screens/queries/Verdicts.ts | 3 + .../verdicts/src/lib/dto/verdicts.response.ts | 13 ++- .../src/lib/verdicts-client.service.ts | 22 +++- 4 files changed, 137 insertions(+), 11 deletions(-) diff --git a/apps/web/screens/Verdicts/VerdictsList.tsx b/apps/web/screens/Verdicts/VerdictsList.tsx index 0119168ddd6f..acfac4e2d76a 100644 --- a/apps/web/screens/Verdicts/VerdictsList.tsx +++ b/apps/web/screens/Verdicts/VerdictsList.tsx @@ -1,9 +1,22 @@ +import { parseAsString, useQueryState } from 'next-usequerystate' + +import { + Box, + FocusableBox, + GridColumn, + GridContainer, + GridRow, + Input, + Stack, + Text, +} from '@island.is/island-ui/core' import { GetVerdictsQuery, GetVerdictsQueryVariables, } from '@island.is/web/graphql/schema' +import { useDateUtils } from '@island.is/web/i18n/useDateUtils' import { withMainLayout } from '@island.is/web/layouts/main' -import { Screen } from '@island.is/web/types' +import type { Screen } from '@island.is/web/types' import { GET_VERDICTS_QUERY } from '../queries/Verdicts' @@ -12,10 +25,97 @@ interface VerdictsListProps { } const VerdictsList: Screen = ({ items }) => { - return
VerdictsList {JSON.stringify(items)}
+ const { format } = useDateUtils() + + const [searchTerm, setSearchTerm] = useQueryState( + 'q', + parseAsString + .withOptions({ + clearOnDefault: true, + shallow: false, + }) + .withDefault(''), + ) + + return ( + + + + + Dómar og úrskurðir + + Dómar frá öllum dómstigum á Íslandi + { + setSearchTerm(ev.target.value) + }} + name="verdict-search-input" + backgroundColor="blue" + placeholder="Sláðu inn orð, málsnúmer, málsaðila" + icon={{ + name: 'search', + type: 'outline', + }} + /> + + {items.map((item) => ( + + + + + + + + {item.caseNumber} + + + + {item.verdictDate && ( + + {format( + new Date(item.verdictDate), + 'd. MMM yyyy', + )} + + )} + + + + + + + {item.court} + + + {item.title} + + + + + + + + ))} + + + + + ) } -VerdictsList.getProps = async ({ apolloClient }) => { +VerdictsList.getProps = async ({ apolloClient, query }) => { + const searchTerm = parseAsString.withDefault('').parseServerSide(query.q) + const verdictListResponse = await apolloClient.query< GetVerdictsQuery, GetVerdictsQueryVariables @@ -23,13 +123,11 @@ VerdictsList.getProps = async ({ apolloClient }) => { query: GET_VERDICTS_QUERY, variables: { input: { - searchTerm: '', + searchTerm, }, }, }) - console.log(verdictListResponse) - return { items: verdictListResponse.data.webVerdicts.items, } diff --git a/apps/web/screens/queries/Verdicts.ts b/apps/web/screens/queries/Verdicts.ts index 0cfebef1480b..8ef6ddaac376 100644 --- a/apps/web/screens/queries/Verdicts.ts +++ b/apps/web/screens/queries/Verdicts.ts @@ -5,6 +5,9 @@ export const GET_VERDICTS_QUERY = gql` webVerdicts(input: $input) { items { title + court + caseNumber + verdictDate } input { searchTerm diff --git a/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts b/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts index 3eec55b0af60..6459db87a3e0 100644 --- a/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts +++ b/libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts @@ -2,17 +2,26 @@ import { CacheField } from '@island.is/nest/graphql' import { Field, ObjectType } from '@nestjs/graphql' import { VerdictsInput } from './verdicts.input' -@ObjectType('WebVerdictsItem') +@ObjectType() class VerdictItem { @Field(() => String) title!: string + @Field(() => String) + court!: string + + @Field(() => String) + caseNumber!: string + + @Field(() => Date) + verdictDate!: Date + // TODO: Add more fields } @ObjectType('WebVerdictsResponse') export class VerdictsResponse { - @CacheField(() => VerdictItem) + @CacheField(() => [VerdictItem]) items!: VerdictItem[] @CacheField(() => VerdictsInput) diff --git a/libs/clients/verdicts/src/lib/verdicts-client.service.ts b/libs/clients/verdicts/src/lib/verdicts-client.service.ts index 47115a69dd22..32b599cf349a 100644 --- a/libs/clients/verdicts/src/lib/verdicts-client.service.ts +++ b/libs/clients/verdicts/src/lib/verdicts-client.service.ts @@ -19,18 +19,34 @@ export class VerdictsClientService { laws: [''], dateFrom: '', dateTo: '', - orderBy: 'title', + orderBy: 'title', // TODO: how should the verdicts be ordered? pageNumber: 1, itemsPerPage: 10, + ...input, }, }) return { items: ( - (response.items?.filter((item) => Boolean(item.title)) ?? []) as { + (response.items?.filter( + (item) => + Boolean(item.title) && + Boolean(item.court) && + Boolean(item.caseNumber) && + Boolean(item.verdictDate) && + Boolean(item.caseId), + ) ?? []) as { title: string + court: string + caseNumber: string + verdictDate: Date }[] - ).map((item) => ({ title: item.title })), + ).map((item) => ({ + title: item.title, + court: item.court, + caseNumber: item.caseNumber, + verdictDate: item.verdictDate, + })), } }