Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: application profile v1 #200

Open
wants to merge 1 commit into
base: develop-uthyrning-bostader
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/services/lease-service/routes/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export const routes = (router: KoaRouter) => {
*/

type GetApplicationProfileResponseData = z.infer<
typeof leasing.GetApplicationProfileResponseDataSchema
typeof leasing.v1.GetApplicationProfileResponseDataSchema
>

router.get('(.*)/contacts/:contactCode/application-profile', async (ctx) => {
Expand Down Expand Up @@ -560,13 +560,13 @@ export const routes = (router: KoaRouter) => {
*/

type CreateOrUpdateApplicationProfileResponseData = z.infer<
typeof leasing.CreateOrUpdateApplicationProfileResponseDataSchema
typeof leasing.v1.CreateOrUpdateApplicationProfileResponseDataSchema
>

router.post(
'(.*)/contacts/:contactCode/application-profile',
parseRequestBody(
leasing.CreateOrUpdateApplicationProfileRequestParamsSchema
leasing.v1.CreateOrUpdateApplicationProfileRequestParamsSchema
),
async (ctx) => {
const metadata = generateRouteMetadata(ctx)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Factory } from 'fishery'
import {
ApplicationProfile,
ApplicationProfileHousingReference,
} from 'onecore-types'
import { schemas } from 'onecore-types'
import { z } from 'zod'

type ApplicationProfile = z.infer<typeof schemas.v1.ApplicationProfileSchema>
type ApplicationProfileHousingReference = z.infer<
typeof schemas.v1.ApplicationProfileHousingReferenceSchema
>

export const ApplicationProfileFactory = Factory.define<ApplicationProfile>(
({ sequence }) => ({
Expand Down
6 changes: 3 additions & 3 deletions src/services/lease-service/tests/routes/contacts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('GET /contacts/:contactCode/application-profile', () => {

expect(res.status).toBe(200)
expect(() =>
leasing.GetApplicationProfileResponseDataSchema.parse(res.body.content)
leasing.v1.GetApplicationProfileResponseDataSchema.parse(res.body.content)
).not.toThrow()
})
})
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('POST /contacts/:contactCode/application-profile', () => {

expect(res.status).toBe(200)
expect(() =>
leasing.CreateOrUpdateApplicationProfileResponseDataSchema.parse(
leasing.v1.CreateOrUpdateApplicationProfileResponseDataSchema.parse(
res.body.content
)
).not.toThrow()
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('POST /contacts/:contactCode/application-profile', () => {

expect(res.status).toBe(201)
expect(() =>
leasing.CreateOrUpdateApplicationProfileResponseDataSchema.parse(
leasing.v1.CreateOrUpdateApplicationProfileResponseDataSchema.parse(
res.body.content
)
).not.toThrow()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ApplicationProfile, leasing } from 'onecore-types'
import { schemas, leasing } from 'onecore-types'
import { Knex } from 'knex'
import { z } from 'zod'

import { AdapterResult } from './adapters/types'
import * as applicationProfileAdapter from './adapters/application-profile-adapter'

type Params = z.infer<
typeof leasing.CreateOrUpdateApplicationProfileRequestParamsSchema
typeof leasing.v1.CreateOrUpdateApplicationProfileRequestParamsSchema
>

type ApplicationProfile = z.infer<typeof schemas.v1.ApplicationProfileSchema>

export async function updateOrCreateApplicationProfile(
db: Knex,
contactCode: string,
Expand Down