Skip to content

Commit 1281a6a

Browse files
mittistormenlalmqvist
authored andcommitted
Feat/uth 236 get all parking space listings from one core (#35)
* Feat: UTH-236 Get All Parking Space Listings From OneCore Added missing functionality to filter result based on a ContactCode. Scored/internal Listings where the user doesn't have a housing contract is filtered out.
1 parent 3770739 commit 1281a6a

File tree

2 files changed

+10
-46
lines changed

2 files changed

+10
-46
lines changed

core/src/adapters/leasing-adapter/listings.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -296,52 +296,6 @@ const createMultipleListings = async (
296296
}
297297
}
298298

299-
const createMultipleListings = async (
300-
listingsData: Array<Omit<Listing, 'id' | 'rentalObject'>>
301-
): Promise<AdapterResult<Listing[], 'partial-failure' | 'unknown'>> => {
302-
try {
303-
const response = await axios.post(
304-
`${tenantsLeasesServiceUrl}/listings/batch`,
305-
{ listings: listingsData }
306-
)
307-
308-
if (response.status === HttpStatusCode.Created) {
309-
return { ok: true, data: response.data.content }
310-
}
311-
312-
// Handle partial success (207 Multi-Status)
313-
if (response.status === 207) {
314-
logger.warn(
315-
{
316-
listingsCount: listingsData.length,
317-
responseData: response.data,
318-
},
319-
'Partial success when creating multiple listings'
320-
)
321-
return { ok: false, err: 'partial-failure' }
322-
}
323-
324-
logger.error(
325-
{
326-
status: response.status,
327-
data: response.data,
328-
listingsCount: listingsData.length,
329-
},
330-
'Unexpected response when creating multiple listings'
331-
)
332-
return { ok: false, err: 'unknown' }
333-
} catch (error) {
334-
logger.error(
335-
{
336-
error,
337-
listingsCount: listingsData.length,
338-
},
339-
'Error creating multiple listings'
340-
)
341-
return { ok: false, err: 'unknown' }
342-
}
343-
}
344-
345299
export {
346300
getActiveListingByRentalObjectCode,
347301
getListingsWithApplicants,

core/src/services/lease-service/tests/listings.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ describe('GET /listings', () => {
132132
})
133133
const parkingSpace = factory.vacantParkingSpace.build({
134134
rentalObjectCode: '12345',
135+
residentialAreaCode: 'AREA123',
135136
})
136137

137138
const getListingsSpy = jest
@@ -142,6 +143,15 @@ describe('GET /listings', () => {
142143
.spyOn(tenantLeaseAdapter, 'getParkingSpaces')
143144
.mockResolvedValueOnce({ ok: true, data: [parkingSpace] })
144145

146+
jest
147+
.spyOn(tenantLeaseAdapter, 'getTenantByContactCode')
148+
.mockResolvedValueOnce({
149+
ok: true,
150+
data: factory.tenant.build({
151+
currentHousingContract: { residentialArea: { code: 'AREA123' } },
152+
}),
153+
})
154+
145155
const res = await request(app.callback()).get(
146156
'/listings?rentalObjectCode=12345'
147157
)

0 commit comments

Comments
 (0)