Skip to content

Instantly share code, notes, and snippets.

View amitastreait's full-sized avatar
🎯
Creativity ki potli liye chala ja raha ek bairagi

Amit Singh amitastreait

🎯
Creativity ki potli liye chala ja raha ek bairagi
View GitHub Profile
/*
* @Author : Amit Singh
* @Date : 22nd Feb 2018
* @Description : Class is responsible for getting the dynamic data and sending back to
* : Lightning Component
*/
public class DynamicBindingDemoController {
/*
* @Author : Amit Singh
* @Date : 22nd Feb 2018
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,force:hasSObjectName"
controller='DynamicBindingDemoController'
access="global" >
<!-- call the doInit method to load the list of All the Available Objects into the Org -->
<aura:handler name='init' value='{!this}' action='{!c.doInit}' />
<aura:attribute name='objectList' type='List' />
<aura:attribute name="isSending" type="boolean" />
<c:Spinner />
<div class="slds-m-around_small">
<div class="slds-page-header">
/*
@Author : Amit Singh
@BuiltDate : 21st March 2018
@Description : Handler class that will be created by developer and allowed only one for every object
*/
public class AccountTriggerHandler implements TriggerInterface{
public void BeforeInsert(List<SObject> newItems) {
/* Update the Account name before account inserted into Salesorce */
/*
@Author : Amit Singh
@BuiltDate : 21st March 2018
@Description : Account Trigger that will call the RUN mthos of TriggerDispatcher class
*/
trigger AccountTrigger on Account (before insert, after insert, before update, after update, before delete, after delete, after undelete) {
TriggerDispatcher.run(new AccountTriggerHandler() , 'Account');
}
({
onInit : function(component, event, helper) {
/* Call the Apex class method to fetch the List of all object */
var action = component.get('c.listAllObject');
action.setCallback(this, function(response){
var state = response.getState();
if(state === 'SUCCESS' && component.isValid()){
/* set the value to the attribute of the component */
var responseValue = response.getReturnValue();
var lstOptions = [];
Login_User__c loginUserSetting = Login_User__c.getOrgDefaults();
String Session_Id;
If(loginUserSetting !=null){
Organization orgInfo = [Select Id, Name, isSandbox From Organization LIMIT 1];
String endPoint = '';
If(orgInfo.isSandbox)
endPoint = 'https://test.salesforce.com/services/oauth2/token';
else
endPoint = 'https://login.salesforce.com/services/oauth2/token';
@amitastreait
amitastreait / BookManager_UnitTest
Created August 19, 2018 12:11
How to Test ApexRest
@isTest
public class BookManager_UnitTest {
public static testMethod void unitTest_PostMethod(){
RestRequest request = new RestRequest();
request.requestURI = '/services/apexrest/v1/BookManagement/';
request.httpMethod = 'POST';
request.addHeader('Content-Type', 'application/json');
request.addHeader('Accept', 'application/json');
//request.addHeader('Authorization', 'Bearer '+Userinfo.getSessionId());
public class AllAccounts_MapController {
@AuraEnabled
public static List<Account> getAccList(){
List<Account> accList = new List<Account>();
accList = [Select Id, Name, ShippingStreet, ShippingCity, ShippingState,
ShippingPostalCode, ShippingCountry From Account
Where ShippingStreet!=null AND ShippingCity!= null AND ShippingState != null
AND ShippingPostalCode!= null AND ShippingCountry!=null];
return accList;
}
public class QuickbookConnection{
// Replase with your Client Id
public static String client_Id = 'Q0lUVQVbYhzGMzNuBe2AFc8AiQL82BPOBpIILFlqteae8aTz8H';
// Replase with your Client Secret
public static String consumer_Secret = 'qjhhpmfSuB0Yk5X6aQSXc5r3DgYS9jhOLVcbBsHV';
// Replace with Your Redirect URI
public static String redirect_URI = 'https://dreamhouse-a-dev-ed--c.ap5.visual.force.com/apex/QuickbookConnection';
/*
* @Name - doAuthorizationQuickBooks
.THIS{
background: cadetblue;
}
.THIS.c-container {
border: 1px solid #d8dde6;
margin: 10px 0 20px 0;
}
.THIS .page-section {
border: solid 1px #ccc;