ipp_quickbase_devkit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +87 -0
- data/README.rdoc +112 -0
- data/doc/QuickBaseClient.rb.htm +1896 -0
- data/doc/ReleaseNotes.txt +43 -0
- data/doc/qbc.makeCSVFile.qbc +4 -0
- data/doc/qbc.makeCSVFile.rb +4 -0
- data/doc/quickbase_adapter.rb.htm +399 -0
- data/examples/cookbookfiles/QuickBaseAPICookbook.html +2590 -0
- data/examples/cookbookfiles/addChangeRemoveUserRole.rb +21 -0
- data/examples/cookbookfiles/addOrEditRecord.rb +10 -0
- data/examples/cookbookfiles/application_object.rb +55 -0
- data/examples/cookbookfiles/applyRubyFormulas.rb +10 -0
- data/examples/cookbookfiles/average.rb +27 -0
- data/examples/cookbookfiles/backupApplication.rb +8 -0
- data/examples/cookbookfiles/cacheSchemas.rb +53 -0
- data/examples/cookbookfiles/calculateRunningTotals.rb +11 -0
- data/examples/cookbookfiles/copyrecords.rb +73 -0
- data/examples/cookbookfiles/count.rb +26 -0
- data/examples/cookbookfiles/createRecordNavigatorHTML.rb +42 -0
- data/examples/cookbookfiles/createReportDashboard.rb +35 -0
- data/examples/cookbookfiles/createTable.rb +12 -0
- data/examples/cookbookfiles/deviation.rb +25 -0
- data/examples/cookbookfiles/downloadCookbook.rb +97 -0
- data/examples/cookbookfiles/downloadFile.rb +10 -0
- data/examples/cookbookfiles/downloadFilesToFolder.rb +81 -0
- data/examples/cookbookfiles/downloadToTextFile.rb +64 -0
- data/examples/cookbookfiles/dumpSchema.rb +11 -0
- data/examples/cookbookfiles/duplicateRecord.rb +8 -0
- data/examples/cookbookfiles/dynamicMethods.rb +33 -0
- data/examples/cookbookfiles/editRecords.rb +15 -0
- data/examples/cookbookfiles/findJohnsLast10Records.rb +17 -0
- data/examples/cookbookfiles/findRubyRecords.rb +17 -0
- data/examples/cookbookfiles/formatCurrency.rb +24 -0
- data/examples/cookbookfiles/formatDate.rb +10 -0
- data/examples/cookbookfiles/formatDuration.rb +27 -0
- data/examples/cookbookfiles/formatPercent.rb +24 -0
- data/examples/cookbookfiles/getAllValuesForFields.rb +18 -0
- data/examples/cookbookfiles/getAppDTMInfo.rb +29 -0
- data/examples/cookbookfiles/getApplicationVariable.rb +5 -0
- data/examples/cookbookfiles/getChildTableDBID.rb +11 -0
- data/examples/cookbookfiles/getColumnListForReport.rb +6 -0
- data/examples/cookbookfiles/getFieldChoices.rb +13 -0
- data/examples/cookbookfiles/getFieldIDs.rb +6 -0
- data/examples/cookbookfiles/getFieldNames.rb +6 -0
- data/examples/cookbookfiles/getLastModTime.rb +8 -0
- data/examples/cookbookfiles/getLastRecModTime.rb +8 -0
- data/examples/cookbookfiles/getNumRecords.rb +8 -0
- data/examples/cookbookfiles/getNumTables.rb +4 -0
- data/examples/cookbookfiles/getRecord.rb +5 -0
- data/examples/cookbookfiles/getRecordDisplayURL.rb +13 -0
- data/examples/cookbookfiles/getRecordsAddedToday.rb +20 -0
- data/examples/cookbookfiles/getRecordsAsJSON.rb +6 -0
- data/examples/cookbookfiles/getReportNames.rb +25 -0
- data/examples/cookbookfiles/getRoleInfo.rb +48 -0
- data/examples/cookbookfiles/getServerStatus.rb +11 -0
- data/examples/cookbookfiles/getSortListForReport.rb +6 -0
- data/examples/cookbookfiles/getTableIDs.rb +6 -0
- data/examples/cookbookfiles/getTableName.rb +8 -0
- data/examples/cookbookfiles/getTableNames.rb +25 -0
- data/examples/cookbookfiles/getTimeCreated.rb +8 -0
- data/examples/cookbookfiles/getTimeInMilliseconds.rb +5 -0
- data/examples/cookbookfiles/getUserInfo.rb +26 -0
- data/examples/cookbookfiles/getUserRole.rb +15 -0
- data/examples/cookbookfiles/intranet.rb +101 -0
- data/examples/cookbookfiles/isAverageField.rb +17 -0
- data/examples/cookbookfiles/isDbidString.rb +8 -0
- data/examples/cookbookfiles/isTotalField.rb +16 -0
- data/examples/cookbookfiles/iterateDBPages.rb +8 -0
- data/examples/cookbookfiles/iterateFilteredRecords.rb +12 -0
- data/examples/cookbookfiles/iterateJoinRecords.rb +68 -0
- data/examples/cookbookfiles/iterateRecordInfos.rb +8 -0
- data/examples/cookbookfiles/iterateRecords.rb +23 -0
- data/examples/cookbookfiles/iterateSummaryRecords.rb +13 -0
- data/examples/cookbookfiles/iterateUnionRecords.rb +38 -0
- data/examples/cookbookfiles/listAccessibleApplications.rb +6 -0
- data/examples/cookbookfiles/logRequestAndResponseXML.rb +8 -0
- data/examples/cookbookfiles/lookupFieldPropertyByName.rb +62 -0
- data/examples/cookbookfiles/lookupFieldTypeByName.rb +10 -0
- data/examples/cookbookfiles/makeCSVFile.rb +4 -0
- data/examples/cookbookfiles/makeSlideShow.rb +42 -0
- data/examples/cookbookfiles/makerecs.rb +64 -0
- data/examples/cookbookfiles/max.rb +26 -0
- data/examples/cookbookfiles/min.rb +26 -0
- data/examples/cookbookfiles/percent.rb +29 -0
- data/examples/cookbookfiles/printChildElements.rb +54 -0
- data/examples/cookbookfiles/printNewRecords.rb +12 -0
- data/examples/cookbookfiles/processRESTRequest.rb +21 -0
- data/examples/cookbookfiles/provisionAndInviteNewUser.rb +13 -0
- data/examples/cookbookfiles/purgeRecords.rb +15 -0
- data/examples/cookbookfiles/quickbase_adapter.rb.htm +397 -0
- data/examples/cookbookfiles/quickbase_record_finder.zip +0 -0
- data/examples/cookbookfiles/recordAndFieldIterator.rb +24 -0
- data/examples/cookbookfiles/runImport.rb +9 -0
- data/examples/cookbookfiles/runQuickBaseTwitterConnector.rb +41 -0
- data/examples/cookbookfiles/sendToQuickBase.rb +33 -0
- data/examples/cookbookfiles/setDBvar.rb +6 -0
- data/examples/cookbookfiles/showRequestAndResponseXML.rb +8 -0
- data/examples/cookbookfiles/sqlQuery.rb +11 -0
- data/examples/cookbookfiles/stopOnError.rb +10 -0
- data/examples/cookbookfiles/sum.rb +26 -0
- data/examples/cookbookfiles/twitterFromQuickBase.rb +42 -0
- data/examples/cookbookfiles/twitterWithQuickBase.rb +36 -0
- data/examples/cookbookfiles/uploadCSVData.rb +20 -0
- data/examples/cookbookfiles/uploadExcelData.rb +22 -0
- data/examples/cookbookfiles/uploadFileEveryHour.rb +18 -0
- data/examples/cookbookfiles/uploadFileIntoNewRecord.rb +8 -0
- data/examples/cookbookfiles/uploadFilesFromFolder.exe +0 -0
- data/examples/cookbookfiles/uploadFilesFromFolder.rb +69 -0
- data/examples/cookbookfiles/useCompanyURL.rb +12 -0
- data/examples/cookbookfiles/userRoles.rb +49 -0
- data/examples/cookbookfiles/watchCommunityForum.rb +5 -0
- data/examples/cookbookfiles/wikifyTable.rb +29 -0
- data/examples/cookbookfiles/xmlShortcuts.rb +33 -0
- data/examples/pmp/app/controllers/application.rb +7 -0
- data/examples/pmp/app/controllers/contacts_controller.rb +8 -0
- data/examples/pmp/app/controllers/document_library_controller.rb +2 -0
- data/examples/pmp/app/controllers/issues_controller.rb +5 -0
- data/examples/pmp/app/controllers/projects_controller.rb +22 -0
- data/examples/pmp/app/controllers/resources_controller.rb +2 -0
- data/examples/pmp/app/controllers/tasks_controller.rb +13 -0
- data/examples/pmp/app/controllers/time_cards_controller.rb +5 -0
- data/examples/pmp/app/helpers/application_helper.rb +3 -0
- data/examples/pmp/app/helpers/contacts_helper.rb +2 -0
- data/examples/pmp/app/helpers/document_library_helper.rb +2 -0
- data/examples/pmp/app/helpers/issues_helper.rb +2 -0
- data/examples/pmp/app/helpers/projects_helper.rb +2 -0
- data/examples/pmp/app/helpers/resources_helper.rb +2 -0
- data/examples/pmp/app/helpers/tasks_helper.rb +2 -0
- data/examples/pmp/app/helpers/time_cards_helper.rb +2 -0
- data/examples/pmp/app/models/contacts.rb +26 -0
- data/examples/pmp/app/models/document_library.rb +2 -0
- data/examples/pmp/app/models/issues.rb +6 -0
- data/examples/pmp/app/models/projects.rb +26 -0
- data/examples/pmp/app/models/resources.rb +2 -0
- data/examples/pmp/app/models/tasks.rb +12 -0
- data/examples/pmp/app/models/time_cards.rb +7 -0
- data/examples/pmp/app/schemas/contacts.xml +1 -0
- data/examples/pmp/app/schemas/document_library.xml +1 -0
- data/examples/pmp/app/schemas/issues.xml +1 -0
- data/examples/pmp/app/schemas/pmp.xml +1 -0
- data/examples/pmp/app/schemas/projects.xml +1 -0
- data/examples/pmp/app/schemas/readme.txt +8 -0
- data/examples/pmp/app/schemas/resources.xml +1 -0
- data/examples/pmp/app/schemas/tasks.xml +1 -0
- data/examples/pmp/app/schemas/time_cards.xml +1 -0
- data/examples/pmp/app/views/contacts/companies.rhtml +31 -0
- data/examples/pmp/app/views/contacts/project_contacts.rhtml +31 -0
- data/examples/pmp/app/views/issues/filter_issues.rhtml +26 -0
- data/examples/pmp/app/views/layouts/application.rhtml +56 -0
- data/examples/pmp/app/views/projects/all_projects.rhtml +33 -0
- data/examples/pmp/app/views/projects/home.rhtml +11 -0
- data/examples/pmp/app/views/projects/my_open_projects.rhtml +27 -0
- data/examples/pmp/app/views/projects/open_projects.rhtml +44 -0
- data/examples/pmp/app/views/projects/project_sorted_by_company.rhtml +40 -0
- data/examples/pmp/app/views/projects/projects_sorted_by_priority.rhtml +30 -0
- data/examples/pmp/app/views/projects/updated_projects.rhtml +0 -0
- data/examples/pmp/app/views/tasks/all_tasks.rhtml +27 -0
- data/examples/pmp/app/views/tasks/search.rhtml +23 -0
- data/examples/pmp/app/views/tasks/search2.rhtml +23 -0
- data/examples/pmp/app/views/tasks/search3.rhtml +23 -0
- data/examples/pmp/app/views/time_cards/summary.rhtml +38 -0
- data/examples/pmp/config/boot.rb +45 -0
- data/examples/pmp/config/database.yml +30 -0
- data/examples/pmp/config/environment.rb +60 -0
- data/examples/pmp/config/environments/development.rb +21 -0
- data/examples/pmp/config/environments/production.rb +18 -0
- data/examples/pmp/config/environments/test.rb +19 -0
- data/examples/pmp/config/routes.rb +23 -0
- data/examples/pmp/db/migrate/001_create_projects.rb +10 -0
- data/examples/pmp/db/migrate/002_create_tasks.rb +10 -0
- data/examples/pmp/db/migrate/003_create_issues.rb +10 -0
- data/examples/pmp/db/migrate/004_create_document_libraries.rb +10 -0
- data/examples/pmp/db/migrate/005_create_resources.rb +10 -0
- data/examples/pmp/db/migrate/006_create_time_cards.rb +10 -0
- data/examples/pmp/db/migrate/007_create_contacts.rb +10 -0
- data/examples/pmp/public/404.html +30 -0
- data/examples/pmp/public/500.html +30 -0
- data/examples/pmp/public/app.index.html +277 -0
- data/examples/pmp/public/dispatch.cgi +10 -0
- data/examples/pmp/public/dispatch.fcgi +24 -0
- data/examples/pmp/public/dispatch.rb +10 -0
- data/examples/pmp/public/favicon.ico +0 -0
- data/examples/pmp/public/images/rails.png +0 -0
- data/examples/pmp/public/javascripts/application.js +2 -0
- data/examples/pmp/public/javascripts/controls.js +833 -0
- data/examples/pmp/public/javascripts/dragdrop.js +942 -0
- data/examples/pmp/public/javascripts/effects.js +1088 -0
- data/examples/pmp/public/javascripts/prototype.js +2515 -0
- data/examples/pmp/public/robots.txt +1 -0
- data/examples/pmp/test/fixtures/contacts.yml +5 -0
- data/examples/pmp/test/fixtures/document_libraries.yml +5 -0
- data/examples/pmp/test/fixtures/issues.yml +5 -0
- data/examples/pmp/test/fixtures/projects.yml +5 -0
- data/examples/pmp/test/fixtures/resources.yml +5 -0
- data/examples/pmp/test/fixtures/tasks.yml +5 -0
- data/examples/pmp/test/fixtures/time_cards.yml +5 -0
- data/examples/pmp/test/functional/contacts_controller_test.rb +18 -0
- data/examples/pmp/test/functional/document_library_controller_test.rb +18 -0
- data/examples/pmp/test/functional/issues_controller_test.rb +18 -0
- data/examples/pmp/test/functional/projects_controller_test.rb +18 -0
- data/examples/pmp/test/functional/resources_controller_test.rb +18 -0
- data/examples/pmp/test/functional/tasks_controller_test.rb +18 -0
- data/examples/pmp/test/functional/time_cards_controller_test.rb +18 -0
- data/examples/pmp/test/test_helper.rb +28 -0
- data/examples/pmp/test/unit/contacts_test.rb +10 -0
- data/examples/pmp/test/unit/document_library_test.rb +10 -0
- data/examples/pmp/test/unit/issues_test.rb +10 -0
- data/examples/pmp/test/unit/projects_test.rb +10 -0
- data/examples/pmp/test/unit/resources_test.rb +10 -0
- data/examples/pmp/test/unit/tasks_test.rb +10 -0
- data/examples/pmp/test/unit/time_cards_test.rb +10 -0
- data/lib/QuickBaseClient.rb +5054 -0
- data/lib/QuickBaseCommandLineClient.rb +401 -0
- data/lib/QuickBaseContactsAppBuilder.rb +419 -0
- data/lib/QuickBaseEmailer.rb +334 -0
- data/lib/QuickBaseEventNotifier.rb +592 -0
- data/lib/QuickBaseMisc.rb +96 -0
- data/lib/QuickBaseObjects.rb +566 -0
- data/lib/QuickBaseRSSGenerator.rb +286 -0
- data/lib/QuickBaseTextData.rb +545 -0
- data/lib/QuickBaseTwitterConnector.rb +300 -0
- data/lib/QuickBaseWebClient.rb +126 -0
- data/lib/WorkPlaceClient.rb +45 -0
- data/lib/qbc.makeCSVFile.qbc +4 -0
- data/lib/qbc.makeCSVFile.rb +17 -0
- data/lib/quickbase_adapter.rb +320 -0
- data/lib/runFieldEntryDialog.rb +151 -0
- data/lib/runOfflineFieldEntryDialog.rb +203 -0
- data/rakefile +100 -0
- data/test/run_tests.bat +7 -0
- data/test/spec_all_tests.rb +13 -0
- data/test/spec_smoke_tests.rb +58 -0
- data/test/spec_workplace_addrecord_test.rb +46 -0
- data/test/spec_workplace_base_test.rb +57 -0
- data/test/spec_workplace_editrecord_test.rb +38 -0
- data/test/spec_workplace_json_test.rb +38 -0
- data/test/spec_workplace_objects_test.rb +39 -0
- data/test/spec_workplace_smoke_tests.rb +45 -0
- metadata +353 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
#--#####################################################################
|
|
2
|
+
# Copyright (c) 2009 Gareth Lewis and Intuit, Inc.
|
|
3
|
+
#
|
|
4
|
+
# All rights reserved. This program and the accompanying materials
|
|
5
|
+
# are made available under the terms of the Eclipse Public License v1.0
|
|
6
|
+
# which accompanies this distribution, and is available at
|
|
7
|
+
# http://www.opensource.org/licenses/eclipse-1.0.php
|
|
8
|
+
#
|
|
9
|
+
# Contributors:
|
|
10
|
+
# Gareth Lewis - Initial contribution.
|
|
11
|
+
# Intuit Partner Platform.
|
|
12
|
+
#++#####################################################################
|
|
13
|
+
|
|
14
|
+
require 'rubygems'
|
|
15
|
+
gem 'twitter4r', '>=0.3.0'
|
|
16
|
+
require 'twitter'
|
|
17
|
+
|
|
18
|
+
require 'QuickBaseClient'
|
|
19
|
+
|
|
20
|
+
module QuickBase
|
|
21
|
+
|
|
22
|
+
class TwitterConnector
|
|
23
|
+
|
|
24
|
+
#----------------------------------------------------------------
|
|
25
|
+
def initialize(options = {:get_friends_twitter_status => true,:get_direct_messages => true})
|
|
26
|
+
@options = options
|
|
27
|
+
[quickbase_username,quickbase_password,twitter_username,twitter_password].each{|option|
|
|
28
|
+
@options[option] ||= get_input(option)
|
|
29
|
+
}
|
|
30
|
+
get_connection_type
|
|
31
|
+
find_or_create_twitter_databases if get_quickbase_client
|
|
32
|
+
run if get_twitter_client
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
#----------------------------------------------------------------
|
|
38
|
+
def get_input(string)
|
|
39
|
+
ret = ""
|
|
40
|
+
while ret.length == 0
|
|
41
|
+
print "Please enter the #{string} to use for this session: "
|
|
42
|
+
ret = gets.chop
|
|
43
|
+
end
|
|
44
|
+
ret
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
#----------------------------------------------------------------
|
|
48
|
+
def get_quickbase_client
|
|
49
|
+
begin
|
|
50
|
+
@qbc = QuickBase::Client.new(@options[quickbase_username],@options[quickbase_password])
|
|
51
|
+
#@qbc.printRequestsAndResponses=true
|
|
52
|
+
rescue StandardError => error
|
|
53
|
+
puts "Error accessing QuickBase. Please check your username and password. (#{error})"
|
|
54
|
+
@qbc= nil
|
|
55
|
+
end
|
|
56
|
+
@qbc
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#----------------------------------------------------------------
|
|
60
|
+
def get_twitter_client
|
|
61
|
+
begin
|
|
62
|
+
@tc = Twitter::Client.new(:login => @options[twitter_username],:password => @options[twitter_password])
|
|
63
|
+
rescue StandardError => error
|
|
64
|
+
puts "Error accessing Twitter. Please check your username and password. (#{error})"
|
|
65
|
+
@tc= nil
|
|
66
|
+
end
|
|
67
|
+
@tc
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#----------------------------------------------------------------
|
|
71
|
+
def get_connection_type
|
|
72
|
+
puts "\n\nPlease enter a number to select the connection type:\n\n"
|
|
73
|
+
puts "1 - Send Twitter messages to QuickBase."
|
|
74
|
+
puts "2 - Send QuickBase messages to Twitter."
|
|
75
|
+
puts "3 - Exchange messages between QuickBase and Twitter."
|
|
76
|
+
puts "4 - Send automated replies from QuickBase to Twitter."
|
|
77
|
+
puts "5 - All the above.\n\n"
|
|
78
|
+
@options[connection_type] = ""
|
|
79
|
+
while !["1","2","3","4","5"].include?(@options[connection_type])
|
|
80
|
+
@options[connection_type] = gets.chop
|
|
81
|
+
end
|
|
82
|
+
puts "\n\n"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#----------------------------------------------------------------
|
|
86
|
+
def find_or_create_twitter_databases
|
|
87
|
+
message_database = "Twitter messages: #{@options[quickbase_username]} - #{@options[twitter_username]}"
|
|
88
|
+
@messages_dbid = @qbc.findDBByName(message_database)
|
|
89
|
+
if @messages_dbid.nil?
|
|
90
|
+
begin
|
|
91
|
+
@messages_dbid = @qbc.createDatabase(message_database, "Messages exchanged between QuickBase (#{@options['QuickBase username']}) and Twitter (#{@options['Twitter username']})." )
|
|
92
|
+
@qbc.addField(@messages_dbid, message_type, "text")
|
|
93
|
+
@qbc.addField(@messages_dbid, twitter_username, "text")
|
|
94
|
+
@qbc.addField(@messages_dbid, received_from_twitter, "text")
|
|
95
|
+
@qbc.addField(@messages_dbid, keyword, "text")
|
|
96
|
+
@qbc.addField(@messages_dbid, send_to_twitter, "text")
|
|
97
|
+
@qbc.addField(@messages_dbid, sent_to_twitter, "checkbox")
|
|
98
|
+
rescue StandardError => error
|
|
99
|
+
puts "Error creating Twitter messages database in QuickBase. (#{error})"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
@qbc.getSchema(@messages_dbid)
|
|
103
|
+
@messages_dbid = @qbc.lookupChdbid(message_database)
|
|
104
|
+
@qbc.getSchema(@messages_dbid)
|
|
105
|
+
@fieldIDs = {}
|
|
106
|
+
@qbc.getFieldNames.each{|name|@fieldIDs[name]=@qbc.lookupFieldIDByName(name)}
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
#----------------------------------------------------------------
|
|
110
|
+
def run
|
|
111
|
+
@lastCheckTime = (Time.now-60)
|
|
112
|
+
loop {
|
|
113
|
+
nextCheckTime = Time.now
|
|
114
|
+
if ["1","3","5"].include?(@options[connection_type])
|
|
115
|
+
if @options[:get_my_twitter_status]
|
|
116
|
+
get_my_twitter_status
|
|
117
|
+
sleep(60)
|
|
118
|
+
end
|
|
119
|
+
if @options[:get_friends_twitter_status]
|
|
120
|
+
get_friends_twitter_status
|
|
121
|
+
sleep(60)
|
|
122
|
+
end
|
|
123
|
+
if @options[:get_direct_messages]
|
|
124
|
+
get_direct_messages
|
|
125
|
+
sleep(60)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
if ["2","3","5"].include?(@options[connection_type])
|
|
129
|
+
send_messages_to_twitter
|
|
130
|
+
sleep(60)
|
|
131
|
+
end
|
|
132
|
+
if ["4","5"].include?(@options[connection_type])
|
|
133
|
+
get_direct_messages
|
|
134
|
+
sleep(60)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
@lastCheckTime = nextCheckTime
|
|
138
|
+
}
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
#----------------------------------------------------------------
|
|
142
|
+
def get_my_twitter_status
|
|
143
|
+
get_twitter_status(:me)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
#----------------------------------------------------------------
|
|
147
|
+
def get_friends_twitter_status
|
|
148
|
+
get_twitter_status(:friends)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
#----------------------------------------------------------------
|
|
152
|
+
def get_public_twitter_status
|
|
153
|
+
get_twitter_status(:public)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
#----------------------------------------------------------------
|
|
157
|
+
def get_twitter_status(who,twitter_options = {})
|
|
158
|
+
twitter_options["since"] ||= @lastCheckTime
|
|
159
|
+
puts "Getting '#{who}' Twitter Status since #{twitter_options["since"]}."
|
|
160
|
+
begin
|
|
161
|
+
@tc.timeline_for(who,twitter_options) {|status|
|
|
162
|
+
@qbc.clearFieldValuePairList
|
|
163
|
+
@qbc.addFieldValuePair(twitter_username,nil,nil,status.user.screen_name)
|
|
164
|
+
@qbc.addFieldValuePair(received_from_twitter,nil,nil,status.text)
|
|
165
|
+
@qbc.addFieldValuePair(message_type,nil,nil,"status")
|
|
166
|
+
@qbc.addRecord(@messages_dbid,@qbc.fvlist)
|
|
167
|
+
puts "Twitter status added to QuickBase: #{status.user.screen_name}: #{status.text}"
|
|
168
|
+
}
|
|
169
|
+
rescue Twitter::RESTError => error
|
|
170
|
+
#puts "Twitter exception handling timeline_for request: #{error}"
|
|
171
|
+
rescue StandardError => error
|
|
172
|
+
puts "Exception handling timeline_for request: #{error}"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
#----------------------------------------------------------------
|
|
177
|
+
def get_direct_messages(twitter_options = {})
|
|
178
|
+
twitter_options["since"] ||= @lastCheckTime
|
|
179
|
+
puts "Getting Direct Messages from Twitter since #{twitter_options["since"]}."
|
|
180
|
+
begin
|
|
181
|
+
received_messages = @tc.messages(:received,twitter_options)
|
|
182
|
+
if received_messages
|
|
183
|
+
received_messages.each{|message|
|
|
184
|
+
if message.created_at > @lastCheckTime
|
|
185
|
+
sentAutomatedReply = false
|
|
186
|
+
if ["4","5"].include?(@options[connection_type])
|
|
187
|
+
if message.text[-1,1] == ':'
|
|
188
|
+
sentAutomatedReply = sendAutomatedReplyFromQuickBase(message.text,message.sender.screen_name)
|
|
189
|
+
else
|
|
190
|
+
sentAutomatedReply = processRESTRequest(message.text,message.sender.screen_name)
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
if !sentAutomatedReply
|
|
194
|
+
@qbc.clearFieldValuePairList
|
|
195
|
+
@qbc.addFieldValuePair(twitter_username,nil,nil,message.sender.screen_name)
|
|
196
|
+
@qbc.addFieldValuePair(received_from_twitter,nil,nil,message.text)
|
|
197
|
+
@qbc.addFieldValuePair(message_type,nil,nil,"message")
|
|
198
|
+
@qbc.addRecord(@messages_dbid,@qbc.fvlist)
|
|
199
|
+
puts "Twitter Direct Message added to QuickBase: #{message.sender.screen_name}: #{message.text}"
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
}
|
|
203
|
+
end
|
|
204
|
+
rescue Twitter::RESTError => error
|
|
205
|
+
puts "Twitter exception handling Twitter::Client.messages request: #{error}"
|
|
206
|
+
rescue StandardError => error
|
|
207
|
+
puts "Exception handling Twitter::Client.messages request: #{error}"
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
#----------------------------------------------------------------
|
|
212
|
+
def send_messages_to_twitter
|
|
213
|
+
timeToCompare = Misc.time_in_milliseconds(@lastCheckTime)
|
|
214
|
+
puts "Sending messages from QuickBase to Twitter added since #{@lastCheckTime}."
|
|
215
|
+
@qbc.iterateRecords(@messages_dbid,[date_created,record_ID,send_to_twitter,twitter_username],"{'1'.OAF.'today'}AND{'#{@fieldIDs[send_to_twitter]}'.XEX.''}AND{'#{@fieldIDs[sent_to_twitter]}'.XEX.'1'}"){|new_quickbase_record|
|
|
216
|
+
if new_quickbase_record[date_created].to_i > timeToCompare
|
|
217
|
+
begin
|
|
218
|
+
msgType = ""
|
|
219
|
+
recipient = ""
|
|
220
|
+
if new_quickbase_record[twitter_username]
|
|
221
|
+
msgType = "Direct Message"
|
|
222
|
+
recipient = new_quickbase_record[twitter_username].dup
|
|
223
|
+
Twitter::Message.create(:text => new_quickbase_record[send_to_twitter].dup,:recipient => new_quickbase_record[twitter_username].dup,:client => @tc)
|
|
224
|
+
else
|
|
225
|
+
msgType = "Status"
|
|
226
|
+
Twitter::Status.create(:text => new_quickbase_record[send_to_twitter].dup,:client => @tc)
|
|
227
|
+
end
|
|
228
|
+
@qbc.clearFieldValuePairList
|
|
229
|
+
@qbc.addFieldValuePair(sent_to_twitter,nil,nil,"1")
|
|
230
|
+
@qbc.editRecord(@messages_dbid,new_quickbase_record[record_ID],@qbc.fvlist)
|
|
231
|
+
puts "#{msgType} sent from QuickBase to Twitter: #{recipient} #{new_quickbase_record[send_to_twitter].dup}"
|
|
232
|
+
rescue Twitter::RESTError => error
|
|
233
|
+
puts "Twitter exception handling #{msgType}.create request: #{error}"
|
|
234
|
+
rescue StandardError => error
|
|
235
|
+
puts "Exception handling #{msgType}.create request: #{error}"
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
}
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
#-------------------------------------------------------------------------------------------------
|
|
242
|
+
def sendAutomatedReplyFromQuickBase(requestString, sendTo)
|
|
243
|
+
sent = false
|
|
244
|
+
@qbc.iterateRecords(@messages_dbid,[send_to_twitter],"{'#{@fieldIDs[keyword]}'.EX.'#{requestString}'}AND{'#{@fieldIDs[send_to_twitter]}'.XEX.''}"){|quickbase_record|
|
|
245
|
+
begin
|
|
246
|
+
response = "#{requestString}: #{quickbase_record[send_to_twitter].dup}"
|
|
247
|
+
Twitter::Message.create(:text => response,:recipient => sendTo,:client => @tc)
|
|
248
|
+
puts "Automated Direct Message sent to #{sendTo}: #{response}"
|
|
249
|
+
sent = true
|
|
250
|
+
rescue Twitter::RESTError => error
|
|
251
|
+
puts "Twitter exception handling Twitter::Message.create request: #{error}"
|
|
252
|
+
rescue StandardError => error
|
|
253
|
+
puts "Exception handling Twitter::Message.create request: #{error}"
|
|
254
|
+
end
|
|
255
|
+
}
|
|
256
|
+
sent
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
#----------------------------------------------------------------
|
|
260
|
+
def processRESTRequest(requestString, sendTo)
|
|
261
|
+
sent = false
|
|
262
|
+
reply = @qbc.processRESTRequest(requestString)
|
|
263
|
+
response = "#{requestString}: #{reply}"
|
|
264
|
+
begin
|
|
265
|
+
Twitter::Message.create(:text => response,:recipient => sendTo,:client => @tc)
|
|
266
|
+
puts "Automated Direct Message sent to #{sendTo}: #{response}"
|
|
267
|
+
sent = true
|
|
268
|
+
rescue Twitter::RESTError => error
|
|
269
|
+
puts "Twitter exception handling Twitter::Message.create request: #{error}"
|
|
270
|
+
rescue StandardError => error
|
|
271
|
+
puts "Exception handling Twitter::Message.create request: #{error}"
|
|
272
|
+
end
|
|
273
|
+
sent
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
#----------------------------------------------------------------
|
|
277
|
+
def quickbase_username() "Quickbase username" end
|
|
278
|
+
def quickbase_password() "Quickbase password" end
|
|
279
|
+
def twitter_username() "Twitter username" end
|
|
280
|
+
def twitter_password() "Twitter password" end
|
|
281
|
+
def connection_type() "Connection type" end
|
|
282
|
+
def message_type() "Message type" end
|
|
283
|
+
def keyword() "Keyword" end
|
|
284
|
+
def received_from_twitter() "Received from Twitter" end
|
|
285
|
+
def send_to_twitter() "Send to Twitter" end
|
|
286
|
+
def sent_to_twitter() "Sent?" end
|
|
287
|
+
def record_ID() "Record ID#" end
|
|
288
|
+
def date_created() "Date Created" end
|
|
289
|
+
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def testQuickBaseTwitterConnector()
|
|
295
|
+
QuickBase::TwitterConnector.new
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
#testQuickBaseTwitterConnector
|
|
299
|
+
|
|
300
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#--#####################################################################
|
|
2
|
+
# Copyright (c) 2009 Gareth Lewis and Intuit, Inc.
|
|
3
|
+
#
|
|
4
|
+
# All rights reserved. This program and the accompanying materials
|
|
5
|
+
# are made available under the terms of the Eclipse Public License v1.0
|
|
6
|
+
# which accompanies this distribution, and is available at
|
|
7
|
+
# http://www.opensource.org/licenses/eclipse-1.0.php
|
|
8
|
+
#
|
|
9
|
+
# Contributors:
|
|
10
|
+
# Gareth Lewis - Initial contribution.
|
|
11
|
+
# Intuit Partner Platform.
|
|
12
|
+
#++#####################################################################
|
|
13
|
+
|
|
14
|
+
require 'QuickBaseCommandlineClient'
|
|
15
|
+
|
|
16
|
+
module QuickBase
|
|
17
|
+
|
|
18
|
+
# class WebClient: a web server that responds to requests to run command files
|
|
19
|
+
# present on the local machine. This extends QuickBase via URLs on web pages.
|
|
20
|
+
#
|
|
21
|
+
# e.g. if there is an 'uploadSpreadsheet.qbc' command file next to this QuickBaseClient.rb
|
|
22
|
+
# file on your machine, it can be run from a web page by starting 'WebClient.new' on your
|
|
23
|
+
# machine and placing 'http://127.0.0.1:2358/qbc/uploadSpreadsheet.qbc' in a link on the
|
|
24
|
+
# web page.
|
|
25
|
+
#
|
|
26
|
+
# Any request that does not include "/qbc/" will shut down the server.
|
|
27
|
+
class WebClient < CommandLineClient
|
|
28
|
+
|
|
29
|
+
attr_reader :runNow, :running, :ipAddress, :port, :thread
|
|
30
|
+
|
|
31
|
+
def initialize( runNow = true, ipAddress = 'localhost', port = 2358 )
|
|
32
|
+
super()
|
|
33
|
+
@runNow = runNow
|
|
34
|
+
@doStop = @running = false
|
|
35
|
+
if @runNow
|
|
36
|
+
start( ipAddress, port )
|
|
37
|
+
else
|
|
38
|
+
@ipAddress, @port = ipAddress, port
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def stop()
|
|
43
|
+
if @running and @thread
|
|
44
|
+
puts "------ #{Time.now} ------"
|
|
45
|
+
puts "------ Web client stopped ------"
|
|
46
|
+
Thread.kill( @thread )
|
|
47
|
+
@doStop = @running = @thread = nil
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def start( ipAddress = 'localhost', port = 2358 )
|
|
52
|
+
|
|
53
|
+
stop if @running
|
|
54
|
+
@ipAddress, @port = ipAddress, port
|
|
55
|
+
|
|
56
|
+
@thread = Thread.new {
|
|
57
|
+
|
|
58
|
+
begin
|
|
59
|
+
server = TCPServer.new( ipAddress, port )
|
|
60
|
+
@running = true
|
|
61
|
+
|
|
62
|
+
puts "------ #{Time.now} ------"
|
|
63
|
+
puts "------ Web client started on #{ipAddress}:#{port} ------"
|
|
64
|
+
|
|
65
|
+
while ( session = server.accept )
|
|
66
|
+
|
|
67
|
+
request = session.gets
|
|
68
|
+
|
|
69
|
+
puts "------ #{Time.now} ------"
|
|
70
|
+
puts "Request: #{request}"
|
|
71
|
+
|
|
72
|
+
if request.include?( " /qbc/" )
|
|
73
|
+
commandFile = ""
|
|
74
|
+
requestParts = request.split( " " )
|
|
75
|
+
requestParts.each{ |requestPart|
|
|
76
|
+
if requestPart.include?( "/qbc/" )
|
|
77
|
+
commandFile = requestPart.split( "/" ).last
|
|
78
|
+
end
|
|
79
|
+
}
|
|
80
|
+
if commandFile.length > 1 and FileTest.readable?( commandFile )
|
|
81
|
+
puts "------ Attempting to run '#{commandFile}'."
|
|
82
|
+
run( commandFile )
|
|
83
|
+
puts "------ Finished running command file '#{commandFile}'."
|
|
84
|
+
session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n"
|
|
85
|
+
session.print "<html><head><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"></META></head><body><h1>"
|
|
86
|
+
session.print "Finished running command file '#{commandFile}'.<br>Please press the browser's Back button"
|
|
87
|
+
session.print "</h1></body></html>\r\n"
|
|
88
|
+
else
|
|
89
|
+
puts "------ '#{commandFile}' is not a valid command file."
|
|
90
|
+
session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n"
|
|
91
|
+
session.print "<html><head><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"></META></head><body><h1>'#{commandFile}' is not a valid command file.</h1></body></html>\r\n"
|
|
92
|
+
end
|
|
93
|
+
session.close
|
|
94
|
+
elsif not request.include?( "GET /favicon.ico " )
|
|
95
|
+
session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n"
|
|
96
|
+
session.print "<html><head><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"></META></head><body><h1>Invalid request.</h1></body></html>\r\n"
|
|
97
|
+
session.close
|
|
98
|
+
stop()
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
rescue StandardError => e
|
|
102
|
+
puts "Error: #{e}"
|
|
103
|
+
end
|
|
104
|
+
}
|
|
105
|
+
@thread.join
|
|
106
|
+
@running
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end #class WebClient -------------------------------------
|
|
110
|
+
|
|
111
|
+
end #module QuickBase ---------------------------------------------
|
|
112
|
+
|
|
113
|
+
# Run a command line client as a local web server that runs command files.
|
|
114
|
+
# e.g. ruby QuickBaseWebClient.rb runwebclient
|
|
115
|
+
if __FILE__ == $0 and ARGV.length > 0
|
|
116
|
+
if ARGV[0] == "runwebclient"
|
|
117
|
+
ARGV.shift
|
|
118
|
+
if ARGV.length > 1
|
|
119
|
+
qbwc = QuickBase::WebClient.new( true, ARGV[0], ARGV[1] )
|
|
120
|
+
elsif ARGV.length > 0
|
|
121
|
+
qbwc = QuickBase::WebClient.new( true, ARGV[0] )
|
|
122
|
+
else
|
|
123
|
+
qbwc = QuickBase::WebClient.new( true )
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#--#####################################################################
|
|
2
|
+
# Copyright (c) 2009 Gareth Lewis and Intuit, Inc.
|
|
3
|
+
#
|
|
4
|
+
# All rights reserved. This program and the accompanying materials
|
|
5
|
+
# are made available under the terms of the Eclipse Public License v1.0
|
|
6
|
+
# which accompanies this distribution, and is available at
|
|
7
|
+
# http://www.opensource.org/licenses/eclipse-1.0.php
|
|
8
|
+
#
|
|
9
|
+
# Contributors:
|
|
10
|
+
# Gareth Lewis - Initial contribution.
|
|
11
|
+
# Intuit Partner Platform.
|
|
12
|
+
#++#####################################################################
|
|
13
|
+
|
|
14
|
+
require 'QuickBaseClient'
|
|
15
|
+
|
|
16
|
+
module QuickBase
|
|
17
|
+
# Client that defaults the host to workplace.intuit.com
|
|
18
|
+
class WorkPlaceClient < Client
|
|
19
|
+
def initialize(username=nil,password=nil,appname=nil,useSSL=true,printRequestsAndResponses=false,
|
|
20
|
+
stopOnError=false,showTrace=false,apptoken=nil,debugHTTPConnection=false,proxy_options = nil)
|
|
21
|
+
super(username,password,appname,useSSL,printRequestsAndResponses,stopOnError,showTrace,"workplace",apptoken,debugHTTPConnection,"intuit",proxy_options)
|
|
22
|
+
end
|
|
23
|
+
def WorkPlaceClient.init(options)
|
|
24
|
+
options ||= {}
|
|
25
|
+
options["useSSL"] ||= true
|
|
26
|
+
options["printRequestsAndResponses"] ||= false
|
|
27
|
+
options["stopOnError"] ||= false
|
|
28
|
+
options["showTrace"] ||= false
|
|
29
|
+
options["debugHTTPConnection"] ||= false
|
|
30
|
+
options["proxy_options"] ||= nil
|
|
31
|
+
instance = WorkPlaceClient.new( options["username"],
|
|
32
|
+
options["password"],
|
|
33
|
+
options["appname"],
|
|
34
|
+
options["useSSL"],
|
|
35
|
+
options["printRequestsAndResponses"],
|
|
36
|
+
options["stopOnError"],
|
|
37
|
+
options["showTrace"],
|
|
38
|
+
options["apptoken"],
|
|
39
|
+
options["debugHTTPConnection"],
|
|
40
|
+
options["proxy_options"])
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|