Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The following javascript was created to avoid duplicating code in postman's pre-request scripts
- */
- var amp = function() {
- var api_key = postman.getEnvironmentVariable("api_key"),
- api_key_id = postman.getEnvironmentVariable("api_key_id"),
- signature_delim = '|',
- sign = function(overrides) {
- if(typeof overrides !== 'object'){
- overrides = {};
- }
- var timestamp = Math.round(new Date() / 1000);
- if(overrides.timestamp){
- timestamp = overrides.timestamp;
- }
- var api_signature = "";
- var buffer = '/amp/api/createApp/?key_id=' + api_key_id +
- '×tamp=' + timestamp +
- signature_delim + request.data +
- signature_delim + api_key;
- api_signature = md5(buffer);
- postman.setGlobalVariable("api_timestamp", timestamp);
- postman.setGlobalVariable("api_signature", api_signature);
- },
- cleanup = function(){
- postman.clearGlobalVariable("api_timestamp");
- postman.clearGlobalVariable("api_signature");
- },
- md5 = function(value) {
- return CryptoJS.MD5(value).toString();
- }
- return {"sign":sign,"cleanup":cleanup };
- }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement