Integrating QuickBase With Web Services - Gareth Lewis

9
Integrating QuickBase with Web Services Gareth Lewis, QuickBase User & Author of the QuickBase API Cookbook

description

f you have to use the QuickBase API outside the browser, one option is to access it via Ruby. Ruby is simple, flexible, powerful, easy to install and learn - and the Ruby SDK for QuickBase makes using the API straightforward. Through a series of concrete examples, we'll look at some SDK basics then go onto email, RSS, Twitter, web servers and other topics.

Transcript of Integrating QuickBase With Web Services - Gareth Lewis

Page 1: Integrating QuickBase With Web Services - Gareth Lewis

Integrating QuickBase with Web ServicesGareth Lewis, QuickBase User & Author of the QuickBase API Cookbook

Page 2: Integrating QuickBase With Web Services - Gareth Lewis

2

1. You have a problem that can't be solved in the browser with QuickBase or Javascript.

2. You have to use the QuickBase API.

3. You want a simple language that just does what it's told and is friendly to work with.

4. You don't want to write a bunch of code just to get basic things accomplished.

5. If you don't like how the Ruby SDK does something, change the source code.

Why use the Ruby SDK for QuickBase?

Wrote Ruby SDK for QuickBase in 2005 to solve for project progress charting needs

Page 3: Integrating QuickBase With Web Services - Gareth Lewis

3

The SDK works with Ruby version 1.8.6 or higher.

It works with JRuby but not with IronRuby, yet.

Get Ruby: 1-Click installer for Windows: http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe

Get Ruby: Other O.S.: http://rubyforge.org/frs/?group_id=426&release_id=27644

Get JRuby: http://jruby.org/download

Get the SDK from code.intuit.com

QuickBase API CookBook: https://www.quickbase.com/db/bcdcajmrf

Get Ruby and the SDK

Page 4: Integrating QuickBase With Web Services - Gareth Lewis

4

Put Ruby code in a file with a .rb extension (e.g. authenticate.rb), and run it by typing ruby authenticate.rb

authenticate.rb: require 'QuickBaseClient' qbc = QuickBase::Client.new("username","password") qbc2 = QuickBase::Client.new; qbc2.authenticate("username","password")

addRecord.rb: require 'QuickBaseClient' qbc = QuickBase::Client.new("username","password") recordId, update_id = qbc.addRecord("bcdcajmrf",{"Name" => "Fred"})

editRecord.rb: require 'QuickBaseClient‘qbc = QuickBase::Client.new("username","password") qbc.editRecord("bcdcajmrf","1",{"Name" => "Fred"})

doQuery.rb: require 'QuickBaseClient' QuickBase::Client.new("username","password").doQuery("bcdcajmrg") { |record_xml| print record_xml}

signOut.rb: require 'QuickBaseClient' qbc = QuickBase::Client.new("username","password") qbc.signOut

Ruby SDK Basics

Page 5: Integrating QuickBase With Web Services - Gareth Lewis

Twitter/ QuickBase Integratio

n

Generate RSS feed

Send to email in

html format

Start Ruby

Script via Web page

Ruby on Smart Phones

5

Integration and Automation with Ruby

Other examples using Ruby: • Ruby Scripts as Windows .EXE files

• Search for records from a command-line

• QuickBase + 'desktop' applications

• Watir (Web application testing in Ruby) - Browser automation using Ruby

• Rails Integration

(Link to complete examples)

Page 6: Integrating QuickBase With Web Services - Gareth Lewis

require 'QuickBaseTwitterConnector' # Installed with SDKQuickBase::TwitterConnector.new # Starts an interactive session

 

 Please enter the Quickbase username to use for this session: [email protected] enter the Quickbase password to use for this session: wilmaPlease enter the Twitter username to use for this session: fred_flintstonePlease enter the Twitter password to use for this session: wilma Please enter a number to select the connection type: 1 - Send Twitter messages to QuickBase.2 - Send QuickBase messages to Twitter.3 - Exchange messages between QuickBase and Twitter.4 - Send automated replies from QuickBase to Twitter.5 - All the above. 5 Getting 'friends' Twitter Status since Fri, 28 Mar 2008 13:47:24 -0700.Getting Direct Messages from Twitter since Fri, 28 Mar 2008 13:47:24 -0700.Sending messages from QuickBase to Twitter added since Fri, 28 Mar 2008 13:47:24 -0700.Getting Direct Messages from Twitter since Fri, 28 Mar 2008 13:47:24 -0700.Automated Direct Message sent to wilma_flintstone: what's for dinner?: rex ribs 6

Twitter Connector : background process polls QuickBase and

Twitter for new records and tweets, sends data in both directions.

Page 7: Integrating QuickBase With Web Services - Gareth Lewis

7

Send HTML Email require 'QuickBaseEmailer‘

def send_email( subject, message, bccRecipients )

emailBody = "Content-Type: text/html;\n\n" emailBody << "<HTML><BODY>" emailBody << message emailBody << "</BODY></HTML>"

qbe = QuickBase::Emailer.new( "[email protected]", "wilma" )

qbe.sendBccEmail( "[email protected]", # from ["[email protected]", "[email protected]"], # to bccRecipients, # BCC subject, emailBody, "mail.bedrock.com", # SMTP email server 25, # SMTP email port nil ) end

qbc = QuickBase::Client.new( "[email protected]", "wilma" )

loop { qbc.iterateRecords( "bdcvpsxpy", [ "Record ID#", "subject", "message", "bccRecipients" ], nil, nil, "Pending Emails Report" ) { |record |

send_email( record["subject"], record["message"], record["bccRecipients"].split(/,/) )

qbc.editRecord( "bdcvpsxpy", record["Record ID#"], { "sent" => "1" } ) # Exclude from Pending Emails Report } sleep( 5 ) # wait 5 minutes then check for more emails }

Usage Case Scenario:

Professional services tech team automates customer requests

- Customer calls in a request

- Employee enters request into QuickBase

- Then calls/emails team to find a technician for the job

- Now the process is entirely automated with the email script

Saves 15 minutes per case…

Page 8: Integrating QuickBase With Web Services - Gareth Lewis

8

One RSS feed for multiple tables

require 'QuickBaseRSSGenerator'

qbc = QuickBase::Client.new( "username", "password" )

qbRSSgen = QuickBase::RSSGenerator.new( qbc )

qbRSSgen.setTitle( "QuickBase Forum/KnowledgeBase RSS" )

qbRSSgen.setLink( "main" )

qbRSSgen.setDescription( "RSS view of QuickBase Community Forum and KnowledgeBase" )

qbRSSgen.addTable("8emtadvk", "Community Forum", { "title" => "6", "description" => "10" }, # Field IDs nil, nil, "List Changes", 75 ) # 75 records

qbRSSgen.addTable( "6mztyxu8", "KnowledgeBase", { "title" => "5", "description" => "6" }, "{'6'.CT.'API'}", # API KnowledgeBase entries nil, nil, 50 ) # 50 records

rssText = qbRSSgen.generateRSStext

File.open( "QuickBaseInfoRSS.xml", "w" ) { |file| file.write( rssText ) } # upload to QuickBase ?!

Page 9: Integrating QuickBase With Web Services - Gareth Lewis

9

SummaryQuickBase is great

There are a some things that can only be done outside the browser, via the API

Ruby is not the answer to Life, the Universe and Everything

Ruby will not waste your time

Ruby is a very pleasant language with tons of excellent libraries

The Ruby SDK aims to help you get QuickBase API work done quickly, even if you've never used Ruby

The examples in this presentation show some of what can be done, and how to do it

See you in the QuickBase Innovation Network !