This file contains 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
const AWS = require('aws-sdk'); | |
const https = require('https'); | |
const DynamoDB = new AWS.DynamoDB(); | |
const SLACK_PROTOCOL = 'https:'; | |
const SLACK_HOST = 'hooks.slack.com'; | |
const SLACK_PATH = '/services/YOUR-SLACK-PATH-HERE'; | |
async function postToSlack(event) { | |
var coffeeType = event.clickType == 'SINGLE' ? 'Regular' : 'Decaf' |
This file contains 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
var AWS = require('aws-sdk'); | |
exports.handler = (event, context, callback) => { | |
var now = new Date(); | |
var startDate = new Date(now.getFullYear(), now.getMonth(), 1); | |
var endDate = new Date(now.getFullYear(), now.getMonth() + 1, 1) | |
if (now.getMonth() == 12) { | |
endDate = new Date(now.getFullYear() + 1, 1, 1) | |
} |
This file contains 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
import UIKit | |
import UserNotifications | |
protocol PushManagerDelegate { | |
func pushManagerUpdated() | |
} | |
class PushManager: NSObject { | |
static let sharedInstance = PushManager() |
This file contains 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
import UIKit | |
import UserNotifications | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { |
This file contains 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
class ContactsViewController: UITableViewController { | |
private var contacts:[SalesforceContact] = [] | |
override func viewDidAppear(animated: Bool) { | |
super.viewDidAppear(animated) | |
reloadContacts() | |
} |
This file contains 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 SalesforceContact { | |
public var id: String? | |
public var firstName: String? | |
public var lastName: String? | |
public var email: String? | |
//Method to initialize with JSON dict returned by the API | |
public init(dictionary: [String : AnyObject]) { | |
This file contains 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
func fetchContacts(completion completion: (contacts: [SalesforceContact], error: NSError?) -> ()) { | |
//TODO: Confirm that user is authenticated | |
let request = SFRestAPI.sharedInstance().requestForQuery("SELECT Id, FirstName, LastName, Email FROM Contact") | |
SFRestAPI.sharedInstance().sendRESTRequest(request, failBlock: { (error) in | |
//Handle the error | |
print("sendRESTRequest error: \(error.localizedDescription)") | |
}) { (response) in | |
//Parse the response | |
print("sendRESTRequest response") |
This file contains 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
func launch() { | |
SalesforceSDKManager.sharedManager().launch() | |
} |
This file contains 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
func setupSDKManager() { | |
let salesforceSDKManager = SalesforceSDKManager.sharedManager() | |
salesforceSDKManager.connectedAppId = self.consumerKey | |
salesforceSDKManager.connectedAppCallbackUri = self.redirectUrl | |
salesforceSDKManager.authScopes = ["web", "api"] | |
//Post launch action handler | |
salesforceSDKManager.postLaunchAction = { launchActionList in | |
let launchActionString = SalesforceSDKManager.launchActionsStringRepresentation(launchActionList) |
This file contains 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
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
override init() { | |
super.init() | |
//Setup the SalesforceManager | |
SalesforceManager.sharedInstance.setupSDKManager() |
NewerOlder