forked from dzmitry-duboyski/2captcha-ts
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5032a02
commit f41153c
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* | ||
* ### Renaming captcha parameters | ||
* | ||
* Description: parameter names used in the API may differ from those used in the library, in such cases parameter names are renamed in accordance with those used in the API. | ||
* | ||
* @param params - captcha parameters as an object | ||
* @returns returns new object with renamed params | ||
* | ||
*/ | ||
export default function renameParams(params: any) { | ||
let newParams: any = new Object(); | ||
|
||
/** | ||
* Captcha parameters that need to be renamed before sent to the API. | ||
*/ | ||
const replaceParams: any = { | ||
"cols" : "recaptchacols", | ||
"rows" : "recaptcharows", | ||
"minClicks" : "min_clicks", | ||
"maxClicks" : "max_clicks", | ||
"canSkip" : "can_no_answer", | ||
"previousId" : "previousID" | ||
} | ||
|
||
for(let key in params) { | ||
if(replaceParams.hasOwnProperty(key)) { | ||
newParams[replaceParams[key]] = params[key] | ||
} else { | ||
newParams[key] = params[key] | ||
} | ||
} | ||
|
||
return newParams | ||
} |