Slide 1

Slide 1 text

Confidential [email protected] / [email protected] December, 2012 Integration with Salesforce - Access Salesforce data from Ruby

Slide 2

Slide 2 text

2 Confidential Agenda • Who is Splashtop • Personal and Business • Why choose Salesforce • Integration with Salesforce • Accessing data using databasedotcom gem • Lessons Learned • References • Insights 2012/12/8

Slide 3

Slide 3 text

3 Confidential Who is Splashtop 2012/12/8 • Splashtop’s products are top-selling apps on Apple App Store, Google Play, Amazon Appstore for Android and others.

Slide 4

Slide 4 text

4 Confidential Splashtop for Personal 2012/12/8

Slide 5

Slide 5 text

5 Confidential Splashtop for Business - Ideal for All Industries 2012/12/8

Slide 6

Slide 6 text

6 Confidential Why choose Salesforce (1/2) 2012/12/8

Slide 7

Slide 7 text

7 Confidential • CRM, Sales oriented flow automation. • Web to Lead, Outbound messages • Apex , trigger, callout, visualforce… • SOAP, Bulk, Metadata REST API • App Exchange, partners. • Developer documentations. Why Salesforce (2/2) 2012/12/8 Sales Automation John Smith [email protected] Send welcome email to user, send notification to sales, follow up trial processes…

Slide 8

Slide 8 text

8 Confidential Accessing Salesforce data from Ruby • Using databasedotcom gem • Setup Remote Access • Authentication and Go • Lessons Learned • References • Resources • Insights 2012/12/8 Sales Automation John started trial our product!

Slide 9

Slide 9 text

9 Confidential Using databasedotcom gem 2012/12/8 1. Wiki Accessing Salesforce Data from Ruby 1. Register developer account 2. Setup Remote Access 3. Authentication 4. Modules and Name spacing 5. Ready to go client = Databasedotcom::Client.new client.authenticate client.materialize("Lead") a*“start_trial__c"] = "YES" a.save a = Lead.find_by_Email(‘[email protected]') Accessing Data from Ruby (1/5)

Slide 10

Slide 10 text

10 Confidential Setup Remote Access 2012/12/8 Accessing Data from Ruby (2/5) Server side setup Client side setup Consumer = client id = key + token

Slide 11

Slide 11 text

11 Confidential Authentication and Go 2012/12/8 • find_by • find_all_by • field_name__c • save • delete • Lead.query("CreatedDate >= 2012-10-26T00:00:00.000z") Accessing Data from Ruby (3/5) id/secret/ passwd..

Slide 12

Slide 12 text

12 Confidential Lessons - License Type and Quota 2012/12/8 Accessing Data from Ruby (4/5)

Slide 13

Slide 13 text

13 Confidential Lessons - Exception Handling 2012/12/8 TotalRequests Limit exceeded • Increase quota or carefully use Uninitialized constant Lead • Materialize each time before access constant Cannot reference converted lead • Update Contact instead. No such column 'Jigsaw' on entity 'Lead • Avoid BE side fields changes Accessing Data from Ruby (5/5)

Slide 14

Slide 14 text

14 Confidential Reference • Resources • Splashtop (http://www.splashtop.com) • Wiki Accessing Salesforce Data from Ruby (http://wiki.developerforce.com/page/Accessing_Salesforce_Data_From_Ruby) • Integrating with Force.com (youtube, wiki) • Object Reference for Salesforce and Force.com • Databasedotcom (http://rubydoc.info/gems/databasedotcom) • Insights 2012/12/8

Slide 15

Slide 15 text

Confidential Thank You

Slide 16

Slide 16 text

16 Confidential Sobject 2012/12/8 References – Insight (1/4)

Slide 17

Slide 17 text

17 Confidential REST API • @client.materialize("Lead") 2012/12/8 ***** REQUEST: https://ap1.salesforce.com/services/data/v23.0/sobjects/Lead/describe ***** RESPONSE: Net::HTTPOK -> {"name":"Lead","fields": [{"length":18,"name":"Id", "type":"id", "defaultValue":null,"label":"Lead ID",... {"length":0, "name":"IsDeleted","type":"boolean","defaultValue":null,"label":"Deleted",... • contact = Lead.find_by_Email(‘[email protected]') ***** REQUEST: https://ap1.salesforce.com/services/data/v23.0/query?q=SELECT%20Id%2CIsDeleted%2CMasterRecordId%2 ....%20FROM%20Lead%20WHERE%20Email%20%3D%20'demo%40splashtop.com'%20LIMIT%201 ***** RESPONSE: Net::HTTPOK -> {"totalSize":1,"done":true,"records": [{"attributes":{"type":"Lead","url":"/services/data/v23.0/sobjects/Lead/00Q9000000Cd0XXXXX"}, "Id":"00Q9000000Cd0BlEAJ","IsDeleted":false,"MasterRecordId":null,"LastName":"SplashtopDemo",...}]} References – Insight (2/4)

Slide 18

Slide 18 text

18 Confidential Refresh Token - concept 2012/12/8 • Reason • Avoid exposing account password in code. • Revoke anytime without side effects. • How • Concept from Digging Deeper into OAuth 2.0 • Build-Mobile-Apps-in-the-Cloud-with-Omniauth,-Httparty-and-Force.com • Never tried - Introduction to the databasedotcom-oauth2 Gem References – Insight (3/4)

Slide 19

Slide 19 text

19 Confidential Refresh Token - implementation 2012/12/8 From: http://wiki.developerforce.com/images/6/68/OAuthWebServerFlow.png 1. Create an local demo project 2. Gemfile ‘omniauth’ 3. Server side ‘Remote Access’ https://localhost:3000/auth/forcedotcom/callback 4. add /config/initializers/omniauth.rb 5. add /app/controllers/session_controller.rb 6. modify config/routes.rb 7. add lib/configforcedotcom.rb 8. add https 9. patch file (/Library/Ruby/Gems/1.8) ‘~/gems/oa-oauth-0.2.0/lib/omniauth/strategies/oauth2.rb’ # line 66: @access_token = build_access_token puts "access_token: #{@access_token.inspect}" 10. trigger by: https://localhost:3000/auth/forcedotcom References – Insight (4/4)