Created
May 26, 2022 18:03
-
-
Save ViniciusResende/21c55b27eeceedb709b65e44d59bce41 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| *verifyBrandsURLsActiveness(brandsURLs) { | |
| function* getTurboRequestStatusCode(brand) { | |
| try { | |
| const { statusCode } = yield rp({ | |
| url: `${turboApiConfig[brand]}/${brandsURLs[brand].path}`, | |
| resolveWithFullResponse: true, | |
| timeout: 5000 | |
| }) | |
| return statusCode; | |
| } catch (error) { | |
| return error.statusCode; | |
| } | |
| } | |
| const statusCodeObj = { | |
| americanas: yield getTurboRequestStatusCode('americanas'), | |
| submarino: yield getTurboRequestStatusCode('submarino'), | |
| shoptime: yield getTurboRequestStatusCode('shoptime'), | |
| } | |
| function getBrandsURLsActivenessFinalObj(brand) { | |
| return { | |
| active: statusCodeObj[brand] === httpStatus.OK, | |
| url: brandsURLs[brand].url | |
| } | |
| } | |
| return { | |
| americanas: getBrandsURLsActivenessFinalObj('americanas'), | |
| submarino: getBrandsURLsActivenessFinalObj('submarino'), | |
| shoptime: getBrandsURLsActivenessFinalObj('shoptime'), | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment