Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/v2.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouzel-yext authored Nov 20, 2024
2 parents b067ff6 + 2050135 commit beacd76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/provideEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,26 @@ export class EndpointsFactory {
}
}

/** Provides the cached domain based on environment and cloud region. */
getCachedDomain() {
switch (this.cloudChoice){
case CloudChoice.GLOBAL_GCP:
return `https://${this.environment}-cdn-cached-gcp.${this.cloudRegion}.yextapis.com`;
case CloudChoice.GLOBAL_MULTI:
default:
return `https://${this.environment}-cdn-cached.${this.cloudRegion}.yextapis.com`;
}
}

/** Provides all endpoints based on environment and cloud region. */
getEndpoints() {
return {
universalSearch: `${this.getDomain()}/v2/accounts/me/search/query`,
verticalSearch: `${this.getDomain()}/v2/accounts/me/search/vertical/query`,
questionSubmission: `${this.getDomain()}/v2/accounts/me/createQuestion`,
status: 'https://answersstatus.pagescdn.com',
universalAutocomplete: `${this.getDomain()}/v2/accounts/me/search/autocomplete`,
verticalAutocomplete: `${this.getDomain()}/v2/accounts/me/search/vertical/autocomplete`,
universalAutocomplete: `${this.getCachedDomain()}/v2/accounts/me/search/autocomplete`,
verticalAutocomplete: `${this.getCachedDomain()}/v2/accounts/me/search/vertical/autocomplete`,
filterSearch: `${this.getDomain()}/v2/accounts/me/search/filtersearch`,
};
}
Expand Down
4 changes: 2 additions & 2 deletions tests/provideEndpointsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ it('Prod, US, GCP produces expected endpoint', () => {
cloudRegion: CloudRegion.US,
cloudChoice: CloudChoice.GLOBAL_GCP
}).getEndpoints();
expect(endPoints).toHaveProperty('universalAutocomplete', 'https://prod-cdn-gcp.us.yextapis.com/v2/accounts/me/search/autocomplete');
expect(endPoints).toHaveProperty('universalAutocomplete', 'https://prod-cdn-cached-gcp.us.yextapis.com/v2/accounts/me/search/autocomplete');
});

it('Prod, EU, Multi produces expected endpoint', () => {
Expand All @@ -34,7 +34,7 @@ it('Prod, EU, Multi produces expected endpoint', () => {
cloudRegion: CloudRegion.EU,
cloudChoice: CloudChoice.GLOBAL_MULTI
}).getEndpoints();
expect(endPoints).toHaveProperty('verticalAutocomplete', 'https://prod-cdn.eu.yextapis.com/v2/accounts/me/search/vertical/autocomplete');
expect(endPoints).toHaveProperty('verticalAutocomplete', 'https://prod-cdn-cached.eu.yextapis.com/v2/accounts/me/search/vertical/autocomplete');
});

it('Prod, EU, GCP produces expected endpoint', () => {
Expand Down

0 comments on commit beacd76

Please sign in to comment.