Skip to content
Merged
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
72 changes: 36 additions & 36 deletions src/international_street/Candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ export interface IntlStreetComponents {
superAdministrativeArea: string | undefined;
administrativeArea: string | undefined;
administrativeAreaIso2: string | undefined;
administrativeAreaShort: string | undefined;
administrativeAreaLong: string | undefined;
attention: string | undefined;
subAdministrativeArea: string | undefined;
dependentLocality: string | undefined;
dependentLocalityName: string | undefined;
Expand All @@ -18,6 +17,11 @@ export interface IntlStreetComponents {
premisePrefixNumber: string | undefined;
premiseNumber: string | undefined;
premiseType: string | undefined;
shortAddressCode: string | undefined;
subBuildingLeadingType: string | undefined;
subBuildingBlock: string | undefined;
subBuildingDoor: string | undefined;
subBuildingStaircase: string | undefined;
thoroughfare: string | undefined;
thoroughfarePredirection: string | undefined;
thoroughfarePostdirection: string | undefined;
Expand Down Expand Up @@ -57,8 +61,7 @@ export interface IntlChangesComponents {
superAdministrativeArea: string | undefined;
administrativeArea: string | undefined;
administrativeAreaIso2: string | undefined;
administrativeAreaShort: string | undefined;
administrativeAreaLong: string | undefined;
attention: string | undefined;
subAdministrativeArea: string | undefined;
dependentLocality: string | undefined;
dependentLocalityName: string | undefined;
Expand Down Expand Up @@ -97,6 +100,11 @@ export interface IntlChangesComponents {
postBox: string | undefined;
postBoxType: string | undefined;
postBoxNumber: string | undefined;
shortAddressCode: string | undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are at the end of the changes list, but somewhere in the middle of the normal components list. Doesn't matter functionally so it's fine not to change it, but just wanted to point it out in case we cared about that level of consistency.

subBuildingLeadingType: string | undefined;
subBuildingBlock: string | undefined;
subBuildingDoor: string | undefined;
subBuildingStaircase: string | undefined;
}

export interface IntlChanges {
Expand All @@ -109,10 +117,6 @@ export interface IntlChanges {
address6: string | undefined;
address7: string | undefined;
address8: string | undefined;
address9: string | undefined;
address10: string | undefined;
address11: string | undefined;
address12: string | undefined;
components: IntlChangesComponents;
}

Expand All @@ -138,8 +142,7 @@ interface RawIntlStreetRawComponents {
super_administrative_area?: string;
administrative_area?: string;
administrative_area_iso2?: string;
administrative_area_short?: string;
administrative_area_long?: string;
attention?: string;
sub_administrative_area?: string;
dependent_locality?: string;
dependent_locality_name?: string;
Expand All @@ -153,6 +156,11 @@ interface RawIntlStreetRawComponents {
premise_prefix_number?: string;
premise_number?: string;
premise_type?: string;
short_address_code?: string;
sub_building_leading_type?: string;
sub_building_block?: string;
sub_building_door?: string;
sub_building_staircase?: string;
thoroughfare?: string;
thoroughfare_predirection?: string;
thoroughfare_postdirection?: string;
Expand Down Expand Up @@ -197,10 +205,6 @@ interface RawIntlChanges {
address6?: string;
address7?: string;
address8?: string;
address9?: string;
address10?: string;
address11?: string;
address12?: string;
components?: RawIntlStreetRawComponents;
}

Expand Down Expand Up @@ -231,10 +235,6 @@ export interface RawIntlStreetCandidate {
address6?: string;
address7?: string;
address8?: string;
address9?: string;
address10?: string;
address11?: string;
address12?: string;
components?: RawIntlStreetRawComponents;
analysis?: RawIntlStreetAnalysis;
metadata?: RawIntlStreetMetadata;
Expand All @@ -250,10 +250,6 @@ export default class Candidate {
address6: string;
address7: string;
address8: string;
address9: string;
address10: string;
address11: string;
address12: string;
components: IntlStreetComponents;
analysis: IntlStreetAnalysis;
metadata: IntlStreetMetadata;
Expand All @@ -268,19 +264,14 @@ export default class Candidate {
this.address6 = responseData.address6 ?? "";
this.address7 = responseData.address7 ?? "";
this.address8 = responseData.address8 ?? "";
this.address9 = responseData.address9 ?? "";
this.address10 = responseData.address10 ?? "";
this.address11 = responseData.address11 ?? "";
this.address12 = responseData.address12 ?? "";

this.components = {} as IntlStreetComponents;
if (responseData.components !== undefined) {
this.components.countryIso3 = responseData.components.country_iso_3;
this.components.superAdministrativeArea = responseData.components.super_administrative_area;
this.components.administrativeArea = responseData.components.administrative_area;
this.components.administrativeAreaIso2 = responseData.components.administrative_area_iso2;
this.components.administrativeAreaShort = responseData.components.administrative_area_short;
this.components.administrativeAreaLong = responseData.components.administrative_area_long;
this.components.attention = responseData.components.attention;
this.components.subAdministrativeArea = responseData.components.sub_administrative_area;
this.components.dependentLocality = responseData.components.dependent_locality;
this.components.dependentLocalityName = responseData.components.dependent_locality_name;
Expand All @@ -294,6 +285,11 @@ export default class Candidate {
this.components.premisePrefixNumber = responseData.components.premise_prefix_number;
this.components.premiseNumber = responseData.components.premise_number;
this.components.premiseType = responseData.components.premise_type;
this.components.shortAddressCode = responseData.components.short_address_code;
this.components.subBuildingLeadingType = responseData.components.sub_building_leading_type;
this.components.subBuildingBlock = responseData.components.sub_building_block;
this.components.subBuildingDoor = responseData.components.sub_building_door;
this.components.subBuildingStaircase = responseData.components.sub_building_staircase;
this.components.thoroughfare = responseData.components.thoroughfare;
this.components.thoroughfarePredirection = responseData.components.thoroughfare_predirection;
this.components.thoroughfarePostdirection =
Expand Down Expand Up @@ -352,10 +348,6 @@ export default class Candidate {
this.analysis.changes.address6 = responseData.analysis.changes.address6;
this.analysis.changes.address7 = responseData.analysis.changes.address7;
this.analysis.changes.address8 = responseData.analysis.changes.address8;
this.analysis.changes.address9 = responseData.analysis.changes.address9;
this.analysis.changes.address10 = responseData.analysis.changes.address10;
this.analysis.changes.address11 = responseData.analysis.changes.address11;
this.analysis.changes.address12 = responseData.analysis.changes.address12;

this.analysis.changes.components = {} as IntlChangesComponents;
if (responseData.analysis.changes.components !== undefined) {
Expand All @@ -367,10 +359,8 @@ export default class Candidate {
responseData.analysis.changes.components.administrative_area;
this.analysis.changes.components.administrativeAreaIso2 =
responseData.analysis.changes.components.administrative_area_iso2;
this.analysis.changes.components.administrativeAreaShort =
responseData.analysis.changes.components.administrative_area_short;
this.analysis.changes.components.administrativeAreaLong =
responseData.analysis.changes.components.administrative_area_long;
this.analysis.changes.components.attention =
responseData.analysis.changes.components.attention;
this.analysis.changes.components.subAdministrativeArea =
responseData.analysis.changes.components.sub_administrative_area;
this.analysis.changes.components.dependentLocality =
Expand All @@ -397,6 +387,16 @@ export default class Candidate {
responseData.analysis.changes.components.premise_number;
this.analysis.changes.components.premiseType =
responseData.analysis.changes.components.premise_type;
this.analysis.changes.components.shortAddressCode =
responseData.analysis.changes.components.short_address_code;
this.analysis.changes.components.subBuildingLeadingType =
responseData.analysis.changes.components.sub_building_leading_type;
this.analysis.changes.components.subBuildingBlock =
responseData.analysis.changes.components.sub_building_block;
this.analysis.changes.components.subBuildingDoor =
responseData.analysis.changes.components.sub_building_door;
this.analysis.changes.components.subBuildingStaircase =
responseData.analysis.changes.components.sub_building_staircase;
this.analysis.changes.components.thoroughfare =
responseData.analysis.changes.components.thoroughfare;
this.analysis.changes.components.thoroughfarePredirection =
Expand Down
48 changes: 24 additions & 24 deletions tests/international_street/test_Candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ describe("An International match candidate", function () {
address6: "7",
address7: "8",
address8: "9",
address9: "10",
address10: "11",
address11: "12",
address12: "13",
components: {
country_iso_3: "14",
super_administrative_area: "15",
administrative_area: "16",
administrative_area_iso2: "16.1",
administrative_area_short: "16.2",
administrative_area_long: "16.3",
attention: "119",
sub_administrative_area: "17",
dependent_locality: "18",
dependent_locality_name: "19",
Expand All @@ -37,6 +32,11 @@ describe("An International match candidate", function () {
premise_prefix_number: "26.5",
premise_number: "27",
premise_type: "28",
short_address_code: "120",
sub_building_leading_type: "121",
sub_building_block: "122",
sub_building_door: "123",
sub_building_staircase: "124",
thoroughfare: "29",
thoroughfare_predirection: "30",
thoroughfare_postdirection: "31",
Expand Down Expand Up @@ -86,16 +86,11 @@ describe("An International match candidate", function () {
address6: "66",
address7: "67",
address8: "68",
address9: "69",
address10: "70",
address11: "71",
address12: "72",
components: {
country_iso_3: "73",
super_administrative_area: "74",
administrative_area: "75",
administrative_area_short: "75.1",
administrative_area_long: "75.2",
attention: "126",
sub_administrative_area: "76",
dependent_locality: "77",
dependent_locality_name: "78",
Expand All @@ -109,6 +104,11 @@ describe("An International match candidate", function () {
premise_prefix_number: "86",
premise_number: "87",
premise_type: "88",
short_address_code: "127",
sub_building_leading_type: "128",
sub_building_block: "129",
sub_building_door: "130",
sub_building_staircase: "131",
thoroughfare: "89",
thoroughfare_predirection: "90",
thoroughfare_postdirection: "91",
Expand Down Expand Up @@ -150,17 +150,12 @@ describe("An International match candidate", function () {
expect(candidate.address6).to.equal("7");
expect(candidate.address7).to.equal("8");
expect(candidate.address8).to.equal("9");
expect(candidate.address9).to.equal("10");
expect(candidate.address10).to.equal("11");
expect(candidate.address11).to.equal("12");
expect(candidate.address12).to.equal("13");
let components = candidate.components;
expect(components.countryIso3).to.equal("14");
expect(components.superAdministrativeArea).to.equal("15");
expect(components.administrativeArea).to.equal("16");
expect(components.administrativeAreaIso2).to.equal("16.1");
expect(components.administrativeAreaShort).to.equal("16.2");
expect(components.administrativeAreaLong).to.equal("16.3");
expect(components.attention).to.equal("119");
expect(components.subAdministrativeArea).to.equal("17");
expect(components.dependentLocality).to.equal("18");
expect(components.dependentLocalityName).to.equal("19");
Expand All @@ -174,6 +169,11 @@ describe("An International match candidate", function () {
expect(components.premisePrefixNumber).to.equal("26.5");
expect(components.premiseNumber).to.equal("27");
expect(components.premiseType).to.equal("28");
expect(components.shortAddressCode).to.equal("120");
expect(components.subBuildingLeadingType).to.equal("121");
expect(components.subBuildingBlock).to.equal("122");
expect(components.subBuildingDoor).to.equal("123");
expect(components.subBuildingStaircase).to.equal("124");
expect(components.thoroughfare).to.equal("29");
expect(components.thoroughfarePredirection).to.equal("30");
expect(components.thoroughfarePostdirection).to.equal("31");
Expand Down Expand Up @@ -221,16 +221,11 @@ describe("An International match candidate", function () {
expect(changes.address6).to.equal("66");
expect(changes.address7).to.equal("67");
expect(changes.address8).to.equal("68");
expect(changes.address9).to.equal("69");
expect(changes.address10).to.equal("70");
expect(changes.address11).to.equal("71");
expect(changes.address12).to.equal("72");
let ccomponents = changes.components;
expect(ccomponents.countryIso3).to.equal("73");
expect(ccomponents.superAdministrativeArea).to.equal("74");
expect(ccomponents.administrativeArea).to.equal("75");
expect(ccomponents.administrativeAreaShort).to.equal("75.1");
expect(ccomponents.administrativeAreaLong).to.equal("75.2");
expect(ccomponents.attention).to.equal("126");
expect(ccomponents.subAdministrativeArea).to.equal("76");
expect(ccomponents.dependentLocality).to.equal("77");
expect(ccomponents.dependentLocalityName).to.equal("78");
Expand All @@ -244,6 +239,11 @@ describe("An International match candidate", function () {
expect(ccomponents.premisePrefixNumber).to.equal("86");
expect(ccomponents.premiseNumber).to.equal("87");
expect(ccomponents.premiseType).to.equal("88");
expect(ccomponents.shortAddressCode).to.equal("127");
expect(ccomponents.subBuildingLeadingType).to.equal("128");
expect(ccomponents.subBuildingBlock).to.equal("129");
expect(ccomponents.subBuildingDoor).to.equal("130");
expect(ccomponents.subBuildingStaircase).to.equal("131");
expect(ccomponents.thoroughfare).to.equal("89");
expect(ccomponents.thoroughfarePredirection).to.equal("90");
expect(ccomponents.thoroughfarePostdirection).to.equal("91");
Expand Down