Best JavaScript code snippet using stryker-parent
att.js
Source:att.js
...60 };61 // *********************************************************network62 // createHttpObject() END******************63 // *********************************************************atthelper64 // prepareExecutor() START*****************************65 var attHelper = {66 prepareExecutor : function(thisRef) {67 if (thisRef.preparer && !thisRef.prepared) {68 thisRef.preparer();69 thisRef.prepared = true;70 }71 }72 };73 // *********************************************************atthelper74 // prepareExecutor() END******************75 // *********************************************************bedframe76 // build() START*****************************************77 var bedFrame = {};78 var BedFrame = {};79 /**80 * Default property type that results in only the latest specified81 * value being used (that is, the deepest child's value will be used82 * over any of its parents). Particularly useful for specifying83 * default values that most children use, and then overriding those84 * default values on exceptional children.85 */86 BedFrame.PROPERTY_TYPE_ONLY_LATEST = 0;87 /**88 * Property type that results in child values equating to their89 * parent value plus their own, separated by a forward slash.90 * Particularly useful for creating a URL hierarchy.91 */92 BedFrame.PROPERTY_TYPE_SLASH_COMBINE = 1;93 /**94 * Property type that results in a parent value not propogating to95 * its children.96 */97 BedFrame.PROPERTY_TYPE_IGNORE = 2;98 /**99 * Recursively builds a full API on the target object, as defined in100 * the api object. Properties will be added to the target object,101 * but the object reference itself will not be altered. This means102 * you can safely "build" on a CommonJS exports object.103 *104 * @param target105 * The object that the API will be created in.106 * @param api107 * The specifications for the API you want to expose108 * through objects. Read "THE API OBJECT" in readme.md to109 * find out more.110 */111 bedFrame.build = function bedFrameTransformObject(target, api) {112 // Save a reference to the children property of the current113 // segment of the API.114 var children = api.children || [], c;115 // Iterate over every child to set up its API.116 for (c in children) {117 // Avoid prototyped members.118 if (!children.hasOwnProperty(c)) {119 continue;120 }121 // Create a shorter reference to the present child.122 var child = children[c];123 // Determine the present property types, or default to an124 // empty object.125 // (We will pass this variable down in the next step;126 // propertyTypes is itself by default typed ONLY_LATEST).127 var propertyTypes = child.propertyTypes || api.propertyTypes || {};128 // Don't pass down children (that causes an infinite129 // recursion).130 propertyTypes.children = BedFrame.PROPERTY_TYPE_IGNORE;131 // Iterate over every member of the current segment of the132 // API.133 for (var o in api) {134 // Avoid prototyped members and children.135 if (!api.hasOwnProperty(o)) {136 continue;137 }138 // Based on the property type specified for this API,139 // cascade property down from parent to child.140 switch (propertyTypes[o]141 || BedFrame.PROPERTY_TYPE_ONLY_LATEST) {142 case BedFrame.PROPERTY_TYPE_ONLY_LATEST:143 // ONLY_LATEST results in child taking precedence144 // over the parent, completely replacing the value.145 child[o] = child[o] === undefined ? api[o] : child[o];146 break;147 case BedFrame.PROPERTY_TYPE_SLASH_COMBINE:148 // SLASH_COMBINE results in the child ending up with149 // a slash-separated-value from the top most150 // parent to the present child, where elements151 // without a value are ignored (there won't be any152 // double slashes in the computed value).153 var parts = [];154 if (api[o]) {155 parts.push(api[o]);156 }157 if (child[o]) {158 parts.push(child[o]);159 }160 child[o] = parts.join('/');161 break;162 }163 }164 // If the current child specifies the method property, and165 // does not have any children, it's an endpoint and166 // needs to be set up as a method. Inject it in to the167 // target.168 if (child.method && !child.children) {169 target[child.method] = (function(child) {170 return function() {171 // Executors are designed to work based off of172 // their context. Act upon the child, which is a173 // mixed174 // down result of its parent, and its parent's175 // parent, and so on.176 return child.executor.apply(child, arguments);177 };178 })(child);179 }180 // Otherwise, inject the new property in to the target, and181 // recurse upon the sub-segment of the API.182 else if (child.property) {183 bedFrameTransformObject(target[child.property] = {}, child);184 }185 }186 };187 bedFrame.BedFrame = BedFrame;188 // *********************************************************bedframe189 // build() END******************190 // Namespace used for API methods191 var ATT = {};192 193 (function() { //used to keep varibles private194 var protocol = 'https://';195 var domain = 'api.att.com'/*'api-uat.pacer.bf.sl.attcompute.com'*/;196 var origin = protocol + domain;197 198 // Constants key-value for setting Default Values and URL's199 ATT.Constants = {200 CONTENT_TYPE_JSON : 'application/json',201 ACCEPT_TYPE_JSON : 'application/json',202 CONTENT_TYPE_URL_ENCODED : 'application/x-www-form-urlencoded',203 ENDPOINT_ACCESS_TOKEN : origin + '/oauth/access_token',204 ENDPOINT_SMS : origin + '/sms/v3/messaging',205 ENDPOINT_STT : origin + '/speech/v3/speechToText',206 ENDPOINT_NOTARY : origin + '/Security/Notary/Rest/1/SignedPayload',207 ENDPOINT_ADS: origin + '/rest/1/ads?',208 ENDPOINT_MMS : origin + '/mms/v3/messaging',209 ENDPOINT_OAUTH : origin + '/oauth',210 ENDPOINT_WAPPUSH : origin + '/1/messages/outbox/wapPush',211 ENDPOINT_LOCATION : origin + '/2/devices/location',212 ENDPOINT_DEVICECAPABILITIES : origin + '/1/devices/',213 ENDPOINT_IMMN : origin + '/rest/1/MyMessages',214 ENDPOINT_ROOT_PAYMENT : origin,215 ENDPOINT_PAYMENT_NEWTRANSACTION : '/rest/3/Commerce/Payment/Transactions',216 ENDPOINT_PAYMENT_TRANSACTIONSTATUS : '/rest/3/Commerce/Payment/Transactions/',217 ENDPOINT_PAYMENT_NEWSUBSCRIPTIONS : '/rest/3/Commerce/Payment/Subscriptions',218 ENDPOINT_PAYMENT_SUBSCRIPTIONSTATUS : '/rest/3/Commerce/Payment/Subscriptions/',219 ENDPOINT_PAYMENT_REFUNDTRANSACTION : '/rest/3/Commerce/Payment/Transactions',220 ENDPOINT_PAYMENT_GETSUBSCRIPTIONDETAILS : '/rest/3/Commerce/Payment/Subscriptions/',221 ENDPOINT_PAYMENT_GETNOTIFICATION : '/rest/3/Commerce/Payment/Notifications/',222 ENDPOINT_PAYMENT_ACKNOWLEDGENOTIFICATION : '/rest/3/Commerce/Payment//Notifications/',223 ENDPOINT_CALLMGMT : origin + '/rest/1/Sessions',224 ENDPOINT_TTS : origin + '/speech/v3/textToSpeech'225 226 };227 })();228 // Session variables used across all methods229 var sessionOBJ = {230 attHelper : attHelper, // provide attHelper object231 bedFrame : bedFrame, // provide bedframe object for generic232 // method implementation format used233 // here.234 accessKeyId : null, // To be initialized via the authorize235 // method236 secretKey : null, // To be initialized via the authorize237 // method238 accessToken : null, // To be initialized via the239 // generateAccessToken method240 scope : null, // To be initalized via the authorize method241 oauthCode : null, // To be initialized via the242 // generateAccessToken method, Required only243 // if grantType = 'authorization_code'.244 grantType : null, // To be initialized via the245 // generateAccessToken method, value246 // 'client_credentials'.247 isOAuth_Code : false, // To be initialized via executors which248 // invoke call for OAUTH Token249 oauthToken : null, // To be initialized via the250 // generateAccessToken method,if grantType =251 // 'authorization_code'.252 refreshToken : null253 };254 /*255 * method to generate Access Token This method generate Token based256 * on the value of grantType. It is used to generate Access Token if257 * grantType = 'client_credentials'. It is used to generate Oauth258 * Token if grantType = 'authorization_code'.259 */260 var generateAccessToken = function(callBackToken) {261 var cbOnData = function(response) {262 var token = JSON.parse(response);263 console.log('Token generated: ' + response);264 if (sessionOBJ.isOAuth_Code === true) {265 sessionOBJ.isOAuth_Code = false;266 callBackToken(token.access_token);267 } else if (sessionOBJ.grantType === 'client_credentials') {268 window.localStorage.refreshToken = token.refresh_token;269 window.localStorage.access_token = token.access_token;270 callBackToken(window.localStorage.access_token);271 } else if (sessionOBJ.grantType === 'refresh_token') {272 window.localStorage.refreshToken = token.refresh_token;273 window.localStorage.access_token = token.access_token;274 callBackToken(window.localStorage.access_token);275 }276 };277 var cbOnError = function(error) {278 alert('error in generating token: ' + error);279 console.log('error in generating token: ' + error);280 };281 var body = null;282 var sUrl = ATT.Constants.ENDPOINT_ACCESS_TOKEN;283 if ((sessionOBJ.isOAuth_Code) && (sessionOBJ.grantType === 'authorization_code') && (sessionOBJ.oauthCode !== null)) {284 body = 'client_id=' + sessionOBJ.accessKeyId + '&client_secret=' + sessionOBJ.secretKey + '&grant_type=' + sessionOBJ.grantType + '&code=' + sessionOBJ.oauthCode;285 } else {286 if (sessionOBJ.grantType === 'client_credentials') {287 body = 'client_id=' + sessionOBJ.accessKeyId + '&client_secret=' + sessionOBJ.secretKey + '&grant_type=' + sessionOBJ.grantType + '&scope=' + sessionOBJ.scope;288 }289 if (sessionOBJ.grantType === 'refresh_token') {290 body = 'client_id=' + sessionOBJ.accessKeyId + '&client_secret=' + sessionOBJ.secretKey + '&grant_type=' + sessionOBJ.grantType + '&refresh_token=' + window.localStorage.refreshToken;291 }292 }293 var jquery_object = {294 url : sUrl,295 type : 'POST',296 async : true,297 data : body,298 headers : {299 Accept : ATT.Constants.ACCEPT_TYPE_JSON300 },301 crossDomain : true,302 beforeSend : function(xhr) {303 xhr.setRequestHeader('Content-Type', ATT.Constants.CONTENT_TYPE_URL_ENCODED);304 }305 };306 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);307 };308 /*309 * method to check Access Token .Once Access Token generated, saves310 * in window.localStorage.access_token.If Access Token is not311 * generated once, call generateAccessToken method,else use the312 * existing Access Token.313 */314 var checkAccessToken = function(callBackFunction) {315 if (window.localStorage.access_token) {316 callBackFunction(window.localStorage.access_token);317 } else {318 generateAccessToken(callBackFunction);319 }320 };321 /*322 * Uses the ATT API to invoke an Action specified by the method,323 * along with the parameters, returns the response returned by the324 * Service, and raises an Error callback in case of a failure.325 * @param params - Parameters to be sent @param cbOnData - CallBack326 * to be invoked for Response @param cbOnError - Callback to be327 * invoked for Error328 */329 /*330 * Executor for SMS api331 */332 var SMSExecutor = function(params, cbOnData, cbOnError) {333 sessionOBJ.attHelper.prepareExecutor(this);334 var self = this;335 336 337 338 var smsRequest = function(accessToken) {339 var jquery_object = {340 type : self.verb,341 async : true,342 headers : {343 Accept : params.accept344 },345 crossDomain : true,346 beforeSend : function(xhr) {347 xhr.setRequestHeader('Authorization', 'Bearer' + ' ' + accessToken);348 if (params.contentType !== undefined) {349 xhr.setRequestHeader('Content-Type', params.contentType);350 }351 if (params.accept !== undefined) {352 xhr.setRequestHeader('Accept', params.accept);353 }354 }355 };356 if (self.method.toLowerCase() === 'sendsms') {357 if (params.contentType.toLowerCase() === ATT.Constants.CONTENT_TYPE_JSON) {358 jquery_object.data = "{\"outboundSMSRequest\":" + JSON.stringify(params.body) + "}";359 } else {360 jquery_object.data = params.body;361 }362 }363 if (params.smsId !== undefined) {364 jquery_object.url = self.endPoint + self.appendUrl + params.smsId;365 } else if (params.registrationId !== undefined) {366 var getSMSEndPoint = (self.endPoint + self.appendUrl) + params.registrationId;367 jquery_object.url = getSMSEndPoint;368 } else {369 jquery_object.url = self.endPoint + self.appendUrl;370 }371 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);372 };373 /*374 * CALLING function to check Access Token If already Generated375 * then direct call API else generate AccessToken376 */377 checkAccessToken(smsRequest);378 };379 /*380 * Executor for NOTARY api381 */382 var NOTARYExecutor = function(params, cbOnData, cbOnError) {383 sessionOBJ.attHelper.prepareExecutor(this);384 var self = this, notaryRequest;385 notaryRequest = function(accessToken) {386 if (params.data.MerchantPaymentRedirectUrl !== undefined) {387 params.data.MerchantPaymentRedirectUrl = params.data.MerchantPaymentRedirectUrl + "?token=" + window.localStorage.access_token;388 }389 var jquery_object = {390 type : self.verb,391 async : true,392 url : self.endPoint,393 headers : {394 Accept : params.accept395 },396 data : JSON.stringify(params.data),397 crossDomain : true,398 beforeSend : function(xhr) {399 xhr.setRequestHeader('Client_id', params.clientId);400 if (params.contentLength) {401 xhr.setRequestHeader('Content-Length', params.contentLength);402 }403 xhr.setRequestHeader('Client_secret', params.clientSecret);404 if (params.contentType !== undefined) {405 xhr.setRequestHeader('Content-Type', params.contentType);406 }407 if (params.accept !== undefined) {408 xhr.setRequestHeader('Accept', params.accept);409 }410 }411 };412 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);413 };414 /*415 * CALLING function to check Access Token If already Generated416 * then direct call API else generate AccessToken417 */418 checkAccessToken(notaryRequest);419 };420 /*421 * Executor for SPEECHTOTEXT api422 */423 var STTExecutor = function(params, cbOnData, cbOnError) {424 sessionOBJ.attHelper.prepareExecutor(this);425 var self = this, ContentType, accept, sttRequest;426 sttRequest = function(accessToken) {427 var token = 'Bearer' + ' ' + accessToken;428 if (params.accept !== undefined) {429 accept = params.accept;430 }431 if (params.contentType !== undefined) {432 ContentType = params.contentType;433 }434 var args = [{435 filePath : params.filePath,436 token : token,437 accept : accept,438 contentType : ContentType,439 contentLanguage : ((params.contentLanguage === undefined) ? "" : params.contentLanguage),440 contentLength : ((params.contentLength === undefined) ? "" : params.contentLength),441 XSpeechContext : ((params.xSpeechContext === undefined) ? "Generic" : params.xSpeechContext),442 transferEncoding : ((params.transferEncoding === undefined) ? "" : params.transferEncoding),443 xarg : ((params.xarg === undefined) ? "" : params.xarg),444 url : self.endPoint445 }];446 return cordova.exec(cbOnData, cbOnError, "AttPlugin", "speechToText", args);447 };448 /*449 * CALLING function to check Access Token If already Generated450 * then direct call API else generate AccessToken451 */452 checkAccessToken(sttRequest);453 };454 455 /*456 * Executor for TextToSpeech api457 */458 var TTSExecutor = function(params, cbOnData, cbOnError) {459 sessionOBJ.attHelper.prepareExecutor(this);460 var self, args;461 self = this;462 //var accessToken = 'e3a8e54ed675bb863b605aea926354dd';463 var ttsRequest = function(accessToken) {464 465 var token = 'Bearer' + ' ' + accessToken;466 args = [ {467 url : self.endPoint,468 token : token,469 body : params.body ? params.body : '',470 data : params.data,471 contentType : params.contentType ? params.contentType472 : '',473 accept : params.accept ? params.accept 474 : '',475 xarg : params.xarg,476 filePath : params.filePath477 } ];478 479 return Cordova.exec(cbOnData, cbOnError, "AttPlugin",480 "textToSpeech", args);481 };482 /*483 * CALLING function to check Access Token If already Generated484 * then direct call API else generate AccessToken485 */486 checkAccessToken(ttsRequest);487 };488 /*489 * Executor for OAUTH api490 */491 var OAUTHExecutor = function(params, cbOnData, cbOnError) {492 sessionOBJ.attHelper.prepareExecutor(this);493 var self = this;494 var jquery_object = {495 type : self.verb,496 async : true,497 headers : {498 Accept : params.accept499 },500 crossDomain : true501 };502 if ((params.clientId !== undefined) && (params.scope !== undefined)) {503 if (params.redirectUrl !== undefined) {504 jquery_object.url = self.endPoint + self.appendUrl + '?' + 'client_id=' + params.clientId + '&' + 'scope=' + params.scope + '&' + 'redirect_url=' + params.redirectUrl;505 } else {506 jquery_object.url = self.endPoint + self.appendUrl + '?' + 'client_id=' + params.clientId + '&' + 'scope=' + params.scope;507 }508 } else {509 jquery_object.url = self.endPoint + self.appendUrl;510 }511 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);512 };513 /*514 * Executor for WAPPush api515 */516 var SendWAPPushExecutor = function(params, cbOnData, cbOnError) {517 sessionOBJ.attHelper.prepareExecutor(this);518 var self, wapRequest, args;519 self = this;520 wapRequest = function(accessToken) {521 var token = 'Bearer' + ' ' + accessToken;522 args = [{523 url : self.endPoint,524 accessToken : token,525 body : params.body ? params.body : '',526 data : params.data,527 contentType : params.contentType ? params.contentType : '',528 accept : params.accept ? params.accept : ''529 }];530 return Cordova.exec(cbOnData, cbOnError, "AttPlugin", "sendWAPPush", args);531 };532 /*533 * CALLING function to check Access Token If already Generated534 * then direct call API else generate AccessToken535 */536 checkAccessToken(wapRequest);537 };538 /*539 * Executor for LOCATION api540 */541 var LOCATIONExecutor = function(params, cbOnData, cbOnError) {542 sessionOBJ.attHelper.prepareExecutor(this);543 var self = this, locationRequest, body = '';544 locationRequest = function(accessToken) {545 if ((params.requestedAccuracy !== undefined) || (params.tolerance !== undefined) || (params.acceptableAccuracy !== undefined)) {546 for (var keys in params) {547 if ((params.hasOwnProperty(keys)) && (keys !== 'Accept')) {548 body = body + '&' + keys + '=' + params[keys];549 }550 }551 body = body.substr(1, body.length);552 }553 var jquery_object = {554 type : self.verb,555 async : true,556 headers : {557 Accept : params.accept558 },559 url : self.endPoint + '?' + body,560 crossDomain : true,561 beforeSend : function(xhr) {562 xhr.setRequestHeader('Authorization', 'Bearer' + ' ' + accessToken);563 if (params.accept !== undefined) {564 xhr.setRequestHeader('Accept', params.accept);565 }566 }567 };568 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);569 };570 /*571 * set sessionOBJ.isOAuth_Code = true to indicate generation of572 * oauth token.573 * CALLING function generate AccessToken574 */575 sessionOBJ.isOAuth_Code = true;576 generateAccessToken(locationRequest);577 };578 579 /**580 * Executor for ADS api.581 * This ADS api call uses native module.582 */583 var ADSExecutor = function(params, cbOnData, cbOnError) {"use strict";584 sessionOBJ.attHelper.prepareExecutor(this);585 var self = this, adsRequest;586 adsRequest = function(accessToken) {587 588 var queryString = (typeof params.body === 'string') ? params.body : $.param(params.body);589 590 var jquery_object = {591 type : self.verb,592 url: self.endPoint + queryString,593 async : true,594 crossDomain : true,595 headers: {596 'Accept': params.accept,597 'Authorization': 'Bearer' + ' ' + accessToken,598 'Udid': params.udid599 }600 };601 602 httpRequest.createHttpObject(jquery_object, cbOnData,603 cbOnError);604 };605 /**606 * CALLING function to check Access Token607 * If already Generated then direct call API else generate AccessToken608 */609 610 checkAccessToken(adsRequest);611 };612 /*613 * Executor for MMS api614 */615 var MMSExecutor = function(params, cbOnData, cbOnError) {616 sessionOBJ.attHelper.prepareExecutor(this);617 var self = this, mmsRequest;618 mmsRequest = function(accessToken) {619 if (self.method.toLowerCase() === 'getmmsdeliverystatus') {620 var jquery_object = {621 type : self.verb,622 async : true,623 headers : {624 Accept : params.accept625 },626 url : self.endPoint + self.appendUrl + '/' + params.id,627 crossDomain : true,628 beforeSend : function(xhr) {629 xhr.setRequestHeader('Authorization', 'Bearer' + ' ' + accessToken);630 }631 };632 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);633 } else {634 var token = 'Bearer' + ' ' + accessToken;635 var data;636 if (params.contentType.toLowerCase() === ATT.Constants.CONTENT_TYPE_JSON) {637 data = "{\"outboundMessageRequest\":" + JSON.stringify(params.body) + "}";638 }else {639 data = params.body;640 }641 var types = [{642 body : (params.body !== undefined) ? data : '',643 accessToken : token,644 url : self.endPoint + self.appendUrl,645 accept : (params.accept !== undefined) ? params.accept : '',646 attachments : (params.attachments && params.attachments.length > 0) ? params.attachments : [{}],647 contentType : (params.contentType !== undefined) ? params.contentType : ''648 }]649 return Cordova.exec(cbOnData, cbOnError, "AttPlugin", "sendMMS", types);650 }651 };652 /*653 * CALLING function to check Access Token If already Generated654 * then direct call API else generate AccessToken655 */656 checkAccessToken(mmsRequest);657 };658 /*659 * Executor for Payment api660 */661 var PaymentExecutor = function(params, cbOnData, cbOnError) {662 var self = this, refundTransaction, getStatus;663 sessionOBJ.attHelper.prepareExecutor(this);664 if (self.method.toLowerCase() === 'newtransaction' || self.method.toLowerCase() === 'newsubscription') {665 cbOnData(this.endPoint + this.appendUrl + '?Signature=' + params.signature + "&SignedPaymentDetail=" + params.signedDocument + "&clientid=" + params.clientId);666 } else if (self.method.toLowerCase() === 'refundtransaction') {667 refundTransaction = function(accessToken) {668 var jquery_object = {669 type : self.verb,670 async : true,671 headers : {672 Accept : params.accept673 },674 url : self.endPoint + self.appendUrl + '/' + params.transactionId + '?Action=' + params.action,675 crossDomain : true,676 beforeSend : function(xhr) {677 xhr.setRequestHeader('Authorization', ('Bearer' + ' ' + accessToken));678 if (params.contentType !== undefined) {679 xhr.setRequestHeader('Content-Type', params.contentType);680 }681 if (params.accept !== undefined) {682 xhr.setRequestHeader('Accept', params.accept);683 }684 }685 };686 if (params.contentType === ATT.Constants.CONTENT_TYPE_JSON) {687 jquery_object.data = JSON.stringify(params.body);688 } else {689 jquery_object.data = params.body;690 }691 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);692 };693 checkAccessToken(refundTransaction);694 } else {695 getStatus = function(accessToken) {696 var jquery_object = {697 type : self.verb,698 async : true,699 headers : {700 Accept : params.accept701 },702 crossDomain : true,703 beforeSend : function(xhr) {704 xhr.setRequestHeader('Authorization', 'Bearer' + ' ' + accessToken);705 if (params.accept !== undefined) {706 xhr.setRequestHeader('Accept', params.accept);707 }708 }709 };710 if (self.method.toLowerCase() === 'getsubscriptionstatus') {711 if (params.subscriptionId) {712 jquery_object.url = self.endPoint + self.appendUrl + 'SubscriptionId/' + params.subscriptionId;713 } else if (params.merchantTransactionId) {714 jquery_object.url = self.endPoint + self.appendUrl + 'MerchantTransactionId/' + params.merchantTransactionId;715 } else if (params.subscriptionAuthCode) {716 jquery_object.url = self.endPoint + self.appendUrl + 'SubscriptionAuthCode/' + params.subscriptionAuthCode;717 }718 } else if (self.method.toLowerCase() === 'gettransactionstatus') {719 if (params.transactionId) {720 jquery_object.url = self.endPoint + self.appendUrl + 'TransactionId/' + params.transactionID;721 } else if (params.merchantTransactionId) {722 jquery_object.url = self.endPoint + self.appendUrl + 'MerchantTransactionId/' + params.merchantTransactionId;723 } else if (params.transactionAuthCode) {724 jquery_object.url = self.endPoint + self.appendUrl + 'TransactionAuthCode/' + params.transactionAuthCode;725 }726 } else if (self.method.toLowerCase() === 'getnotification' || self.method.toLowerCase() === 'acknowledgenotification') {727 jquery_object.url = self.endPoint + self.appendUrl + params.notificationId;728 } else if (self.method.toLowerCase() === 'getsubscriptiondetails') {729 jquery_object.url = self.endPoint + self.appendUrl + params.merchantSubscriptionId + '/Detail/' + params.consumerId;730 }731 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);732 };733 /*734 * CALLING function to check Access Token If already735 * Generated then direct call API else generate AccessToken736 */737 checkAccessToken(getStatus);738 }739 };740 /*741 * Executor for DeviceCapabilities api742 */743 var DeviceCapabilitiesExecutor = function(params, cbOnData, cbOnError) {"use strict";744 sessionOBJ.attHelper.prepareExecutor(this);745 var self = this, ObtainDeviceCapabilities;746 var address;747 ObtainDeviceCapabilities = function(accessToken) {748 address = encodeURIComponent(params.Address);749 var jquery_object = {750 type : self.verb,751 async : true,752 headers : {753 Accept : params.Accept754 },755 url : self.endPoint + address + self.appendUrl,756 crossDomain : true,757 beforeSend : function(xhr) {758 xhr.setRequestHeader('Authorization', 'Bearer' + ' ' + accessToken);759 if (params.Accept === undefined) {760 xhr.setRequestHeader('Accept', self.accept);761 }762 }763 };764 httpRequest.createHttpObject(jquery_object, cbOnData, cbOnError);765 };766 /*767 * set sessionOBJ.isOAuth_Code = true to indicate generation of768 * oauth token.769 * CALLING function generate AccessToken770 */771 sessionOBJ.isOAuth_Code = true;772 generateAccessToken(ObtainDeviceCapabilities);773 };774 775 /*776 * Executor for Call Management api777 */778 var CallMgmtExecutor = function(params, cbOnData, cbOnError) {779 sessionOBJ.attHelper.prepareExecutor(this);780 var self = this;781 var callMgmtRequest = function(accessToken) {782 var jquery_object = {783 type : self.verb,784 async : false,785 headers : {786 Accept : params.accept787 },788 crossDomain : true,789 beforeSend : function(xhr) {790 xhr.setRequestHeader('Authorization', 'Bearer'791 + ' ' + accessToken);792 if (params.contentType !== undefined) {793 xhr.setRequestHeader('Content-Type',794 params.contentType);795 }796 if (params.accept !== undefined) {797 xhr.setRequestHeader('Accept', params.accept);798 }799 }800 };801 if (self.method.toLowerCase() === 'createsession') {802 if (params.contentType.toLowerCase() === ATT.Constants.CONTENT_TYPE_JSON) {803 jquery_object.data = JSON.stringify(params.body);804 } else {805 jquery_object.data = params.body;806 }807 //jquery_object.url = self.endPoint + self.appendUrl;808 jquery_object.url = self.endPoint;809 }810 else if (self.method.toLowerCase() === 'sendsignal') {811 812 if (params.contentType.toLowerCase() === ATT.Constants.CONTENT_TYPE_JSON) {813 jquery_object.data = JSON.stringify(params.body);814 } else {815 jquery_object.data = params.body;816 }817 jquery_object.url = self.endPoint + '/' + params.cmsId + '/Signals';818 }819 820 httpRequest.createHttpObject(jquery_object, cbOnData,821 cbOnError);822 };823 /*824 * CALLING function to check Access Token If already Generated825 * then direct call API else generate AccessToken826 */827 checkAccessToken(callMgmtRequest);828 };829 /*830 * Executor for IMMN api831 */832 var IMMNExecutor = function(params, cbOnData, cbOnError) {833 sessionOBJ.attHelper.prepareExecutor(this);834 var self = this, immnRequest;835 immnRequest = function(accessToken) {836 if (self.method.toLowerCase() === 'sendmessage') {837 var token = 'Bearer' + ' ' + accessToken;838 var types = [{839 body : params.body ? params.body : '',840 accessToken : token,841 url : self.endPoint,842 accept : (params.accept !== undefined) ? params.accept : '',843 attachments : (params.attachments !== undefined) ? params.attachments : [{}],844 contentType : params.contentType ? params.contentType : ''845 }]846 return Cordova.exec(cbOnData, cbOnError, "AttPlugin", "sendMessage", types);847 } else {...
prepare.ts
Source:prepare.ts
1import * as vscode from "vscode";2import createCore from "../core";3import Command from "./command";4const prepareExecutor = () => {5 if (6 !vscode.workspace.workspaceFolders ||7 !vscode.workspace.workspaceFolders.length8 ) {9 vscode.window.showErrorMessage(10 "There should be open project to learn typing..."11 );12 return;13 }14 try {15 vscode.window.tabGroups.close(vscode.window.tabGroups.activeTabGroup);16 const core = createCore(vscode.workspace.workspaceFolders[0].uri.path);17 core.run();18 vscode.window.showInformationMessage("Learn typing prepared!");19 } catch (e) {20 vscode.window.showErrorMessage((e as Error).message);21 }22};23const prepare: Command = ["learn-typing.prepare", prepareExecutor];...
Using AI Code Generation
1const prepareExecutor = require('stryker-parent').prepareExecutor;2prepareExecutor({3});4module.exports = function(config) {5 config.set({6 });7};
Using AI Code Generation
1var prepareExecutor = require('stryker-parent').prepareExecutor;2prepareExecutor().then(function() {3 var api = require('stryker-api/core');4 var MochaTestRunner = require('stryker-mocha-runner');5 var MochaTestFramework = require('stryker-mocha-framework');6 var MochaTestRunner = require('stryker-mocha-test-runner');7 var MochaTestFramework = require('stryker-mocha-test-framework');8 var MochaTestRunner = require('stryker-mocha-runner');9 var MochaTestFramework = require('stryker-mocha-framework');10 var MochaTestRunner = require('stryker-mocha-test-runner');11 var MochaTestFramework = require('stryker-mocha-test-framework');12 var MochaTestRunner = require('stryker-mocha-runner');13 var MochaTestFramework = require('stryker-mocha-framework');14 var MochaTestRunner = require('stryker-mocha-test-runner');15 var MochaTestFramework = require('stryker-mocha-test-framework');16 var MochaTestRunner = require('stryker-mocha-runner');17 var MochaTestFramework = require('stryker-mocha-framework');18 var MochaTestRunner = require('stryker-mocha-test-runner');19 var MochaTestFramework = require('stryker-mocha-test-framework');
Using AI Code Generation
1module.exports.prepareExecutor = function () {2}3{4 "scripts": {5 }6}7module.exports = function (config) {8 config.set({9 mochaOptions: {10 }11 });12};13function add(a, b) {14 return a + b;15}16const assert = require('assert');17const index = require('../src/index');18describe('index', function () {19 it('should add 2 numbers', function () {20 assert.equal(index.add(3, 5), 8);21 });22});
Using AI Code Generation
1const { prepareExecutor } = require('stryker-parent');2prepareExecutor(config).then(function(executor){3 executor.runMutationTest().then(function(result){4 console.log(result);5 });6});7const { prepareExecutor } = require('stryker-cli');8prepareExecutor(config).then(function(executor){9 executor.runMutationTest().then(function(result){10 console.log(result);11 });12});13const { prepareExecutor } = require('stryker-api');14prepareExecutor(config).then(function(executor){15 executor.runMutationTest().then(function(result){16 console.log(result);17 });18});19const { prepareExecutor } = require('stryker');20prepareExecutor(config).then(function(executor){21 executor.runMutationTest().then(function(result){22 console.log(result);23 });24});25const { Stryker } = require('stryker-api/core');26const stryker = new Stryker(config);27stryker.runMutationTest().then(function(result){28 console.log(result);29});30const { Stryker } = require('stryker-cli/src/Stryker');31const stryker = new Stryker(config);32stryker.runMutationTest().then(function(result){33 console.log(result);34});35const { Stryker } = require('stryker-parent/src/Stryker');36const stryker = new Stryker(config);37stryker.runMutationTest().then(function(result){38 console.log(result);39});
Using AI Code Generation
1var prepareExecutor = require('stryker-parent').prepareExecutor;2prepareExecutor('test-runner', 'test-framework', function(err, executor) {3});4module.exports = function(config, done) {5}6module.exports = function(config, done) {7}8executor.run(config, function(err, result) {9});
Using AI Code Generation
1module.exports = function(config) {2 config.set({3 });4};5module.exports = function(config) {6 config.set({7 });8};9module.exports = function(config) {10 config.set({11 });12};13module.exports = function(config) {14 config.set({15 });16};17module.exports = function(config) {18 config.set({19 });20};21module.exports = function(config) {22 config.set({
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!