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
| public class GetAddressAPI { | |
| // Get Address API: https://getaddress.io/ | |
| // Documentation: https://getaddress.io/Documentation | |
| public String getAddresses(String postcode) { | |
| if (postcode == null) { | |
| return null; | |
| } |
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
| public class StreetLayerAddressAutoCompleteAPI { | |
| // Street Layer: https://streetlayer.com/ | |
| // Documentation: https://streetlayer.com/documentation | |
| public List<String> getAddressAutoComplete(String input, String countryCode) { | |
| string responseData = makeAPICall(input, countryCode); | |
| AutoCompleteResponse response = (AutoCompleteResponse)JSON.deserialize(responseData, AutoCompleteResponse.class); |
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
| exampleJavaScriptMethod : function(cmp, value1, value2) { | |
| var action = cmp.get("c.exampleApexControllerMethod"); | |
| action.setParams({'param1': value1, 'param2': value2 }); | |
| action.setCallback(this, function(response) { | |
| var state = response.getState(); | |
| console.log('exampleJavaScriptMethod state: ' + state); | |
| if(cmp.isValid() && state === "SUCCESS"){ | |
| var result = response.getReturnValue(); | |
| console.log(result); | |
| // do something |
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
| // Documentation: https://developer.salesforce.com/docs/component-library/bundle/force:showToast/specification | |
| // type: 'error', 'warning', 'success', or 'info' | |
| showToast : function(title, message, type, icon) { | |
| var toastEvent = $A.get("e.force:showToast"); | |
| toastEvent.setParams({ | |
| title : title, | |
| message: message, | |
| duration: '2000', | |
| key: icon, |
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
| getQueryStringParameter : function(name) { | |
| var url = decodeURIComponent(window.location.search.substring(1)); | |
| var params = url.split('&'); | |
| for (var i = 0; i < params.length; i++) { | |
| var p = params[i].split('='); | |
| if (p[0] === name) { | |
| return p[1] === undefined ? true : p[1]; | |
| } |
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
| public class GoogleMapsGeocodeApi { | |
| public string geocode(String address){ | |
| String url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' | |
| + EncodingUtil.urlEncode(address, 'UTF-8') | |
| + '&components=country:GB' | |
| + '&key=' + getGoogleMapsAPIKey(); | |
| return getHttp(url); | |
| } |
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
| callAjax : function(method, url, async, callback) { | |
| var request = new XMLHttpRequest(); | |
| request.onreadystatechange = function(component) { | |
| if (request.readyState == 4 ) { | |
| callback.call(this, request); | |
| } | |
| }; | |
| request.open(method, url, async); | |
| request.send(); | |
| }, |
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
| promiseAction : function(cmp, methodName, params){ | |
| console.log(methodName); | |
| console.log(params); | |
| return new Promise(function(resolve, reject) { | |
| var action = cmp.get(methodName); | |
| action.setParams(params); | |
| action.setCallback(this, function(response) { | |
| var state = response.getState(); | |
| console.log(methodName + ' ' + state); | |
| if(cmp.isValid() && state === "SUCCESS"){ |
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
| castBooleanPropertiesToString : function(object) { | |
| var props = Object.getOwnPropertyNames(object); | |
| for (var i = 0; i < props.length; i++) { | |
| var propName = props[i]; | |
| if (typeof object[propName] == 'boolean'){ | |
| object[propName] = object[propName].toString(); | |
| } | |
| } | |
| }, |
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
| openModel : function(cmp, componentName, params, modelId, header, cssClass, callback) { | |
| var modalBody; | |
| $A.createComponent(componentName, params, | |
| function(content, status) { | |
| if (status === "SUCCESS") { | |
| modalBody = content; | |
| cmp.find(modelId).showCustomModal({ | |
| header: header, | |
| body: modalBody, | |
| cssClass: cssClass, |
OlderNewer