import { delay } from "../../../utils"; import type { LoqateAddressDetailsItem, LoqateSearchResponse } from "../types"; export class MockLoqateAddressLookupService { #baseUrl?: string; #apiKey?: string; #countries?: string[]; static readonly mockAddressSearchResults = { Items: [ { Id: "GB|RM|A|20338969", Type: "Address", Text: "99 Gresham Drive", Highlight: "0-2,3-8", Description: "Romford, RM6 4TR", }, { Id: "GB|RM|A|25134456", Type: "Address", Text: "99 Gresham Road", Highlight: "0-2,3-8", Description: "Middlesbrough, TS1 4LT", }, { Id: "GB|RM|ENG|7NG-EC2V-LONDON---STREET-GRESHAM----99", Type: "BuildingNumber", Text: "99 Gresham Street", Highlight: "0-2,3-8", Description: "London, EC2V 7NG - 3 Addresses", }, ], }; static readonly mockAddressDetails = { Items: [ { Id: "GB|RM|A|51074547", Type: "Address", Text: "Curtis Mallet-Prevost Colt & Mosle LLP, 99 Gresham Street", Highlight: "", Description: "London, EC2V 7NG", }, { Id: "GB|RM|A|56463483", Type: "Address", Text: "Hugh James, 99 Gresham Street", Highlight: "", Description: "London, EC2V 7NG", }, { Id: "GB|RM|A|8186332", Type: "Address", Text: "Xbridge Ltd, 99 Gresham Street", Highlight: "", Description: "London, EC2V 7NG", }, ], }; static readonly mockAddressFineDetails = { "GB|RM|A|25134456": { Items: [ { Id: "GB|RM|A|25134456", DomesticId: "25134456", Language: "ENG", LanguageAlternatives: "ENG", Department: "", Company: "", SubBuilding: "", BuildingNumber: "99", BuildingName: "", SecondaryStreet: "", Street: "Gresham Road", Block: "", Neighbourhood: "", District: "", City: "Middlesbrough", Line1: "99 Gresham Road", Line2: "", Line3: "", Line4: "", Line5: "", AdminAreaName: "Middlesbrough", AdminAreaCode: "", Province: "North Yorkshire", ProvinceName: "North Yorkshire", ProvinceCode: "", PostalCode: "TS1 4LT", CountryName: "United Kingdom", CountryIso2: "GB", CountryIso3: "GBR", CountryIsoNumber: "826", SortingNumber1: "33113", SortingNumber2: "", Barcode: "(TS14LT2E3)", POBoxNumber: "", Label: "99 Gresham Road\nMIDDLESBROUGH\nTS1 4LT\nUNITED KINGDOM", Type: "Residential", DataLevel: "Premise", Field1: "", Field2: "", Field3: "", Field4: "", Field5: "", Field6: "", Field7: "", Field8: "", Field9: "", Field10: "", Field11: "", Field12: "", Field13: "", Field14: "", Field15: "", Field16: "", Field17: "", Field18: "", Field19: "", Field20: "", }, ], }, "GB|RM|A|20338969": { Items: [ { Id: "GB|RM|A|20338969", DomesticId: "20338969", Language: "ENG", LanguageAlternatives: "ENG", Department: "", Company: "", SubBuilding: "", BuildingNumber: "99", BuildingName: "", SecondaryStreet: "", Street: "Gresham Drive", Block: "", Neighbourhood: "", District: "", City: "Romford", Line1: "99 Gresham Drive", Line2: "", Line3: "", Line4: "", Line5: "", AdminAreaName: "Redbridge", AdminAreaCode: "", Province: "", ProvinceName: "", ProvinceCode: "", PostalCode: "RM6 4TR", CountryName: "United Kingdom", CountryIso2: "GB", CountryIso3: "GBR", CountryIsoNumber: "826", SortingNumber1: "65115", SortingNumber2: "", Barcode: "(RM64TR2ZR)", POBoxNumber: "", Label: "99 Gresham Drive\nROMFORD\nRM6 4TR\nUNITED KINGDOM", Type: "Residential", DataLevel: "Premise", Field1: "", Field2: "", Field3: "", Field4: "", Field5: "", Field6: "", Field7: "", Field8: "", Field9: "", Field10: "", Field11: "", Field12: "", Field13: "", Field14: "", Field15: "", Field16: "", Field17: "", Field18: "", Field19: "", Field20: "", }, ], }, "GB|RM|A|51074547": { Items: [ { Id: "GB|RM|A|51074547", DomesticId: "51074547", Language: "ENG", LanguageAlternatives: "ENG", Department: "", Company: "Curtis Mallet-Prevost Colt & Mosle LLP", SubBuilding: "", BuildingNumber: "99", BuildingName: "", SecondaryStreet: "", Street: "Gresham Street", Block: "", Neighbourhood: "", District: "", City: "London", Line1: "99 Gresham Street", Line2: "", Line3: "", Line4: "", Line5: "", AdminAreaName: "City of London", AdminAreaCode: "", Province: "", ProvinceName: "", ProvinceCode: "", PostalCode: "EC2V 7NG", CountryName: "United Kingdom", CountryIso2: "GB", CountryIso3: "GBR", CountryIsoNumber: "826", SortingNumber1: "74127", SortingNumber2: "", Barcode: "(EC2V7NG1RL)", POBoxNumber: "", Label: "Curtis Mallet-Prevost Colt & Mosle LLP\n99 Gresham Street\nLONDON\nEC2V 7NG\nUNITED KINGDOM", Type: "Commercial", DataLevel: "Premise", Field1: "", Field2: "", Field3: "", Field4: "", Field5: "", Field6: "", Field7: "", Field8: "", Field9: "", Field10: "", Field11: "", Field12: "", Field13: "", Field14: "", Field15: "", Field16: "", Field17: "", Field18: "", Field19: "", Field20: "", }, ], }, "GB|RM|A|56463483": { Items: [ { Id: "GB|RM|A|56463483", DomesticId: "56463483", Language: "ENG", LanguageAlternatives: "ENG", Department: "", Company: "Hugh James", SubBuilding: "", BuildingNumber: "99", BuildingName: "", SecondaryStreet: "", Street: "Gresham Street", Block: "", Neighbourhood: "", District: "", City: "London", Line1: "99 Gresham Street", Line2: "", Line3: "", Line4: "", Line5: "", AdminAreaName: "City of London", AdminAreaCode: "", Province: "", ProvinceName: "", ProvinceCode: "", PostalCode: "EC2V 7NG", CountryName: "United Kingdom", CountryIso2: "GB", CountryIso3: "GBR", CountryIsoNumber: "826", SortingNumber1: "74127", SortingNumber2: "", Barcode: "(EC2V7NG1ZT)", POBoxNumber: "", Label: "Hugh James\n99 Gresham Street\nLONDON\nEC2V 7NG\nUNITED KINGDOM", Type: "Commercial", DataLevel: "Premise", Field1: "", Field2: "", Field3: "", Field4: "", Field5: "", Field6: "", Field7: "", Field8: "", Field9: "", Field10: "", Field11: "", Field12: "", Field13: "", Field14: "", Field15: "", Field16: "", Field17: "", Field18: "", Field19: "", Field20: "", }, ], }, "GB|RM|A|8186332": { Items: [ { Id: "GB|RM|A|8186332", DomesticId: "8186332", Language: "ENG", LanguageAlternatives: "ENG", Department: "", Company: "Xbridge Ltd", SubBuilding: "", BuildingNumber: "99", BuildingName: "", SecondaryStreet: "", Street: "Gresham Street", Block: "", Neighbourhood: "", District: "", City: "London", Line1: "99 Gresham Street", Line2: "", Line3: "", Line4: "", Line5: "", AdminAreaName: "City of London", AdminAreaCode: "", Province: "", ProvinceName: "", ProvinceCode: "", PostalCode: "EC2V 7NG", CountryName: "United Kingdom", CountryIso2: "GB", CountryIso3: "GBR", CountryIsoNumber: "826", SortingNumber1: "74127", SortingNumber2: "", Barcode: "(EC2V7NG1UO)", POBoxNumber: "", Label: "Xbridge Ltd\n99 Gresham Street\nLONDON\nEC2V 7NG\nUNITED KINGDOM", Type: "Commercial", DataLevel: "Premise", Field1: "", Field2: "", Field3: "", Field4: "", Field5: "", Field6: "", Field7: "", Field8: "", Field9: "", Field10: "", Field11: "", Field12: "", Field13: "", Field14: "", Field15: "", Field16: "", Field17: "", Field18: "", Field19: "", Field20: "", }, ], }, }; async search(_searchTerm: string): Promise { await delay(100); return MockLoqateAddressLookupService.mockAddressSearchResults; } async findById(_id: string): Promise { await delay(100); return MockLoqateAddressLookupService.mockAddressDetails; } async get(id: string): Promise { await delay(100); const details = MockLoqateAddressLookupService.mockAddressFineDetails[ id as keyof typeof MockLoqateAddressLookupService.mockAddressFineDetails ]; return details.Items[0]; } constructor({ baseUrl, apiKey }: { baseUrl?: string; apiKey?: string }) { this.#baseUrl = baseUrl; this.#apiKey = apiKey; } }