Skip to content

Commit

Permalink
feat(DTFS2-7052): api-tests for geospatial/get-address-by-postcode
Browse files Browse the repository at this point in the history
  • Loading branch information
avaitonis committed Apr 11, 2024
1 parent 3259347 commit c8cb1bc
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 217 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type OrdnanceSurveyAuthErrorResponse = {
fault: {
faultstring: string;
detail: {
errorcode: string;
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class OrdnanceSurveyService {

async getAddressesByPostcode(postcode): Promise<GetAddressOrdnanceSurveyResponse> {
const path = `/search/places/v1/postcode?postcode=${encodeURIComponent(postcode)}&lr=${GEOSPATIAL.DEFAULT.RESULT_LANGUAGE}&key=${encodeURIComponent(this.key)}`;

const { data } = await this.httpClient.get<GetAddressOrdnanceSurveyResponse>({
path,
headers: { 'Content-Type': 'application/json' },
Expand Down
4 changes: 4 additions & 0 deletions src/modules/geospatial/geospatial.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class GeospatialService {
const addresses = [];
const response: GetAddressOrdnanceSurveyResponse = await this.ordnanceSurveyService.getAddressesByPostcode(postcode);

if (!response?.results) {
return [];
}

response.results.forEach((item) => {
// Ordnance survey sends duplicated results with the welsh version too via 'CY'
const item_data = item[Object.keys(item)[0]];
Expand Down
146 changes: 118 additions & 28 deletions test/docs/__snapshots__/get-docs-yaml.api-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paths:
type: array
items:
$ref: '#/components/schemas/CurrencyEntity'
tags: &ref_0
tags:
- currencies
/api/v1/currencies/exchange:
get:
Expand Down Expand Up @@ -58,7 +58,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/GetCurrencyExchangeDto'
tags: *ref_0
tags:
- currencies
/api/v1/currencies/{isoCode}:
get:
operationId: CurrenciesController_findOne
Expand All @@ -80,7 +81,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/CurrencyEntity'
tags: *ref_0
tags:
- currencies
/api/v1/customers:
get:
operationId: CustomersController_getCustomers
Expand Down Expand Up @@ -194,38 +196,43 @@ paths:
example: ok
info:
type: object
example: &ref_1
database: &ref_2
example:
database:
status: up
additionalProperties:
type: object
required:
- status
properties:
status:
type: string
additionalProperties:
type: string
additionalProperties: true
nullable: true
error:
type: object
example: {}
additionalProperties:
type: object
required:
- status
properties:
status:
type: string
additionalProperties:
type: string
additionalProperties: true
nullable: true
details:
type: object
example: *ref_1
example:
database:
status: up
additionalProperties:
type: object
required:
- status
properties:
status:
type: string
additionalProperties:
type: string
additionalProperties: true
'503':
description: The Health Check is not successful
content:
Expand All @@ -238,41 +245,49 @@ paths:
example: error
info:
type: object
example: *ref_1
example:
database:
status: up
additionalProperties:
type: object
required:
- status
properties:
status:
type: string
additionalProperties:
type: string
additionalProperties: true
nullable: true
error:
type: object
example:
redis: &ref_3
redis:
status: down
message: Could not connect
additionalProperties:
type: object
required:
- status
properties:
status:
type: string
additionalProperties:
type: string
additionalProperties: true
nullable: true
details:
type: object
example:
database: *ref_2
redis: *ref_3
database:
status: up
redis:
status: down
message: Could not connect
additionalProperties:
type: object
required:
- status
properties:
status:
type: string
additionalProperties:
type: string
additionalProperties: true
tags:
- healthcheck
/api/v1/interest-rates:
Expand Down Expand Up @@ -342,7 +357,7 @@ paths:
responses:
'201':
description: ''
tags: &ref_4
tags:
- numbers
get:
operationId: NumbersController_findOne
Expand Down Expand Up @@ -373,7 +388,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/UkefId'
tags: *ref_4
tags:
- numbers
/api/v1/premium/schedule:
post:
operationId: PremiumSchedulesController_create
Expand All @@ -390,7 +406,7 @@ paths:
responses:
'201':
description: ''
tags: &ref_5
tags:
- premium-schedules
/api/v1/premium/segments/{facilityId}:
get:
Expand All @@ -415,7 +431,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/PremiumScheduleEntity'
tags: *ref_5
tags:
- premium-schedules
/api/v1/sector-industries:
get:
operationId: SectorIndustriesController_find
Expand Down Expand Up @@ -469,6 +486,35 @@ paths:
$ref: '#/components/schemas/YieldRateEntity'
tags:
- yield-rates
/api/v1/geospatial/addresses/postcode:
get:
operationId: GeospatialController_getGeospatial
summary: >-
A search based on a property's postcode. Will accept a full postcode
consisting of the area, district, sector and unit e.g. SO16 0AS.
parameters:
- name: postcode
required: true
in: query
example: SW1A 2AQ
description: Postcode to search for
schema:
type: string
responses:
'200':
description: >-
Returns addresses from Ordanance survey Delivery Point Address (DPA)
system.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/GetAddressesResponseItem'
'404':
description: Customer not found.
tags:
- geospatial
info:
title: MDM API Specification
description: MDM API documentation
Expand Down Expand Up @@ -850,8 +896,8 @@ components:
type: number
example: 1
description: >-
Payment frequency. It can be: 0 -> Null (At maturity), 1 -> Monthly, 2 -> Quarterly, 3->
Semi-annually or 4 -> Annually
Payment frequency. It can be: 0 -> Null (At maturity), 1 -> Monthly,
2 -> Quarterly, 3-> Semi-annually or 4 -> Annually
guaranteeCommencementDate:
format: date-time
type: string
Expand Down Expand Up @@ -1087,6 +1133,50 @@ components:
- updated
- effectiveTo
- effectiveFrom
GetAddressesResponseItem:
type: object
properties:
organisationName:
type: string
description: Organisation name if available
example: CHURCHILL MUSEUM & CABINET WAR ROOMS
addressLine1:
type: string
description: Address line 1
example: CLIVE STEPS KING CHARLES STREET
addressLine2:
type: string
description: Address line 2
example: null
addressLine3:
type: string
description: Address line 3
example: null
locality:
type: string
description: Locality, Town
example: LONDON
postalCode:
type: string
description: Postcode
example: SW1A 2AQ
country:
type: string
description: Country of address record
example: England
enum:
- England
- Scotland
- Wales
- Northern Ireland
required:
- organisationName
- addressLine1
- addressLine2
- addressLine3
- locality
- postalCode
- country
security:
- ApiKeyHeader: []
"
Expand Down
Loading

0 comments on commit c8cb1bc

Please sign in to comment.