-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
17160 Update fetchNr with phone and email validation (#578)
* update fetchNr with phone and email validation * fix small * replace fetch NR func * remove old fetch func
- Loading branch information
Showing
9 changed files
with
352 additions
and
254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,14 +112,16 @@ export default class LegalServices { | |
} | ||
|
||
/** | ||
* Fetches name request data. | ||
* Fetches name request data with phone and email validation. | ||
* @param nrNumber the name request number (eg, NR 1234567) | ||
* @param phone the name request phone (eg, 12321232) | ||
* @param email the name request email (eg, [email protected]) | ||
* @returns a promise to return the NR data, or null if not found | ||
*/ | ||
static async fetchNameRequest (nrNumber: string): Promise<NameRequestIF> { | ||
static async fetchValidContactNr (nrNumber: string, phone = '', email = ''): Promise<NameRequestIF> { | ||
if (!nrNumber) throw new Error('Invalid parameter \'nrNumber\'') | ||
|
||
const url = `nameRequests/${nrNumber}` | ||
const url = `nameRequests/${nrNumber}/validate?phone=${phone}&email=${email}` | ||
return axios.get(url) | ||
.then(response => { | ||
const data = response?.data | ||
|
@@ -128,6 +130,10 @@ export default class LegalServices { | |
}).catch(error => { | ||
if (error?.response?.status === StatusCodes.NOT_FOUND) { | ||
return null // NR not found (not an error) | ||
} else if (error?.response?.status === StatusCodes.BAD_REQUEST) { | ||
throw new Error('Sent invalid email or phone number.') // Sent invalid email or phone | ||
} else if (error?.response?.status === StatusCodes.FORBIDDEN) { | ||
throw new Error('Not sent email or phone number.') // Not sent the email or phone | ||
} | ||
throw error | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters