Skip to content

Instantly share code, notes, and snippets.

String Id = '<Your-Device Id>';
String endpoint = '<Your-public webservice URL>';
String littleBitEvent = 'amplitude:delta:ignite';
String accessToken = '<Device AccessToken>';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://api-http.littlebitscloud.cc/subscriptions');
req.setHeader('Authorization','Bearer ' + accessToken);
req.setHeader('Accept', 'application/vnd.littlebits.v2+json');
//Anonymous APEX REST Service that you can subscribe to with LittleBits Cloudbit
@RestResource(urlMapping='/subscriber')
global with sharing class LittleBitsSubscriber
{
@HttpPost
global static String processSubscriptionEvent()
{
String requestBody = RestContext.request.requestBody.toString();
system.debug(requestBody);
Map<String, Object> littleBitsdata = (Map<String, Object>) JSON.deserializeUntyped(requestBody);
<aura:component >
<aura:attribute name="page" type="integer"/>
<aura:attribute name="pages" type="integer"/>
<aura:attribute name="total" type="integer"/>
<ltng:require styles="/resource/SLDS080/assets/styles/salesforce-lightning-design-system-vf.css" />
<div class="slds">
<div class="slds-form-element">
<button class="slds-button slds-button--brand" onclick="{!c.previousPage}" disabled="{!v.page &lt;= 1}">
Previous
<aura:application >
<c:LightningTable object="Account" fields="Id,Name,Phone" pageSize="10" />
</aura:application>
<aura:event type="APPLICATION" description="Event template">
<aura:attribute name="direction" type="String"/>
</aura:event>
({
previousPage : function(component, event, helper) {
var myEvent = $A.get("e.c:PageChange");
myEvent.setParams({ "direction": "previous"});
myEvent.fire();
},
nextPage : function(component, event, helper) {
var myEvent = $A.get("e.c:PageChange");
myEvent.setParams({ "direction": "next"});
myEvent.fire();
({
action.setCallback(this,function(response){
var state = response.getState();
if(state === 'SUCCESS'){
document.getElementById("data").innerHTML ='';
component.set("v.latestRecords",response.getReturnValue());
component.set("v.page",page);
var retResponse = response.getReturnValue();
component.set("v.total",retResponse.total);
component.set("v.pages",Math.ceil(retResponse.total/component.get("v.pageSize")))
component.set("v.latestRecords",response.getReturnValue());
var retRecords = response.getReturnValue();
retRecords.forEach(function(s) {
var tableRow = document.createElement('tr');
fields.forEach(function(field){
var tableData = document.createElement('td');
var tableDataNode = document.createTextNode(s[field]);
tableData.appendChild(tableDataNode);
tableRow.appendChild(tableData);
});
doInit : function(component, event, helper) {
var action = component.get("c.getRecentRecords");
var fields = component.get("v.fields");
action.setParams({
ObjectName : component.get("v.object"),
limits : component.get("v.limit"),
fieldstoget : fields.join()
});
action.setCallback(this,function(response){
// Logic to process the returned value
@karanrajs
karanrajs / RecentRecordsController.html
Created December 6, 2015 04:51
Lightning Component
<aura:component controller="RecentRecordsController" implements="force:appHostable,flexipage:availableForAllPageTypes">
<ltng:require styles="/resource/SLDS080/assets/styles/salesforce-lightning-design-system-vf.css" />
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
</head>
<body>
<div class="slds">
<div class="slds-card__header slds-grid">
<div class="slds-media slds-media--center slds-has-flexi-truncate">
<div class="slds-media__figure">