Class: QuickBase::Client
- Inherits:
-
Object
- Object
- QuickBase::Client
- Defined in:
- lib/broker/client/QuickBaseClient.rb
Overview
QuickBase Client: Ruby wrapper class for QuickBase HTTP API. The class’s method and member variable names correspond closely to the QuickBase HTTP API reference. This class was written using ruby 1.8.6. It is strongly recommended that you use ruby 1.9.2 or higher. Use REXML to process any QuickBase response XML not handled by this class. The main work of this class is done in initialize(), sendRequest(), and processResponse(). The API_ wrapper methods just set things up for sendRequest() and put values from the response into member variables.
Defined Under Namespace
Classes: FieldValuePairXML
Instance Attribute Summary collapse
-
#access ⇒ Object
readonly
Returns the value of attribute access.
-
#accessid ⇒ Object
readonly
Returns the value of attribute accessid.
-
#accountLimit ⇒ Object
readonly
Returns the value of attribute accountLimit.
-
#accountUsage ⇒ Object
readonly
Returns the value of attribute accountUsage.
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#admin ⇒ Object
readonly
Returns the value of attribute admin.
-
#adminOnly ⇒ Object
readonly
Returns the value of attribute adminOnly.
-
#ancestorappid ⇒ Object
readonly
Returns the value of attribute ancestorappid.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#appdata ⇒ Object
readonly
Returns the value of attribute appdata.
-
#appdbid ⇒ Object
readonly
Returns the value of attribute appdbid.
-
#applicationLimit ⇒ Object
readonly
Returns the value of attribute applicationLimit.
-
#applicationUsage ⇒ Object
readonly
Returns the value of attribute applicationUsage.
-
#apptoken ⇒ Object
Returns the value of attribute apptoken.
-
#authenticationXML ⇒ Object
readonly
Returns the value of attribute authenticationXML.
-
#cachedSchemas ⇒ Object
readonly
Returns the value of attribute cachedSchemas.
-
#cacheSchemas ⇒ Object
Returns the value of attribute cacheSchemas.
-
#chdbids ⇒ Object
readonly
Returns the value of attribute chdbids.
-
#choice ⇒ Object
readonly
Returns the value of attribute choice.
-
#clist ⇒ Object
readonly
Returns the value of attribute clist.
-
#copyfid ⇒ Object
readonly
Returns the value of attribute copyfid.
-
#create ⇒ Object
readonly
Returns the value of attribute create.
-
#createapptoken ⇒ Object
readonly
Returns the value of attribute createapptoken.
-
#createdTime ⇒ Object
readonly
Returns the value of attribute createdTime.
-
#databases ⇒ Object
readonly
Returns the value of attribute databases.
-
#dbdesc ⇒ Object
readonly
Returns the value of attribute dbdesc.
-
#dbid ⇒ Object
readonly
Returns the value of attribute dbid.
-
#dbidForRequestURL ⇒ Object
readonly
Returns the value of attribute dbidForRequestURL.
-
#dbname ⇒ Object
readonly
Returns the value of attribute dbname.
-
#delete ⇒ Object
readonly
Returns the value of attribute delete.
-
#destrid ⇒ Object
readonly
Returns the value of attribute destrid.
-
#dfid ⇒ Object
readonly
Returns the value of attribute dfid.
-
#disprec ⇒ Object
readonly
Returns the value of attribute disprec.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#downLoadFileURL ⇒ Object
readonly
Returns the value of attribute downLoadFileURL.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#encoding ⇒ Object
writeonly
Sets the attribute encoding.
-
#errcode ⇒ Object
readonly
Returns the value of attribute errcode.
-
#errdetail ⇒ Object
readonly
Returns the value of attribute errdetail.
-
#errtext ⇒ Object
readonly
Returns the value of attribute errtext.
-
#escapeBR ⇒ Object
writeonly
Sets the attribute escapeBR.
-
#eventSubscribers ⇒ Object
readonly
Returns the value of attribute eventSubscribers.
-
#excludeparents ⇒ Object
readonly
Returns the value of attribute excludeparents.
-
#externalAuth ⇒ Object
readonly
Returns the value of attribute externalAuth.
-
#fform ⇒ Object
readonly
Returns the value of attribute fform.
-
#fid ⇒ Object
readonly
Returns the value of attribute fid.
-
#fids ⇒ Object
readonly
Returns the value of attribute fids.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#field_data ⇒ Object
readonly
Returns the value of attribute field_data.
-
#field_data_list ⇒ Object
readonly
Returns the value of attribute field_data_list.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#fieldTypeLabelMap ⇒ Object
readonly
Returns the value of attribute fieldTypeLabelMap.
-
#fieldValue ⇒ Object
readonly
Returns the value of attribute fieldValue.
-
#fileContents ⇒ Object
readonly
Returns the value of attribute fileContents.
-
#fileUploadToken ⇒ Object
readonly
Returns the value of attribute fileUploadToken.
-
#firstName ⇒ Object
readonly
Returns the value of attribute firstName.
-
#fmt ⇒ Object
readonly
Returns the value of attribute fmt.
-
#fname ⇒ Object
readonly
Returns the value of attribute fname.
-
#fnames ⇒ Object
readonly
Returns the value of attribute fnames.
-
#fvlist ⇒ Object
Returns the value of attribute fvlist.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#HTML ⇒ Object
readonly
Returns the value of attribute HTML.
-
#httpConnection ⇒ Object
Returns the value of attribute httpConnection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ignoreCR ⇒ Object
writeonly
Sets the attribute ignoreCR.
-
#ignoreError ⇒ Object
readonly
Returns the value of attribute ignoreError.
-
#ignoreLF ⇒ Object
writeonly
Sets the attribute ignoreLF.
-
#ignoreTAB ⇒ Object
writeonly
Sets the attribute ignoreTAB.
-
#includeancestors ⇒ Object
readonly
Returns the value of attribute includeancestors.
-
#jht ⇒ Object
readonly
Returns the value of attribute jht.
-
#jsa ⇒ Object
readonly
Returns the value of attribute jsa.
-
#keepData ⇒ Object
readonly
Returns the value of attribute keepData.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#key_fid ⇒ Object
readonly
Returns the value of attribute key_fid.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#lastAccessTime ⇒ Object
readonly
Returns the value of attribute lastAccessTime.
-
#lastError ⇒ Object
readonly
Returns the value of attribute lastError.
-
#lastModifiedTime ⇒ Object
readonly
Returns the value of attribute lastModifiedTime.
-
#lastName ⇒ Object
readonly
Returns the value of attribute lastName.
-
#lastPaymentDate ⇒ Object
readonly
Returns the value of attribute lastPaymentDate.
-
#lastRecModTime ⇒ Object
readonly
Returns the value of attribute lastRecModTime.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#mgrID ⇒ Object
readonly
Returns the value of attribute mgrID.
-
#mgrName ⇒ Object
readonly
Returns the value of attribute mgrName.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#modify ⇒ Object
readonly
Returns the value of attribute modify.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#newappname ⇒ Object
readonly
Returns the value of attribute newappname.
-
#newdbdesc ⇒ Object
readonly
Returns the value of attribute newdbdesc.
-
#newdbid ⇒ Object
readonly
Returns the value of attribute newdbid.
-
#newdbname ⇒ Object
readonly
Returns the value of attribute newdbname.
-
#newowner ⇒ Object
readonly
Returns the value of attribute newowner.
-
#num_fields ⇒ Object
readonly
Returns the value of attribute num_fields.
-
#num_records ⇒ Object
readonly
Returns the value of attribute num_records.
-
#num_records_deleted ⇒ Object
readonly
Returns the value of attribute num_records_deleted.
-
#num_recs_added ⇒ Object
readonly
Returns the value of attribute num_recs_added.
-
#num_recs_input ⇒ Object
readonly
Returns the value of attribute num_recs_input.
-
#num_recs_updated ⇒ Object
readonly
Returns the value of attribute num_recs_updated.
-
#numadded ⇒ Object
readonly
Returns the value of attribute numadded.
-
#numCreated ⇒ Object
readonly
Returns the value of attribute numCreated.
-
#numMatches ⇒ Object
readonly
Returns the value of attribute numMatches.
-
#numRecords ⇒ Object
readonly
Returns the value of attribute numRecords.
-
#numremoved ⇒ Object
readonly
Returns the value of attribute numremoved.
-
#oldestancestorappid ⇒ Object
readonly
Returns the value of attribute oldestancestorappid.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#org ⇒ Object
readonly
Returns the value of attribute org.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#pagebody ⇒ Object
readonly
Returns the value of attribute pagebody.
-
#pageid ⇒ Object
readonly
Returns the value of attribute pageid.
-
#pagename ⇒ Object
readonly
Returns the value of attribute pagename.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#pagetype ⇒ Object
readonly
Returns the value of attribute pagetype.
-
#parentrid ⇒ Object
readonly
Returns the value of attribute parentrid.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#printRequestsAndResponses ⇒ Object
Returns the value of attribute printRequestsAndResponses.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#qarancestorappid ⇒ Object
readonly
Returns the value of attribute qarancestorappid.
-
#qbhost ⇒ Object
Returns the value of attribute qbhost.
-
#qdbapi ⇒ Object
readonly
Returns the value of attribute qdbapi.
-
#qid ⇒ Object
readonly
Returns the value of attribute qid.
-
#qname ⇒ Object
readonly
Returns the value of attribute qname.
-
#queries ⇒ Object
readonly
Returns the value of attribute queries.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#rdr ⇒ Object
writeonly
Sets the attribute rdr.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#records_csv ⇒ Object
readonly
Returns the value of attribute records_csv.
-
#recurse ⇒ Object
readonly
Returns the value of attribute recurse.
-
#relfids ⇒ Object
readonly
Returns the value of attribute relfids.
-
#requestHeaders ⇒ Object
readonly
Returns the value of attribute requestHeaders.
-
#requestNextAllowedTime ⇒ Object
readonly
Returns the value of attribute requestNextAllowedTime.
-
#requestSucceeded ⇒ Object
readonly
Returns the value of attribute requestSucceeded.
-
#requestTime ⇒ Object
readonly
Returns the value of attribute requestTime.
-
#requestURL ⇒ Object
readonly
Returns the value of attribute requestURL.
-
#requestXML ⇒ Object
readonly
Returns the value of attribute requestXML.
-
#responseElement ⇒ Object
readonly
Returns the value of attribute responseElement.
-
#responseElements ⇒ Object
readonly
Returns the value of attribute responseElements.
-
#responseElementText ⇒ Object
readonly
Returns the value of attribute responseElementText.
-
#responseXML ⇒ Object
readonly
Returns the value of attribute responseXML.
-
#responseXMLdoc ⇒ Object
readonly
Returns the value of attribute responseXMLdoc.
-
#rid ⇒ Object
readonly
Returns the value of attribute rid.
-
#rids ⇒ Object
readonly
Returns the value of attribute rids.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#roleid ⇒ Object
readonly
Returns the value of attribute roleid.
-
#rolename ⇒ Object
readonly
Returns the value of attribute rolename.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#saveviews ⇒ Object
readonly
Returns the value of attribute saveviews.
-
#screenName ⇒ Object
readonly
Returns the value of attribute screenName.
-
#serverDatabases ⇒ Object
readonly
Returns the value of attribute serverDatabases.
-
#serverGroups ⇒ Object
readonly
Returns the value of attribute serverGroups.
-
#serverStatus ⇒ Object
readonly
Returns the value of attribute serverStatus.
-
#serverUpdays ⇒ Object
readonly
Returns the value of attribute serverUpdays.
-
#serverUptime ⇒ Object
readonly
Returns the value of attribute serverUptime.
-
#serverUsers ⇒ Object
readonly
Returns the value of attribute serverUsers.
-
#serverVersion ⇒ Object
readonly
Returns the value of attribute serverVersion.
-
#showAppData ⇒ Object
readonly
Returns the value of attribute showAppData.
-
#skipfirst ⇒ Object
readonly
Returns the value of attribute skipfirst.
-
#slist ⇒ Object
readonly
Returns the value of attribute slist.
-
#sourcerid ⇒ Object
readonly
Returns the value of attribute sourcerid.
-
#standardRequestHeaders ⇒ Object
readonly
Returns the value of attribute standardRequestHeaders.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stopOnError ⇒ Object
Returns the value of attribute stopOnError.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
-
#ticket ⇒ Object
Returns the value of attribute ticket.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#udata ⇒ Object
Returns the value of attribute udata.
-
#uname ⇒ Object
readonly
Returns the value of attribute uname.
-
#update_id ⇒ Object
readonly
Returns the value of attribute update_id.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#userid ⇒ Object
readonly
Returns the value of attribute userid.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
-
#validFieldProperties ⇒ Object
readonly
Returns the value of attribute validFieldProperties.
-
#validFieldTypes ⇒ Object
readonly
Returns the value of attribute validFieldTypes.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
-
#varname ⇒ Object
readonly
Returns the value of attribute varname.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#vid ⇒ Object
readonly
Returns the value of attribute vid.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
-
#withembeddedtables ⇒ Object
readonly
Returns the value of attribute withembeddedtables.
-
#xsl ⇒ Object
writeonly
Sets the attribute xsl.
Class Method Summary collapse
-
.init(options) ⇒ Object
Class method to create an instance of QuickBase::Client using a Hash of parameters.
-
.processDatabase(username, password, appname, chainAPIcalls = nil) ⇒ Object
-
creates a QuickBase::Client, - signs into QuickBase - connects to a specific application - runs code in the associated block - signs out of QuickBase.
-
Instance Method Summary collapse
-
#_addField(label, type, mode = nil) ⇒ Object
API_AddField, using the active table id.
-
#_addRecord(fvlist = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil) ⇒ Object
API_AddRecord, using the active table id.
-
#_addReplaceDBPage(*args) ⇒ Object
API_AddReplaceDBPage, using the active table id.
-
#_addUserToRole(userid, roleid) ⇒ Object
API_AddUserToRole, using the active table id.
-
#_changePermission(*args) ⇒ Object
API_ChangePermission (appears to be deprecated), using the active table id.
-
#_changeRecordOwner(rid, newowner) ⇒ Object
API_ChangeRecordOwner.
-
#_changeUserRole(userid, roleid, newroleid) ⇒ Object
API_ChangeUserRole, using the active table id.
- #_childElementsAsString ⇒ Object
-
#_cloneDatabase(*args) ⇒ Object
API_CloneDatabase, using the active table id.
-
#_copyMasterDetail(*args) ⇒ Object
API_CopyMasterDetail, using the active table id.
-
#_deleteDatabase ⇒ Object
API_DeleteDatabase, using the active table id.
-
#_deleteField(fid) ⇒ Object
API_DeleteField, using the active table id.
-
#_deleteFieldName(fieldName) ⇒ Object
Delete a field, using its name instead of its id.
-
#_deleteRecord(rid) ⇒ Object
API_DeleteRecord, using the active table id.
-
#_doQuery(*args) ⇒ Object
API_DoQuery, using the active table id.
-
#_doQueryCount(query) ⇒ Object
API_DoQueryCount, using the active table id.
-
#_doQueryHash(doQueryOptions) ⇒ Object
version of doQuery that takes a Hash of parameters.
-
#_doQueryName(queryName) ⇒ Object
Runs API_DoQuery using the name of a query.
-
#_downLoadFile(rid, fid, vid = "0") ⇒ Object
(also: #_downloadFile)
Download a file’s contents from a file attachment field in QuickBase.
-
#_editRecord(*args) ⇒ Object
API_EditRecord, using the active table id.
-
#_fieldAddChoices(fid, choice) ⇒ Object
API_FieldAddChoices, using the active table id.
-
#_fieldNameAddChoices(fieldName, choice) ⇒ Object
Runs API_FieldAddChoices using a field name instead ofa field id.
-
#_fieldNameRemoveChoices(fieldName, choice) ⇒ Object
Runs API_FieldRemoveChoices using a field name instead of a field id.
-
#_fieldRemoveChoices(fid, choice) ⇒ Object
API_FieldRemoveChoices, using the active table id.
-
#_genAddRecordForm(fvlist = nil) ⇒ Object
API_GenAddRecordForm, using the active table id.
-
#_genResultsTable(*args) ⇒ Object
API_GenResultsTable, using the active table id.
- #_getAncestorInfo ⇒ Object
-
#_getAppDTMInfo ⇒ Object
API_GetAppDTMInfo, using the active table id.
-
#_getBillingStatus ⇒ Object
API_GetBillingStatus, using the active table id.
-
#_getDBInfo ⇒ Object
API_GetDBInfo, using the active table id.
-
#_getDBPage(pageid, pagename = nil) ⇒ Object
API_GetDBPage, using the active table id.
-
#_getDBvar(varname) ⇒ Object
API_GetDBVar, using the active table id.
-
#_getEntitlementValues ⇒ Object
API_GetEntitlementValues, using the active table id.
-
#_getFileAttachmentUsage ⇒ Object
API_GetFileAttachmentUsage, using the active table id.
-
#_getNumRecords ⇒ Object
API_GetNumRecords, using the active table id.
-
#_getRecordAsHTML(rid, jht = nil, dfid = nil) ⇒ Object
API_GetRecordAsHTML, using the active table id.
-
#_getRecordInfo(rid = @rid) ⇒ Object
API_GetRecordInfo, using the active table id.
-
#_getRoleInfo ⇒ Object
API_GetRoleInfo, using the active table id.
-
#_getSchema ⇒ Object
API_GetSchema, using the active table id.
-
#_getUserRole(userid, inclgrps = nil) ⇒ Object
API_GetUserRole, using the active table id.
-
#_importFromCSV(*args) ⇒ Object
API_ImportFromCSV, using the active table id.
-
#_importFromExcel(excelFilename, lastColumn = 'j', lastDataRow = 0, worksheetNumber = 1, fieldNameRow = 1, firstDataRow = 2, firstColumn = 'a') ⇒ Object
Import data directly from an Excel file into the active table.
-
#_listDBPages ⇒ Object
API_ListDBPages, using the active table id.
- #_printChildElements ⇒ Object
-
#_provisionUser(roleid, email, fname, lname) ⇒ Object
API_ProvisionUser, using the active table id.
-
#_purgeRecords(query = nil, qid = nil, qname = nil) ⇒ Object
API_PurgeRecords, using the active table id.
-
#_removeFileAttachment(rid, fileAttachmentFieldName) ⇒ Object
Remove the file from a File Attachment field in an existing record in the active table e.g.
-
#_removeUserFromRole(userid, roleid) ⇒ Object
API_RemoveUserFromRole, using the active table id.
-
#_renameApp(newappname) ⇒ Object
API_RenameApp, using the active table id.
-
#_runImport(id) ⇒ Object
API_RunImport, using the active table id.
-
#_sendInvitation(userid, usertext = "Welcome to my application!") ⇒ Object
API_SendInvitation, using the active table id.
- #_setActiveRecord(rid) ⇒ Object
-
#_setAppData(appdata) ⇒ Object
API_SetAppData, using the active table id.
-
#_setDBvar(varname, value) ⇒ Object
API_SetDBvar, using the active table id.
-
#_setFieldProperties(properties, fid) ⇒ Object
API_SetFieldProperties, using the active table id.
-
#_setKeyField(fid) ⇒ Object
API_SetKeyField, using the active table id.
-
#_updateFile(filename, fileAttachmentFieldName) ⇒ Object
Update the file attachment in an existing record in the active record in the active table.
-
#_uploadFile(filename, fileAttachmentFieldName) ⇒ Object
Upload a file into a new record in the active table.
-
#_userRoles ⇒ Object
API_UserRoles, using the active table id.
-
#addField(dbid, label, type, mode = nil) ⇒ Object
API_AddField.
-
#addFieldValuePair(name, fid, filename, value) ⇒ Object
Adds a field value to the list of fields to be set by the next addRecord() or editRecord() call to QuickBase.
-
#addOrEditRecord(dbid, fvlist, rid = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, key = nil) ⇒ Object
Use this if you aren’t sure whether a particular record already exists or not.
-
#addRecord(dbid, fvlist = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC = nil) ⇒ Object
API_AddRecord.
-
#addReplaceDBPage(dbid, pageid, pagename, pagetype, pagebody, ignoreError = nil) ⇒ Object
API_AddReplaceDBPage.
-
#addUserToRole(dbid, userid, roleid) ⇒ Object
API_AddUserToRole.
-
#alias_methods ⇒ Object
Add method aliases that follow the ruby method naming convention.
-
#applyDeviationToRecords(dbid, numericField, deviationField, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Query records, get the average of the values in a numeric field, calculate each record’s deviation from the average and put the deviation in a percent field each record.
-
#applyPercentToRecords(dbid, numericField, percentField, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Query records, sum the values in a numeric field, calculate each record’s percentage of the sum and put the percent in a percent field each record.
-
#assertFederatedIdentity(dbid, serviceProviderID, targetURL) ⇒ Object
API_AssertFederatedIdentity (IPP only).
-
#attachIDSRealm(dbid, realm) ⇒ Object
API_AttachIDSRealm (IPP only).
-
#authenticate(username, password, hours = nil) ⇒ Object
API_Authenticate.
-
#average(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Returns the average of the values for one or more fields in the records returned by a query.
-
#chainAPIcallsBlock ⇒ Object
This method changes all the API_ wrapper methods to return ‘self’ instead of their normal return values.
-
#changePermission(dbid, uname, view, modify, create, delete, saveviews, admin) ⇒ Object
API_ChangePermission (appears to be deprecated).
-
#changeRecordOwner(dbid, rid, newowner) ⇒ Object
API_ChangeRecordOwner.
-
#changeRecords(fieldNameToSet, fieldValueToSet, fieldNameToTest, test, fieldValueToTest) ⇒ Object
Change a field’s value in multiple records.
-
#changeUserRole(dbid, userid, roleid, newroleid) ⇒ Object
API_ChangeUserRole.
-
#childElementsAsString(element, indent = 0) ⇒ Object
Recursive method to generate a simplified (yaml-like) tree of the XML returned by QuickBase.
-
#clearFieldValuePairList ⇒ Object
Empty the list of field values used for the next addRecord() or editRecord() call to QuickBase.
-
#clientMethods ⇒ Object
Return an array of all the public methods of this class.
-
#cloneDatabase(dbid, newdbname, newdbdesc, keepData, asTemplate = nil, usersAndRoles = nil) ⇒ Object
API_CloneDatabase.
-
#copyMasterDetail(dbid, destrid, sourcerid, copyfid = nil, recurse = nil, relfids = nil) ⇒ Object
API_CopyMasterDetail.
-
#copyRecord(rid, numCopies = 1, dbid = @dbid) ⇒ Object
Make one or more copies of a record.
-
#count(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Returns the number non-null values for one or more fields in the records returned by a query.
-
#createDatabase(dbname, dbdesc, createapptoken = "1") ⇒ Object
API_CreateDatabase.
-
#createTable(tname, pnoun, application_dbid = @dbid) ⇒ Object
API_CreateTable.
-
#dateToMS(dateString) ⇒ Object
Returns the milliseconds representation of a date specified in mm-dd-yyyy format.
-
#debugHTTPConnection ⇒ Object
Causes useful information to be printed to the screen for every HTTP request.
-
#decodeXML(text) ⇒ Object
Modify the given XML field value for use as a string.
-
#deleteAppZip(dbid) ⇒ Object
API_DeleteAppZip.
-
#deleteDatabase(dbid) ⇒ Object
API_DeleteDatabase.
-
#deleteDuplicateRecords(fnames, fids = nil, options = nil, dbid = @dbid) ⇒ Object
Finds records with the same values in a specified list of fields and deletes all but the first or last duplicate record.
-
#deleteField(dbid, fid) ⇒ Object
API_DeleteField.
-
#deleteRecord(dbid, rid) ⇒ Object
API_DeleteRecord.
-
#deleteRecords(fieldNameToTest = nil, test = nil, fieldValueToTest = nil) ⇒ Object
Delete all records in the active table that match the field/operator/value.
-
#detachIDSRealm(dbid, realm) ⇒ Object
API_DetachIDSRealm (IPP only).
-
#deviation(inputValues) ⇒ Object
Given an array of two numbers, return the difference between the numbers as a positive number.
-
#doQuery(dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
API_DoQuery.
-
#doQueryCount(dbid, query) ⇒ Object
API_DoQueryCount.
-
#doSQLInsert(sqlString) ⇒ Object
Translate a simple SQL INSERT statement to a QuickBase addRecord call.
-
#doSQLQuery(sqlString, returnOptions = nil) ⇒ Object
Translate a simple SQL SELECT statement to a QuickBase query and run it.
-
#doSQLUpdate(sqlString) ⇒ Object
Translate a simple SQL UPDATE statement to a QuickBase editRecord call.
-
#downloadAndSaveFile(dbid, rid, fid, filename = nil, vid = "0") ⇒ Object
Download and save a file from a file attachment field in QuickBase.
-
#downLoadFile(dbid, rid, fid, vid = "0") ⇒ Object
(also: #downloadFile)
Download a file’s contents from a file attachment field in QuickBase.
-
#dumpAppZip(dbid) ⇒ Object
API_DumpAppZip.
-
#eachField(record = @record) ⇒ Object
Iterate record XML and yield only ‘f’ elements.
-
#eachRecord(records = @records) ⇒ Object
Iterate @records XML and yield only ‘record’ elements.
-
#editRecord(dbid, rid, fvlist, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC = nil, key = nil) ⇒ Object
API_EditRecord.
-
#editRecords(dbid, fieldValuesToSet, query = nil, qid = nil, qname = nil) ⇒ Object
Set the values of fields in all records returned by a query.
-
#encodeXML(text, doNPChars = false) ⇒ Object
Modify the given string for use as a XML field value.
-
#encodingStrings(reverse = false) ⇒ Object
Returns the list of string substitutions to make to encode or decode field values used in XML.
-
#escapeXML(char) ⇒ Object
Returns the URL-encoded version of a non-printing character.
-
#fieldAddChoices(dbid, fid, choice) ⇒ Object
API_FieldAddChoices The choice parameter can be one choice string or an array of choice strings.
-
#fieldRemoveChoices(dbid, fid, choice) ⇒ Object
API_FieldRemoveChoices The choice parameter can be one choice string or an array of choice strings.
-
#fieldTypeForLabel(fieldTypeLabel) ⇒ Object
Returns a field type string given the more human-friendly label for a field type.
-
#findDBByname(dbname) ⇒ Object
(also: #findDBByName)
API_FindDBByname.
-
#findDuplicateRecordIDs(fnames, fids, dbid = @dbid, ignoreCase = true) ⇒ Object
Finds records with the same values in a specified list of fields.
-
#findElementByAttributeValue(elements, attribute_name, attribute_value) ⇒ Object
Returns the first XML sub-element with the specified attribute value.
-
#findElementsByAttributeName(elements, attribute_name) ⇒ Object
Returns an array of XML sub-elements with the specified attribute name.
-
#findElementsByAttributeValue(elements, attribute_name, attribute_value) ⇒ Object
Returns an array of XML sub-elements with the specified attribute value.
-
#formatChdbidName(tableName) ⇒ Object
Given the name of a QuickBase table, returns the QuickBase representation of the table name.
-
#formatCurrency(value, options = nil) ⇒ Object
Returns a string formatted for a currency value.
-
#formatDate(milliseconds, fmtString = nil, addDay = false) ⇒ Object
Returns the human-readable string represntation of a date, given the milliseconds version of the date.
-
#formatDuration(value, option = "hours") ⇒ Object
Converts milliseconds to hours and returns the value as a string.
-
#formatFieldValue(value, type, options = nil) ⇒ Object
Returns a human-readable string representation of a QuickBase field value.
-
#formatImportCSV(csv) ⇒ Object
Returns the string required for emebedding CSV data in a request.
-
#formatPercent(value, options = nil) ⇒ Object
Returns a string formatted for a percent value, given the data from QuickBase.
-
#formatTimeOfDay(milliseconds, format = "%I:%M %p") ⇒ Object
Returns a string format for a time of day value.
-
#genAddRecordForm(dbid, fvlist = nil) ⇒ Object
API_GenAddRecordForm.
-
#genResultsTable(dbid, query = nil, clist = nil, slist = nil, jht = nil, jsa = nil, options = nil, qid = nil, qname = nil) ⇒ Object
API_GenResultsTable.
-
#getAllRecordIDs(dbid) ⇒ Object
Get an array of all the record IDs for a specified table.
-
#getAllValuesForFields(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
(also: #getRecordsHash)
Get all the values for one or more fields from a specified table.
-
#getAllValuesForFieldsAsArray(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
(also: #getRecordsArray)
Get all the values for one or more fields from a specified table.
-
#getAllValuesForFieldsAsJSON(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
(also: #getRecordsAsJSON)
Get all the values for one or more fields from a specified table, in JSON format.
-
#getAllValuesForFieldsAsPrettyJSON(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
(also: #getRecordsAsPrettyJSON)
Get all the values for one or more fields from a specified table, in human-readable JSON format.
-
#getAncestorInfo(dbid) ⇒ Object
API_GetAncestorInfo.
-
#getAppDTMInfo(dbid) ⇒ Object
API_GetAppDTMInfo.
-
#getApplicationVariable(variableName, dbid = nil) ⇒ Object
Get the value of an application variable.
-
#getApplicationVariables(dbid = nil) ⇒ Object
Get a Hash of application variables.
-
#getAttributeString(element) ⇒ Object
Returns a string representation of the attributes of an XML element.
-
#getAuthenticationXMLforRequest(api_Request) ⇒ Object
Returns the request XML for either a ticket or a username and password.
-
#getBillingStatus(dbid) ⇒ Object
API_GetBillingStatus.
-
#getColumnListForQuery(id, name) ⇒ Object
(also: #getColumnListForReport)
Returns the clist associated with a query.
-
#getCriteriaForQuery(id, name) ⇒ Object
(also: #getCriteriaForReport)
Returns the criteria associated with a query.
-
#getCSVForReport(dbid, query = nil, qid = nil, qname = nil) ⇒ Object
Get the CSV data for a Report.
-
#getDBforRequestURL(api_Request) ⇒ Object
Determines whether the URL for a QuickBase request is for a specific database table or not, and returns the appropriate string for that portion of the request URL.
-
#getDBInfo(dbid) ⇒ Object
API_GetDBInfo.
-
#getDBPage(dbid, pageid, pagename = nil) ⇒ Object
API_GetDBPage.
-
#getDBPagesAsArray(dbid) ⇒ Object
(also: #getDBPages)
Get an array Pages for an application.
-
#getDBvar(dbid, varname) ⇒ Object
API_GetDBVar.
-
#getEntitlementValues(dbid) ⇒ Object
API_GetEntitlementValues.
-
#getErrorInfoFromResponse ⇒ Object
Extracts error info from XML responses returned by QuickBase.
-
#getFieldChoices(dbid, fieldName = nil, fid = nil) ⇒ Object
Get an array of the existing choices for a multiple-choice text field.
-
#getFieldDataPrintableValue(fid) ⇒ Object
Returns the printable value for a field returned by a getRecordInfo call.
-
#getFieldDataValue(fid) ⇒ Object
Returns the value for a field returned by a getRecordInfo call.
-
#getFieldIDs(dbid = nil, exclude_built_in_fields = false) ⇒ Object
Get an array of field IDs for a table.
-
#getFieldNames(dbid = nil, lowerOrUppercase = "", exclude_built_in_fields = false) ⇒ Object
Get an array of field names for a table.
-
#getFileAttachmentUsage(dbid) ⇒ Object
API_GetFileAttachmentUsage.
-
#getFileDownloadURL(dbid, rid, fid, vid = "0", org = "www", domain = "quickbase", ssl = "s") ⇒ Object
Get the URL string for downloading a file from a File Attachment field.
-
#getFileUploadToken ⇒ Object
API_GetFileUploadToken.
-
#getFilteredRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
(also: #findRecords, #find_records)
e.g.
-
#getIDSRealm(dbid) ⇒ Object
API_GetIDSRealm (IPP only).
-
#getJoinRecords(tablesAndFields) ⇒ Object
Get an array of records from two or more tables and/or queries with the same value in a ‘join’ field.
-
#getNumRecords(dbid) ⇒ Object
API_GetNumRecords.
-
#getNumTables(dbid) ⇒ Object
Get the number of child tables of an application.
-
#getOneTimeTicket ⇒ Object
API_GetOneTimeTicket.
-
#getQueryRequestXML(query = nil, qid = nil, qname = nil) ⇒ Object
Builds the request XML for retrieving the results of a query.
-
#getRealmForDbid(dbid) ⇒ Object
Given a DBID, get the QuickBase realm it is in.
-
#getRecord(rid, dbid = @dbid, fieldNames = nil) ⇒ Object
Get a record as a Hash, using the record id and dbid .
-
#getRecordAsHTML(dbid, rid, jht = nil, dfid = nil) ⇒ Object
API_GetRecordAsHTML.
-
#getRecordInfo(dbid, rid) ⇒ Object
API_GetRecordInfo.
-
#getRecords(rids, dbid = @dbid, fieldNames = nil) ⇒ Object
Get an array of records as Hashes, using the record ids and dbid .
-
#getReportNames(dbid = @dbid) ⇒ Object
Get a list of the names of the reports (i.e. queries) for a table.
-
#getResponseElement(path) ⇒ Object
Gets the element at an Xpath in the XML from QuickBase.
-
#getResponseElements(path) ⇒ Object
Gets an array of elements at an Xpath in the XML from QuickBase.
-
#getResponsePathValue(path) ⇒ Object
Gets the value of a field using an XPath spec., e.g.
-
#getResponsePathValues(path) ⇒ Object
Gets an array of values at an Xpath in the XML from QuickBase.
-
#getResponseValue(field) ⇒ Object
Gets the value for a specific field at the top level of the XML returned from QuickBase.
-
#getRoleInfo(dbid) ⇒ Object
API_GetRoleInfo.
-
#getSchema(dbid) ⇒ Object
API_GetSchema.
-
#getServerStatus ⇒ Object
Get the status of the QuickBase server.
-
#getSortListForQuery(id, name) ⇒ Object
(also: #getSortListForReport)
Returns the slist associated with a query.
-
#getSummaryRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Collect summary records into an array.
-
#getTableIDs(dbid) ⇒ Object
Get a list of the dbids of the child tables of an application.
-
#getTableName(dbid) ⇒ Object
Get the name of a table given its id.
-
#getTableNames(dbid, lowercaseOrUpperCase = "") ⇒ Object
Get a list of the names of the child tables of an application.
-
#getUnionRecords(tables, fieldNames) ⇒ Object
Returns an Array of values from the same fields in two or more tables and/or queries.
-
#getUserInfo(email = nil) ⇒ Object
API_GetUserInfo.
-
#getUserRole(dbid, userid, inclgrps = nil) ⇒ Object
API_GetUserRole.
-
#grantedDBs(withembeddedtables = nil, excludeparents = nil, adminOnly = nil, includeancestors = nil, showAppData = nil) ⇒ Object
API_GrantedDBs.
-
#importCSVFile(filename, dbid = @dbid, targetFieldNames = nil, validateLines = true) ⇒ Object
Add records from lines in a CSV file.
-
#importFromCSV(dbid, records_csv, clist, skipfirst = nil, msInUTC = nil) ⇒ Object
API_ImportFromCSV.
-
#importFromExcel(dbid, excelFilename, lastColumn = 'j', lastDataRow = 0, worksheetNumber = 1, fieldNameRow = 1, firstDataRow = 2, firstColumn = 'a') ⇒ Object
Import data directly from an Excel file into a table The field names are expected to be on line 1 by default.
-
#importSVFile(filename, fieldSeparator = ",", dbid = @dbid, targetFieldNames = nil, validateLines = true) ⇒ Object
Add records from lines in a separated values text file, using a specified field name/value separator.
-
#importTSVFile(filename, dbid = @dbid, targetFieldNames = nil, validateLines = true) ⇒ Object
Import records from a text file in Tab-Separated-Values format.
-
#initialize(username = nil, password = nil, appname = nil, useSSL = true, printRequestsAndResponses = false, stopOnError = false, showTrace = false, org = "www", apptoken = nil, debugHTTPConnection = false, domain = "quickbase", proxy_options = nil) ⇒ Client
constructor
Set printRequestsAndResponses to true to view the XML sent to QuickBase and return from QuickBase.
-
#installAppZip(dbid) ⇒ Object
API_InstallAppZip.
-
#isAverageField?(fieldName) ⇒ Boolean
Returns whether a field will show an Average on reports.
-
#isBuiltInField?(fid) ⇒ Boolean
Returns whether a field ID is the ID for a built-in field.
-
#isHTMLRequest?(api_Request) ⇒ Boolean
Returns whether a request will return HTML rather than XML.
-
#isRecordidField?(fid) ⇒ Boolean
Returns whether a field ID is the ID for the key field in a QuickBase table.
-
#isTotalField?(fieldName) ⇒ Boolean
Returns whether a field will show a Total on reports.
-
#isValidFieldProperty?(property) ⇒ Boolean
Returns whether a given string represents a valid QuickBase field property.
-
#isValidFieldType?(type) ⇒ Boolean
Returns whether a given string represents a valid QuickBase field type.
-
#iterateDBPages(dbid) ⇒ Object
Loop through the list of Pages for an application.
-
#iterateFilteredRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Same as iterateRecords but with fields optionally filtered by Ruby regular expressions.
-
#iterateJoinRecords(tablesAndFields) ⇒ Object
Get records from two or more tables and/or queries with the same value in a ‘join’ field and loop through the joined results.
-
#iterateRecordInfos(dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Loop through a list of records returned from a query.
-
#iterateRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Loop through records returned from a query.
-
#iterateSummaryRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) {|summaryRecord| ... } ⇒ Object
(The QuickBase API does not supply a method for this.) Loop through summary records, like the records in a QuickBase Summary report.
-
#iterateUnionRecords(tables, fieldNames) ⇒ Object
Get values from the same fields in two or more tables and/or queries and loop through the merged results.
-
#listDBPages(dbid) ⇒ Object
API_ListDBPages.
-
#logToFile(filename) ⇒ Object
Log requests to QuickBase and responses from QuickBase in a file.
-
#lookupBaseFieldTypeByName(fieldName) ⇒ Object
Get a field’s base type using its name.
-
#lookupChdbid(tableName, dbid = nil) ⇒ Object
Makes the table with the specified name the ‘active’ table, and returns the id from the table.
-
#lookupField(fid) ⇒ Object
Returns the XML element for a field definition.
-
#lookupFieldData(fid) ⇒ Object
Returns the XML element for a field returned by a getRecordInfo call.
-
#lookupFieldIDByName(fieldName, dbid = nil) ⇒ Object
Gets the ID for a field using the QuickBase field label.
-
#lookupFieldName(element) ⇒ Object
Returns the name of field given an “fid” XML element.
-
#lookupFieldNameFromID(fid, dbid = nil) ⇒ Object
Gets a field name (i.e. QuickBase field label) using a field ID.
-
#lookupFieldPropertyByName(fieldName, property) ⇒ Object
Returns the value of a field property, or nil.
-
#lookupFieldsByType(type) ⇒ Object
Returns an array of XML field elements matching a QuickBase field type.
-
#lookupFieldType(element) ⇒ Object
Returns a QuickBase field type, given an XML “fid” element.
-
#lookupFieldTypeByName(fieldName) ⇒ Object
Get a field’s type using its name.
-
#lookupQuery(qid, dbid = nil) ⇒ Object
Returns the XML element for a query with the specified ID.
-
#lookupQueryByName(name, dbid = nil) ⇒ Object
Returns the XML element for a query with the specified ID.
-
#lookupRecord(rid) ⇒ Object
Returns the XML element for a record with the specified ID.
-
#makeCSVFileForReport(filename, dbid = @dbid, query = nil, qid = nil, qname = nil) ⇒ Object
Create a CSV file using the records for a Report.
-
#makeSVFile(filename, fieldSeparator = ",", dbid = @dbid, query = nil, qid = nil, qname = nil) ⇒ Object
Make a CSV file using the results of a query.
-
#max(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Find the highest value for one or more fields in the records returned by a query.
-
#method_missing(missing_method_name, *missing_method_args) ⇒ Object
Enables alternative syntax for processing data using id values or xml element names.
-
#min(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Find the lowest value for one or more fields in the records returned by a query.
-
#obStatus ⇒ Object
API_obstatus: get the status of the QuickBase server.
-
#onChangedDbid ⇒ Object
Reset appropriate member variables after a different table is accessed.
-
#parseResponseXML(xml) ⇒ Object
Called by processResponse to put the XML from QuickBase into a DOM tree using the REXML module that comes with Ruby.
-
#percent(inputValues) ⇒ Object
Given an array of two numbers, return the second number as a percentage of the first number.
-
#prependAPI?(request) ⇒ Boolean
Returns whether to prepend ‘API_’ to request string.
-
#printChildElements(element, indent = 0) ⇒ Object
Recursive method to print a simplified (yaml-like) tree of the XML returned by QuickBase.
-
#printLastError ⇒ Object
Prints the error info, if any, for the last request sent to QuickBase.
-
#printRequest(url, headers, xml) ⇒ Object
Called by sendRequest if @printRequestsAndResponses is true.
-
#printResponse(code, xml) ⇒ Object
Called by sendRequest if @printRequestsAndResponses is true.
-
#processChildElements(element, leafElementsOnly, block) ⇒ Object
Recursive method to process leaf and (optionally) parent elements of any XML element returned by QuickBase.
-
#processResponse(responseXML) ⇒ Object
Except for requests that return HTML, processes the XML responses returned from QuickBase.
- #processRESTFieldNameOrRecordKeyRequest(dbid, fieldNameOrRecordKey) ⇒ Object
-
#processRESTRequest(requestString) ⇒ Object
Returns table or record values using REST syntax.
-
#provisionUser(dbid, roleid, email, fname, lname) ⇒ Object
API_ProvisionUser.
-
#purgeRecords(dbid, query = nil, qid = nil, qname = nil) ⇒ Object
API_PurgeRecords.
-
#removeFileAttachment(dbid, rid, fileAttachmentFieldName) ⇒ Object
Remove the file from a File Attachment field in an existing record.
-
#removeUserFromRole(dbid, userid, roleid) ⇒ Object
API_RemoveUserFromRole.
-
#renameApp(dbid, newappname) ⇒ Object
API_RenameApp.
-
#replaceFieldValuePair(name, fid, filename, value) ⇒ Object
Replaces a field value in the list of fields to be set by the next addRecord() or editRecord() call to QuickBase.
-
#resetErrorInfo ⇒ Object
Resets error info before QuickBase requests are sent.
-
#resetfid ⇒ Object
Set the @fid (‘active’ field ID) member variable to nil.
-
#resetrid ⇒ Object
Set the @rid (‘active’ record ID) member variable to nil.
-
#runImport(dbid, id) ⇒ Object
API_RunImport.
-
#sendInvitation(dbid, userid, usertext = "Welcome to my application!") ⇒ Object
API_SendInvitation.
-
#sendRequest(api_Request, xmlRequestData = nil) ⇒ Object
Sends requests to QuickBase and processes the reponses.
-
#setActiveRecord(dbid, rid) ⇒ Object
Set the active database and record for subsequent method calls.
-
#setActiveTable(dbid) ⇒ Object
Set the active database table subsequent method calls.
-
#setAppData(dbid, appdata) ⇒ Object
API_SetAppData.
-
#setDBvar(dbid, varname, value) ⇒ Object
API_SetDBvar.
-
#setFieldProperties(dbid, properties, fid) ⇒ Object
API_SetFieldProperties.
-
#setFieldValue(fieldName, fieldValue, dbid = nil, rid = nil, key = nil) ⇒ Object
Change a named field’s value in the active record.
-
#setFieldValues(fields, editRecord = true) ⇒ Object
Set several named fields’ values.
-
#setHTTPConnection(useSSL, org = "www", domain = "quickbase", proxy_options = nil) ⇒ Object
Initializes the connection to QuickBase.
-
#setHTTPConnectionAndqbhost(useSSL, org = "www", domain = "quickbase", proxy_options = nil) ⇒ Object
Initializes the connection to QuickBase and sets the QuickBase URL and port to use for requests.
-
#setKeyField(dbid, fid) ⇒ Object
API_SetKeyField.
-
#setLogger(logger) ⇒ Object
Set the instance of a QuickBase::Logger to be used by QuickBase::Client.
-
#setqbhost(useSSL, org = "www", domain = "quickbase") ⇒ Object
Sets the QuickBase URL and port to use for requests.
-
#signOut ⇒ Object
API_SignOut.
-
#splitString(string, fieldSeparator = ",") ⇒ Object
shenley - gem’s method was flawed and removed nil values, used CSV lib to separate correctly.
-
#subscribe(event, handler) ⇒ Object
Subscribe to a specified event published by QuickBase::Client.
-
#sum(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Returns the sum of the values for one or more fields in the records returned by a query.
-
#toggleTraceInfo(showTrace) ⇒ Object
Turns program stack tracing on or off.
-
#toXML(tag, value = nil) ⇒ Object
Builds the XML for a specific item included in a request to QuickBase.
-
#updateFile(dbid, rid, filename, fileAttachmentFieldName, additionalFieldsToSet = nil) ⇒ Object
Update the file attachment in an existing record in a table.
-
#uploadFile(dbid, filename, fileAttachmentFieldName, additionalFieldsToSet = nil) ⇒ Object
Upload a file into a new record in a table.
-
#uploadFileContents(dbid, filename, fileContents, fileAttachmentFieldName, additionalFieldsToSet = nil) ⇒ Object
Add a File Attachment into a new record in a table, using a string containing the file contents.
-
#userRoles(dbid) ⇒ Object
API_UserRoles.
-
#verifyFieldList(fnames, fids = nil, dbid = @dbid) ⇒ Object
Given an array of field names or field IDs and a table ID, builds an array of valid field IDs and field names.
-
#verifyQueryOperator(operator, fieldType) ⇒ Object
Returns a valid query operator.
Constructor Details
#initialize(username = nil, password = nil, appname = nil, useSSL = true, printRequestsAndResponses = false, stopOnError = false, showTrace = false, org = "www", apptoken = nil, debugHTTPConnection = false, domain = "quickbase", proxy_options = nil) ⇒ Client
Set printRequestsAndResponses to true to view the XML sent to QuickBase and return from QuickBase. This can be very useful during debugging.
Set stopOnError to true to discontinue sending requests to QuickBase after an error has occured with a request. Set showTrace to true to view the complete stack trace of your running program. This should only be necessary as a last resort when a low-level exception has occurred.
To create an instance of QuickBase::Client using a Hash of options, use QuickBase::Client.init(options) instead of QuickBase::Client.new()
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/broker/client/QuickBaseClient.rb', line 83 def initialize( username = nil, password = nil, appname = nil, useSSL = true, printRequestsAndResponses = false, stopOnError = false, showTrace = false, org = "www", apptoken = nil, debugHTTPConnection = false, domain = "quickbase", = nil ) begin @org = org ? org : "www" @domain = domain ? domain : "quickbase" @apptoken = apptoken @printRequestsAndResponses = printRequestsAndResponses @stopOnError = stopOnError @escapeBR = @ignoreCR = @ignoreLF = @ignoreTAB = true toggleTraceInfo( showTrace ) if showTrace setHTTPConnectionAndqbhost( useSSL, org, domain, ) debugHTTPConnection() if debugHTTPConnection @standardRequestHeaders = { "Content-Type" => "application/xml" } if username and password authenticate( username, password ) if appname and @errcode == "0" findDBByname( appname ) if @dbid and @errcode == "0" getDBInfo( @dbid ) getSchema( @dbid ) end end end rescue Net::HTTPBadRequest => @lastError rescue Net::HTTPBadResponse => @lastError rescue Net::HTTPHeaderSyntaxError => @lastError rescue StandardError => @lastError end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(missing_method_name, *missing_method_args) ⇒ Object
Enables alternative syntax for processing data using id values or xml element names. E.g:
qbc.bcdcajmrh.qid_1.printChildElements(qbc.records)
-
prints the records returned by query 1 from table bcdcajmrh
puts qbc.bcdcajmrf.xml_desc
-
get the description from the bcdcajmrf application
puts qbc.dbid_8emtadvk.rid_24105.fid_6
-
print field 6 from record 24105 in table 8emtadvk
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
# File 'lib/broker/client/QuickBaseClient.rb', line 666 def method_missing(missing_method_name, *missing_method_args) method_s = missing_method_name.to_s if method_s.match(/dbid_.+/) if QuickBase::Misc.isDbidString?(method_s.sub("dbid_","")) getSchema(method_s.sub("dbid_","")) end elsif @dbid and method_s.match(/rid_[0-9]+/) _setActiveRecord(method_s.sub("rid_","")) @fieldValue = @field_data_list elsif @dbid and method_s.match(/qid_[0-9]+/) doQuery(@dbid,nil,method_s.sub("qid_","")) elsif @dbid and method_s.match(/fid_[0-9]+/) if @field_data_list @fieldValue = getFieldDataValue(method_s.sub("fid_","")) else lookupField(method_s.sub("fid_","")) end elsif @dbid and method_s.match(/pageid_[0-9]+/) _getDBPage(method_s.sub("pageid_","")) elsif @dbid and method_s.match(/userid_.+/) _getUserRole(method_s.sub("userid_","")) elsif @dbid and @rid and @fid and method_s.match(/vid_[0-9]+/) downLoadFile( @dbid, @rid, @fid, method_s.sub("vid_","") ) elsif @dbid and method_s.match(/import_[0-9]+/) _runImport(method_s.sub("import_","")) elsif @qdbapi and method_s.match(/xml_.+/) if missing_method_args and missing_method_args.length > 0 @fieldValue = @qdbapi.send(method_s.sub("xml_",""),missing_method_args) else @fieldValue = @qdbapi.send(method_s.sub("xml_","")) end elsif QuickBase::Misc.isDbidString?(method_s) getSchema(method_s) else raise "'#{method_s}' is not a valid method in the QuickBase::Client class." end return @fieldValue if @fieldValue.is_a?(REXML::Element) # chain XML lookups return @fieldValue if @fieldValue.is_a?(String) # assume we just want a field value self # otherwise, allows chaining of all above end |
Instance Attribute Details
#access ⇒ Object (readonly)
Returns the value of attribute access.
38 39 40 |
# File 'lib/broker/client/QuickBaseClient.rb', line 38 def access @access end |
#accessid ⇒ Object (readonly)
Returns the value of attribute accessid.
38 39 40 |
# File 'lib/broker/client/QuickBaseClient.rb', line 38 def accessid @accessid end |
#accountLimit ⇒ Object (readonly)
Returns the value of attribute accountLimit.
38 39 40 |
# File 'lib/broker/client/QuickBaseClient.rb', line 38 def accountLimit @accountLimit end |
#accountUsage ⇒ Object (readonly)
Returns the value of attribute accountUsage.
38 39 40 |
# File 'lib/broker/client/QuickBaseClient.rb', line 38 def accountUsage @accountUsage end |
#action ⇒ Object (readonly)
Returns the value of attribute action.
38 39 40 |
# File 'lib/broker/client/QuickBaseClient.rb', line 38 def action @action end |
#admin ⇒ Object (readonly)
Returns the value of attribute admin.
38 39 40 |
# File 'lib/broker/client/QuickBaseClient.rb', line 38 def admin @admin end |
#adminOnly ⇒ Object (readonly)
Returns the value of attribute adminOnly.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def adminOnly @adminOnly end |
#ancestorappid ⇒ Object (readonly)
Returns the value of attribute ancestorappid.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def ancestorappid @ancestorappid end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def app @app end |
#appdata ⇒ Object (readonly)
Returns the value of attribute appdata.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def appdata @appdata end |
#appdbid ⇒ Object (readonly)
Returns the value of attribute appdbid.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def appdbid @appdbid end |
#applicationLimit ⇒ Object (readonly)
Returns the value of attribute applicationLimit.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def applicationLimit @applicationLimit end |
#applicationUsage ⇒ Object (readonly)
Returns the value of attribute applicationUsage.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def applicationUsage @applicationUsage end |
#apptoken ⇒ Object
Returns the value of attribute apptoken.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def apptoken @apptoken end |
#authenticationXML ⇒ Object (readonly)
Returns the value of attribute authenticationXML.
39 40 41 |
# File 'lib/broker/client/QuickBaseClient.rb', line 39 def authenticationXML @authenticationXML end |
#cachedSchemas ⇒ Object (readonly)
Returns the value of attribute cachedSchemas.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def cachedSchemas @cachedSchemas end |
#cacheSchemas ⇒ Object
Returns the value of attribute cacheSchemas.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def cacheSchemas @cacheSchemas end |
#chdbids ⇒ Object (readonly)
Returns the value of attribute chdbids.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def chdbids @chdbids end |
#choice ⇒ Object (readonly)
Returns the value of attribute choice.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def choice @choice end |
#clist ⇒ Object (readonly)
Returns the value of attribute clist.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def clist @clist end |
#copyfid ⇒ Object (readonly)
Returns the value of attribute copyfid.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def copyfid @copyfid end |
#create ⇒ Object (readonly)
Returns the value of attribute create.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def create @create end |
#createapptoken ⇒ Object (readonly)
Returns the value of attribute createapptoken.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def createapptoken @createapptoken end |
#createdTime ⇒ Object (readonly)
Returns the value of attribute createdTime.
40 41 42 |
# File 'lib/broker/client/QuickBaseClient.rb', line 40 def createdTime @createdTime end |
#databases ⇒ Object (readonly)
Returns the value of attribute databases.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def databases @databases end |
#dbdesc ⇒ Object (readonly)
Returns the value of attribute dbdesc.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def dbdesc @dbdesc end |
#dbid ⇒ Object (readonly)
Returns the value of attribute dbid.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def dbid @dbid end |
#dbidForRequestURL ⇒ Object (readonly)
Returns the value of attribute dbidForRequestURL.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def dbidForRequestURL @dbidForRequestURL end |
#dbname ⇒ Object (readonly)
Returns the value of attribute dbname.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def dbname @dbname end |
#delete ⇒ Object (readonly)
Returns the value of attribute delete.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def delete @delete end |
#destrid ⇒ Object (readonly)
Returns the value of attribute destrid.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def destrid @destrid end |
#dfid ⇒ Object (readonly)
Returns the value of attribute dfid.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def dfid @dfid end |
#disprec ⇒ Object (readonly)
Returns the value of attribute disprec.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def disprec @disprec end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def domain @domain end |
#downLoadFileURL ⇒ Object (readonly)
Returns the value of attribute downLoadFileURL.
41 42 43 |
# File 'lib/broker/client/QuickBaseClient.rb', line 41 def downLoadFileURL @downLoadFileURL end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def email @email end |
#encoding=(value) ⇒ Object (writeonly)
Sets the attribute encoding
66 67 68 |
# File 'lib/broker/client/QuickBaseClient.rb', line 66 def encoding=(value) @encoding = value end |
#errcode ⇒ Object (readonly)
Returns the value of attribute errcode.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def errcode @errcode end |
#errdetail ⇒ Object (readonly)
Returns the value of attribute errdetail.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def errdetail @errdetail end |
#errtext ⇒ Object (readonly)
Returns the value of attribute errtext.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def errtext @errtext end |
#escapeBR=(value) ⇒ Object (writeonly)
Sets the attribute escapeBR
65 66 67 |
# File 'lib/broker/client/QuickBaseClient.rb', line 65 def escapeBR=(value) @escapeBR = value end |
#eventSubscribers ⇒ Object (readonly)
Returns the value of attribute eventSubscribers.
63 64 65 |
# File 'lib/broker/client/QuickBaseClient.rb', line 63 def eventSubscribers @eventSubscribers end |
#excludeparents ⇒ Object (readonly)
Returns the value of attribute excludeparents.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def excludeparents @excludeparents end |
#externalAuth ⇒ Object (readonly)
Returns the value of attribute externalAuth.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def externalAuth @externalAuth end |
#fform ⇒ Object (readonly)
Returns the value of attribute fform.
42 43 44 |
# File 'lib/broker/client/QuickBaseClient.rb', line 42 def fform @fform end |
#fid ⇒ Object (readonly)
Returns the value of attribute fid.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fid @fid end |
#fids ⇒ Object (readonly)
Returns the value of attribute fids.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fids @fids end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def field @field end |
#field_data ⇒ Object (readonly)
Returns the value of attribute field_data.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def field_data @field_data end |
#field_data_list ⇒ Object (readonly)
Returns the value of attribute field_data_list.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def field_data_list @field_data_list end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fields @fields end |
#fieldTypeLabelMap ⇒ Object (readonly)
Returns the value of attribute fieldTypeLabelMap.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fieldTypeLabelMap @fieldTypeLabelMap end |
#fieldValue ⇒ Object (readonly)
Returns the value of attribute fieldValue.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fieldValue @fieldValue end |
#fileContents ⇒ Object (readonly)
Returns the value of attribute fileContents.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fileContents @fileContents end |
#fileUploadToken ⇒ Object (readonly)
Returns the value of attribute fileUploadToken.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fileUploadToken @fileUploadToken end |
#firstName ⇒ Object (readonly)
Returns the value of attribute firstName.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def firstName @firstName end |
#fmt ⇒ Object (readonly)
Returns the value of attribute fmt.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fmt @fmt end |
#fname ⇒ Object (readonly)
Returns the value of attribute fname.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fname @fname end |
#fnames ⇒ Object (readonly)
Returns the value of attribute fnames.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fnames @fnames end |
#fvlist ⇒ Object
Returns the value of attribute fvlist.
43 44 45 |
# File 'lib/broker/client/QuickBaseClient.rb', line 43 def fvlist @fvlist end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
44 45 46 |
# File 'lib/broker/client/QuickBaseClient.rb', line 44 def hours @hours end |
#HTML ⇒ Object (readonly)
Returns the value of attribute HTML.
44 45 46 |
# File 'lib/broker/client/QuickBaseClient.rb', line 44 def HTML @HTML end |
#httpConnection ⇒ Object
Returns the value of attribute httpConnection.
44 45 46 |
# File 'lib/broker/client/QuickBaseClient.rb', line 44 def httpConnection @httpConnection end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
44 45 46 |
# File 'lib/broker/client/QuickBaseClient.rb', line 44 def id @id end |
#ignoreCR=(value) ⇒ Object (writeonly)
Sets the attribute ignoreCR
65 66 67 |
# File 'lib/broker/client/QuickBaseClient.rb', line 65 def ignoreCR=(value) @ignoreCR = value end |
#ignoreError ⇒ Object (readonly)
Returns the value of attribute ignoreError.
44 45 46 |
# File 'lib/broker/client/QuickBaseClient.rb', line 44 def ignoreError @ignoreError end |
#ignoreLF=(value) ⇒ Object (writeonly)
Sets the attribute ignoreLF
65 66 67 |
# File 'lib/broker/client/QuickBaseClient.rb', line 65 def ignoreLF=(value) @ignoreLF = value end |
#ignoreTAB=(value) ⇒ Object (writeonly)
Sets the attribute ignoreTAB
65 66 67 |
# File 'lib/broker/client/QuickBaseClient.rb', line 65 def ignoreTAB=(value) @ignoreTAB = value end |
#includeancestors ⇒ Object (readonly)
Returns the value of attribute includeancestors.
44 45 46 |
# File 'lib/broker/client/QuickBaseClient.rb', line 44 def includeancestors @includeancestors end |
#jht ⇒ Object (readonly)
Returns the value of attribute jht.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def jht @jht end |
#jsa ⇒ Object (readonly)
Returns the value of attribute jsa.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def jsa @jsa end |
#keepData ⇒ Object (readonly)
Returns the value of attribute keepData.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def keepData @keepData end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def key @key end |
#key_fid ⇒ Object (readonly)
Returns the value of attribute key_fid.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def key_fid @key_fid end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def label @label end |
#lastAccessTime ⇒ Object (readonly)
Returns the value of attribute lastAccessTime.
45 46 47 |
# File 'lib/broker/client/QuickBaseClient.rb', line 45 def lastAccessTime @lastAccessTime end |
#lastError ⇒ Object (readonly)
Returns the value of attribute lastError.
46 47 48 |
# File 'lib/broker/client/QuickBaseClient.rb', line 46 def lastError @lastError end |
#lastModifiedTime ⇒ Object (readonly)
Returns the value of attribute lastModifiedTime.
46 47 48 |
# File 'lib/broker/client/QuickBaseClient.rb', line 46 def lastModifiedTime @lastModifiedTime end |
#lastName ⇒ Object (readonly)
Returns the value of attribute lastName.
46 47 48 |
# File 'lib/broker/client/QuickBaseClient.rb', line 46 def lastName @lastName end |
#lastPaymentDate ⇒ Object (readonly)
Returns the value of attribute lastPaymentDate.
46 47 48 |
# File 'lib/broker/client/QuickBaseClient.rb', line 46 def lastPaymentDate @lastPaymentDate end |
#lastRecModTime ⇒ Object (readonly)
Returns the value of attribute lastRecModTime.
46 47 48 |
# File 'lib/broker/client/QuickBaseClient.rb', line 46 def lastRecModTime @lastRecModTime end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
63 64 65 |
# File 'lib/broker/client/QuickBaseClient.rb', line 63 def logger @logger end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
46 47 48 |
# File 'lib/broker/client/QuickBaseClient.rb', line 46 def login @login end |
#mgrID ⇒ Object (readonly)
Returns the value of attribute mgrID.
47 48 49 |
# File 'lib/broker/client/QuickBaseClient.rb', line 47 def mgrID @mgrID end |
#mgrName ⇒ Object (readonly)
Returns the value of attribute mgrName.
47 48 49 |
# File 'lib/broker/client/QuickBaseClient.rb', line 47 def mgrName @mgrName end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
47 48 49 |
# File 'lib/broker/client/QuickBaseClient.rb', line 47 def mode @mode end |
#modify ⇒ Object (readonly)
Returns the value of attribute modify.
47 48 49 |
# File 'lib/broker/client/QuickBaseClient.rb', line 47 def modify @modify end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
47 48 49 |
# File 'lib/broker/client/QuickBaseClient.rb', line 47 def name @name end |
#newappname ⇒ Object (readonly)
Returns the value of attribute newappname.
48 49 50 |
# File 'lib/broker/client/QuickBaseClient.rb', line 48 def newappname @newappname end |
#newdbdesc ⇒ Object (readonly)
Returns the value of attribute newdbdesc.
48 49 50 |
# File 'lib/broker/client/QuickBaseClient.rb', line 48 def newdbdesc @newdbdesc end |
#newdbid ⇒ Object (readonly)
Returns the value of attribute newdbid.
48 49 50 |
# File 'lib/broker/client/QuickBaseClient.rb', line 48 def newdbid @newdbid end |
#newdbname ⇒ Object (readonly)
Returns the value of attribute newdbname.
48 49 50 |
# File 'lib/broker/client/QuickBaseClient.rb', line 48 def newdbname @newdbname end |
#newowner ⇒ Object (readonly)
Returns the value of attribute newowner.
48 49 50 |
# File 'lib/broker/client/QuickBaseClient.rb', line 48 def newowner @newowner end |
#num_fields ⇒ Object (readonly)
Returns the value of attribute num_fields.
49 50 51 |
# File 'lib/broker/client/QuickBaseClient.rb', line 49 def num_fields @num_fields end |
#num_records ⇒ Object (readonly)
Returns the value of attribute num_records.
49 50 51 |
# File 'lib/broker/client/QuickBaseClient.rb', line 49 def num_records @num_records end |
#num_records_deleted ⇒ Object (readonly)
Returns the value of attribute num_records_deleted.
49 50 51 |
# File 'lib/broker/client/QuickBaseClient.rb', line 49 def num_records_deleted @num_records_deleted end |
#num_recs_added ⇒ Object (readonly)
Returns the value of attribute num_recs_added.
49 50 51 |
# File 'lib/broker/client/QuickBaseClient.rb', line 49 def num_recs_added @num_recs_added end |
#num_recs_input ⇒ Object (readonly)
Returns the value of attribute num_recs_input.
50 51 52 |
# File 'lib/broker/client/QuickBaseClient.rb', line 50 def num_recs_input @num_recs_input end |
#num_recs_updated ⇒ Object (readonly)
Returns the value of attribute num_recs_updated.
50 51 52 |
# File 'lib/broker/client/QuickBaseClient.rb', line 50 def num_recs_updated @num_recs_updated end |
#numadded ⇒ Object (readonly)
Returns the value of attribute numadded.
50 51 52 |
# File 'lib/broker/client/QuickBaseClient.rb', line 50 def numadded @numadded end |
#numCreated ⇒ Object (readonly)
Returns the value of attribute numCreated.
50 51 52 |
# File 'lib/broker/client/QuickBaseClient.rb', line 50 def numCreated @numCreated end |
#numMatches ⇒ Object (readonly)
Returns the value of attribute numMatches.
49 50 51 |
# File 'lib/broker/client/QuickBaseClient.rb', line 49 def numMatches @numMatches end |
#numRecords ⇒ Object (readonly)
Returns the value of attribute numRecords.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def numRecords @numRecords end |
#numremoved ⇒ Object (readonly)
Returns the value of attribute numremoved.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def numremoved @numremoved end |
#oldestancestorappid ⇒ Object (readonly)
Returns the value of attribute oldestancestorappid.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def oldestancestorappid @oldestancestorappid end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def @options end |
#org ⇒ Object (readonly)
Returns the value of attribute org.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def org @org end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def page @page end |
#pagebody ⇒ Object (readonly)
Returns the value of attribute pagebody.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def pagebody @pagebody end |
#pageid ⇒ Object (readonly)
Returns the value of attribute pageid.
52 53 54 |
# File 'lib/broker/client/QuickBaseClient.rb', line 52 def pageid @pageid end |
#pagename ⇒ Object (readonly)
Returns the value of attribute pagename.
52 53 54 |
# File 'lib/broker/client/QuickBaseClient.rb', line 52 def pagename @pagename end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
51 52 53 |
# File 'lib/broker/client/QuickBaseClient.rb', line 51 def pages @pages end |
#pagetype ⇒ Object (readonly)
Returns the value of attribute pagetype.
52 53 54 |
# File 'lib/broker/client/QuickBaseClient.rb', line 52 def pagetype @pagetype end |
#parentrid ⇒ Object (readonly)
Returns the value of attribute parentrid.
52 53 54 |
# File 'lib/broker/client/QuickBaseClient.rb', line 52 def parentrid @parentrid end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
52 53 54 |
# File 'lib/broker/client/QuickBaseClient.rb', line 52 def password @password end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
52 53 54 |
# File 'lib/broker/client/QuickBaseClient.rb', line 52 def @permissions end |
#printRequestsAndResponses ⇒ Object
Returns the value of attribute printRequestsAndResponses.
53 54 55 |
# File 'lib/broker/client/QuickBaseClient.rb', line 53 def printRequestsAndResponses @printRequestsAndResponses end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
53 54 55 |
# File 'lib/broker/client/QuickBaseClient.rb', line 53 def properties @properties end |
#qarancestorappid ⇒ Object (readonly)
Returns the value of attribute qarancestorappid.
53 54 55 |
# File 'lib/broker/client/QuickBaseClient.rb', line 53 def qarancestorappid @qarancestorappid end |
#qbhost ⇒ Object
Returns the value of attribute qbhost.
53 54 55 |
# File 'lib/broker/client/QuickBaseClient.rb', line 53 def qbhost @qbhost end |
#qdbapi ⇒ Object (readonly)
Returns the value of attribute qdbapi.
53 54 55 |
# File 'lib/broker/client/QuickBaseClient.rb', line 53 def qdbapi @qdbapi end |
#qid ⇒ Object (readonly)
Returns the value of attribute qid.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def qid @qid end |
#qname ⇒ Object (readonly)
Returns the value of attribute qname.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def qname @qname end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def queries @queries end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def query @query end |
#rdr=(value) ⇒ Object (writeonly)
Sets the attribute rdr
66 67 68 |
# File 'lib/broker/client/QuickBaseClient.rb', line 66 def rdr=(value) @rdr = value end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def record @record end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def records @records end |
#records_csv ⇒ Object (readonly)
Returns the value of attribute records_csv.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def records_csv @records_csv end |
#recurse ⇒ Object (readonly)
Returns the value of attribute recurse.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def recurse @recurse end |
#relfids ⇒ Object (readonly)
Returns the value of attribute relfids.
54 55 56 |
# File 'lib/broker/client/QuickBaseClient.rb', line 54 def relfids @relfids end |
#requestHeaders ⇒ Object (readonly)
Returns the value of attribute requestHeaders.
55 56 57 |
# File 'lib/broker/client/QuickBaseClient.rb', line 55 def requestHeaders @requestHeaders end |
#requestNextAllowedTime ⇒ Object (readonly)
Returns the value of attribute requestNextAllowedTime.
55 56 57 |
# File 'lib/broker/client/QuickBaseClient.rb', line 55 def requestNextAllowedTime @requestNextAllowedTime end |
#requestSucceeded ⇒ Object (readonly)
Returns the value of attribute requestSucceeded.
55 56 57 |
# File 'lib/broker/client/QuickBaseClient.rb', line 55 def requestSucceeded @requestSucceeded end |
#requestTime ⇒ Object (readonly)
Returns the value of attribute requestTime.
55 56 57 |
# File 'lib/broker/client/QuickBaseClient.rb', line 55 def requestTime @requestTime end |
#requestURL ⇒ Object (readonly)
Returns the value of attribute requestURL.
55 56 57 |
# File 'lib/broker/client/QuickBaseClient.rb', line 55 def requestURL @requestURL end |
#requestXML ⇒ Object (readonly)
Returns the value of attribute requestXML.
55 56 57 |
# File 'lib/broker/client/QuickBaseClient.rb', line 55 def requestXML @requestXML end |
#responseElement ⇒ Object (readonly)
Returns the value of attribute responseElement.
56 57 58 |
# File 'lib/broker/client/QuickBaseClient.rb', line 56 def responseElement @responseElement end |
#responseElements ⇒ Object (readonly)
Returns the value of attribute responseElements.
56 57 58 |
# File 'lib/broker/client/QuickBaseClient.rb', line 56 def responseElements @responseElements end |
#responseElementText ⇒ Object (readonly)
Returns the value of attribute responseElementText.
56 57 58 |
# File 'lib/broker/client/QuickBaseClient.rb', line 56 def responseElementText @responseElementText end |
#responseXML ⇒ Object (readonly)
Returns the value of attribute responseXML.
56 57 58 |
# File 'lib/broker/client/QuickBaseClient.rb', line 56 def responseXML @responseXML end |
#responseXMLdoc ⇒ Object (readonly)
Returns the value of attribute responseXMLdoc.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def responseXMLdoc @responseXMLdoc end |
#rid ⇒ Object (readonly)
Returns the value of attribute rid.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def rid @rid end |
#rids ⇒ Object (readonly)
Returns the value of attribute rids.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def rids @rids end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def role @role end |
#roleid ⇒ Object (readonly)
Returns the value of attribute roleid.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def roleid @roleid end |
#rolename ⇒ Object (readonly)
Returns the value of attribute rolename.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def rolename @rolename end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def roles @roles end |
#saveviews ⇒ Object (readonly)
Returns the value of attribute saveviews.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def saveviews @saveviews end |
#screenName ⇒ Object (readonly)
Returns the value of attribute screenName.
57 58 59 |
# File 'lib/broker/client/QuickBaseClient.rb', line 57 def screenName @screenName end |
#serverDatabases ⇒ Object (readonly)
Returns the value of attribute serverDatabases.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverDatabases @serverDatabases end |
#serverGroups ⇒ Object (readonly)
Returns the value of attribute serverGroups.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverGroups @serverGroups end |
#serverStatus ⇒ Object (readonly)
Returns the value of attribute serverStatus.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverStatus @serverStatus end |
#serverUpdays ⇒ Object (readonly)
Returns the value of attribute serverUpdays.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverUpdays @serverUpdays end |
#serverUptime ⇒ Object (readonly)
Returns the value of attribute serverUptime.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverUptime @serverUptime end |
#serverUsers ⇒ Object (readonly)
Returns the value of attribute serverUsers.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverUsers @serverUsers end |
#serverVersion ⇒ Object (readonly)
Returns the value of attribute serverVersion.
58 59 60 |
# File 'lib/broker/client/QuickBaseClient.rb', line 58 def serverVersion @serverVersion end |
#showAppData ⇒ Object (readonly)
Returns the value of attribute showAppData.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def showAppData @showAppData end |
#skipfirst ⇒ Object (readonly)
Returns the value of attribute skipfirst.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def skipfirst @skipfirst end |
#slist ⇒ Object (readonly)
Returns the value of attribute slist.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def slist @slist end |
#sourcerid ⇒ Object (readonly)
Returns the value of attribute sourcerid.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def sourcerid @sourcerid end |
#standardRequestHeaders ⇒ Object (readonly)
Returns the value of attribute standardRequestHeaders.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def standardRequestHeaders @standardRequestHeaders end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def status @status end |
#stopOnError ⇒ Object
Returns the value of attribute stopOnError.
59 60 61 |
# File 'lib/broker/client/QuickBaseClient.rb', line 59 def stopOnError @stopOnError end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def table @table end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def tables @tables end |
#ticket ⇒ Object
Returns the value of attribute ticket.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def ticket @ticket end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def type @type end |
#udata ⇒ Object
Returns the value of attribute udata.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def udata @udata end |
#uname ⇒ Object (readonly)
Returns the value of attribute uname.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def uname @uname end |
#update_id ⇒ Object (readonly)
Returns the value of attribute update_id.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def update_id @update_id end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def user @user end |
#userid ⇒ Object (readonly)
Returns the value of attribute userid.
60 61 62 |
# File 'lib/broker/client/QuickBaseClient.rb', line 60 def userid @userid end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
61 62 63 |
# File 'lib/broker/client/QuickBaseClient.rb', line 61 def username @username end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
61 62 63 |
# File 'lib/broker/client/QuickBaseClient.rb', line 61 def users @users end |
#validFieldProperties ⇒ Object (readonly)
Returns the value of attribute validFieldProperties.
61 62 63 |
# File 'lib/broker/client/QuickBaseClient.rb', line 61 def validFieldProperties @validFieldProperties end |
#validFieldTypes ⇒ Object (readonly)
Returns the value of attribute validFieldTypes.
61 62 63 |
# File 'lib/broker/client/QuickBaseClient.rb', line 61 def validFieldTypes @validFieldTypes end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
61 62 63 |
# File 'lib/broker/client/QuickBaseClient.rb', line 61 def value @value end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
61 62 63 |
# File 'lib/broker/client/QuickBaseClient.rb', line 61 def variables @variables end |
#varname ⇒ Object (readonly)
Returns the value of attribute varname.
62 63 64 |
# File 'lib/broker/client/QuickBaseClient.rb', line 62 def varname @varname end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
62 63 64 |
# File 'lib/broker/client/QuickBaseClient.rb', line 62 def version @version end |
#vid ⇒ Object (readonly)
Returns the value of attribute vid.
62 63 64 |
# File 'lib/broker/client/QuickBaseClient.rb', line 62 def vid @vid end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
62 63 64 |
# File 'lib/broker/client/QuickBaseClient.rb', line 62 def view @view end |
#withembeddedtables ⇒ Object (readonly)
Returns the value of attribute withembeddedtables.
62 63 64 |
# File 'lib/broker/client/QuickBaseClient.rb', line 62 def @withembeddedtables end |
#xsl=(value) ⇒ Object (writeonly)
Sets the attribute xsl
66 67 68 |
# File 'lib/broker/client/QuickBaseClient.rb', line 66 def xsl=(value) @xsl = value end |
Class Method Details
.init(options) ⇒ Object
Class method to create an instance of QuickBase::Client using a Hash of parameters. E.g. qbc = QuickBase::Client.init( { “stopOnError” => true, “printRequestsAndResponses” => true } )
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/broker/client/QuickBaseClient.rb', line 126 def Client.init( ) ||= {} ["useSSL"] ||= true ["printRequestsAndResponses"] ||= false ["stopOnError"] ||= false ["showTrace"] ||= false ["org"] ||= "www" ["debugHTTPConnection"] ||= false ["domain"] ||= "quickbase" ["proxy_options"] ||= nil instance = Client.new( ["username"], ["password"], ["appname"], ["useSSL"], ["printRequestsAndResponses"], ["stopOnError"], ["showTrace"], ["org"], ["apptoken"], ["debugHTTPConnection"], ["domain"], ["proxy_options"]) end |
.processDatabase(username, password, appname, chainAPIcalls = nil) ⇒ Object
-
creates a QuickBase::Client,
-
signs into QuickBase
-
connects to a specific application
-
runs code in the associated block
-
signs out of QuickBase
e.g. QuickBase::Client.processDatabase( “user”, “password”, “my DB” ) { |qbClient,dbid| qbClient.getDBInfo( dbid ) }
-
3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3167 def Client.processDatabase( username, password, appname, chainAPIcalls = nil ) if username and password and appname and block_given? begin qbClient = Client.new( username, password, appname ) @chainAPIcalls = chainAPIcalls yield qbClient, qbClient.dbid rescue StandardError ensure qbClient.signOut @chainAPIcalls = nil end end end |
Instance Method Details
#_addField(label, type, mode = nil) ⇒ Object
API_AddField, using the active table id.
1692 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1692 def _addField( label, type, mode = nil ) addField( @dbid, label, type, mode ) end |
#_addRecord(fvlist = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil) ⇒ Object
API_AddRecord, using the active table id.
1721 1722 1723 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1721 def _addRecord( fvlist = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil ) addRecord( @dbid, fvlist, disprec, fform, ignoreError, update_id ) end |
#_addReplaceDBPage(*args) ⇒ Object
API_AddReplaceDBPage, using the active table id.
1752 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1752 def _addReplaceDBPage( *args ) addReplaceDBPage( @dbid, args ) end |
#_addUserToRole(userid, roleid) ⇒ Object
API_AddUserToRole, using the active table id.
1768 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1768 def _addUserToRole( userid, roleid ) addUserToRole( @dbid, userid, roleid ) end |
#_changePermission(*args) ⇒ Object
API_ChangePermission (appears to be deprecated), using the active table id.
1913 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1913 def _changePermission( *args ) changePermission( @dbid, args ) end |
#_changeRecordOwner(rid, newowner) ⇒ Object
API_ChangeRecordOwner
1931 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1931 def _changeRecordOwner( rid, newowner ) changeRecordOwner( @dbid, rid, newowner ) end |
#_changeUserRole(userid, roleid, newroleid) ⇒ Object
API_ChangeUserRole, using the active table id.
1948 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1948 def _changeUserRole( userid, roleid, newroleid ) changeUserRole( @dbid, userid, roleid, newroleid ) end |
#_childElementsAsString ⇒ Object
635 |
# File 'lib/broker/client/QuickBaseClient.rb', line 635 def _childElementsAsString() childElementsAsString( @qdbapi ) end |
#_cloneDatabase(*args) ⇒ Object
API_CloneDatabase, using the active table id.
1973 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1973 def _cloneDatabase( *args ) cloneDatabase( @dbid, args ) end |
#_copyMasterDetail(*args) ⇒ Object
API_CopyMasterDetail, using the active table id.
1998 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1998 def _copyMasterDetail( *args ) copyMasterDetail( @dbid, args ) end |
#_deleteDatabase ⇒ Object
API_DeleteDatabase, using the active table id.
2048 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2048 def _deleteDatabase() deleteDatabase( @dbid ) end |
#_deleteField(fid) ⇒ Object
API_DeleteField, using the active table id.
2062 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2062 def _deleteField( fid ) deleteField( @dbid, fid ) end |
#_deleteFieldName(fieldName) ⇒ Object
Delete a field, using its name instead of its id. Uses the active table id.
2065 2066 2067 2068 2069 2070 2071 2072 2073 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2065 def _deleteFieldName( fieldName ) if @dbid and @fields @fid = lookupFieldIDByName( fieldName ) if @fid deleteField( @dbid, @fid ) end end nil end |
#_deleteRecord(rid) ⇒ Object
API_DeleteRecord, using the active table id.
2087 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2087 def _deleteRecord( rid ) deleteRecord( @dbid, rid ) end |
#_doQuery(*args) ⇒ Object
API_DoQuery, using the active table id.
2134 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2134 def _doQuery( *args ) doQuery( @dbid, args ) end |
#_doQueryCount(query) ⇒ Object
API_DoQueryCount, using the active table id.
2170 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2170 def _doQueryCount( query ) doQueryCount( @dbid, query ) end |
#_doQueryHash(doQueryOptions) ⇒ Object
version of doQuery that takes a Hash of parameters
2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2140 def _doQueryHash( doQueryOptions ) doQueryOptions ||= {} raise "options must be a Hash" unless doQueryOptions.is_a?(Hash) doQueryOptions["dbid"] ||= @dbid doQueryOptions["fmt"] ||= "structured" doQuery( doQueryOptions["dbid"], doQueryOptions["query"], doQueryOptions["qid"], doQueryOptions["qname"], doQueryOptions["clist"], doQueryOptions["slist"], doQueryOptions["fmt"], doQueryOptions["options"] ) end |
#_doQueryName(queryName) ⇒ Object
Runs API_DoQuery using the name of a query. Uses the active table id .
2137 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2137 def _doQueryName( queryName ) doQuery( @dbid, nil, nil, queryName ) end |
#_downLoadFile(rid, fid, vid = "0") ⇒ Object Also known as: _downloadFile
Download a file’s contents from a file attachment field in QuickBase. You must write the contents to disk before a local file exists. Uses the active table id.
2222 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2222 def _downLoadFile( rid, fid, vid = "0" ) downLoadFile( @dbid, rid, fid, vid ) end |
#_editRecord(*args) ⇒ Object
API_EditRecord, using the active table id.
2270 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2270 def _editRecord( *args ) editRecord( @dbid, args ) end |
#_fieldAddChoices(fid, choice) ⇒ Object
API_FieldAddChoices, using the active table id.
2297 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2297 def _fieldAddChoices( fid, choice ) fieldAddChoices( @dbid, fid, choice ) end |
#_fieldNameAddChoices(fieldName, choice) ⇒ Object
Runs API_FieldAddChoices using a field name instead ofa field id. Uses the active table id. Expects getSchema to have been run.
2301 2302 2303 2304 2305 2306 2307 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2301 def _fieldNameAddChoices( fieldName, choice ) if fieldName and choice and @fields @fid = lookupFieldIDByName( fieldName ) fieldAddChoices( @dbid, @fid, choice ) end nil end |
#_fieldNameRemoveChoices(fieldName, choice) ⇒ Object
Runs API_FieldRemoveChoices using a field name instead of a field id. Uses the active table id.
2337 2338 2339 2340 2341 2342 2343 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2337 def _fieldNameRemoveChoices( fieldName, choice ) if fieldName and choice and @fields @fid = lookupFieldIDByName( fieldName ) fieldRemoveChoices( @dbid, @fid, choice ) end nil end |
#_fieldRemoveChoices(fid, choice) ⇒ Object
API_FieldRemoveChoices, using the active table id.
2334 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2334 def _fieldRemoveChoices( fid, choice ) fieldRemoveChoices( @dbid, fid, choice ) end |
#_genAddRecordForm(fvlist = nil) ⇒ Object
API_GenAddRecordForm, using the active table id.
2376 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2376 def _genAddRecordForm( fvlist = nil ) genAddRecordForm( @dbid, fvlist ) end |
#_genResultsTable(*args) ⇒ Object
API_GenResultsTable, using the active table id.
2402 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2402 def _genResultsTable( *args ) genResultsTable( @dbid, args ) end |
#_getAncestorInfo ⇒ Object
2418 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2418 def _getAncestorInfo() getAncestorInfo(@dbid) end |
#_getAppDTMInfo ⇒ Object
API_GetAppDTMInfo, using the active table id.
2444 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2444 def _getAppDTMInfo() getAppDTMInfo( @dbid ) end |
#_getBillingStatus ⇒ Object
API_GetBillingStatus, using the active table id.
2460 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2460 def _getBillingStatus() getBillingStatus(@dbid) end |
#_getDBInfo ⇒ Object
API_GetDBInfo, using the active table id.
2483 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2483 def _getDBInfo() getDBInfo( @dbid ) end |
#_getDBPage(pageid, pagename = nil) ⇒ Object
API_GetDBPage, using the active table id.
2508 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2508 def _getDBPage( pageid, pagename = nil ) getDBPage( @dbid, pageid, pagename ) end |
#_getDBvar(varname) ⇒ Object
API_GetDBVar, using the active table id.
2525 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2525 def _getDBvar( varname ) getDBvar( @dbid, varname ) end |
#_getEntitlementValues ⇒ Object
API_GetEntitlementValues, using the active table id.
2546 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2546 def _getEntitlementValues() getEntitlementValues( @dbid ) end |
#_getFileAttachmentUsage ⇒ Object
API_GetFileAttachmentUsage, using the active table id.
2564 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2564 def _getFileAttachmentUsage() getFileAttachmentUsage( @dbid ) end |
#_getNumRecords ⇒ Object
API_GetNumRecords, using the active table id.
2578 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2578 def _getNumRecords() getNumRecords( @dbid ) end |
#_getRecordAsHTML(rid, jht = nil, dfid = nil) ⇒ Object
API_GetRecordAsHTML, using the active table id.
2622 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2622 def _getRecordAsHTML( rid, jht = nil, dfid = nil ) getRecordAsHTML( @dbid, rid, jht, dfid ) end |
#_getRecordInfo(rid = @rid) ⇒ Object
API_GetRecordInfo, using the active table id.
2648 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2648 def _getRecordInfo( rid = @rid ) getRecordInfo( @dbid, rid ) end |
#_getRoleInfo ⇒ Object
API_GetRoleInfo, using the active table id.
2674 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2674 def _getRoleInfo() getRoleInfo( @dbid ) end |
#_getSchema ⇒ Object
API_GetSchema, using the active table id.
2708 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2708 def _getSchema() getSchema( @dbid ) end |
#_getUserRole(userid, inclgrps = nil) ⇒ Object
API_GetUserRole, using the active table id.
2786 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2786 def _getUserRole( userid, inclgrps = nil ) getUserRole( @dbid, userid, inclgrps ) end |
#_importFromCSV(*args) ⇒ Object
API_ImportFromCSV, using the active table id.
2842 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2842 def _importFromCSV( *args ) importFromCSV( @dbid, args ) end |
#_importFromExcel(excelFilename, lastColumn = 'j', lastDataRow = 0, worksheetNumber = 1, fieldNameRow = 1, firstDataRow = 2, firstColumn = 'a') ⇒ Object
Import data directly from an Excel file into the active table.
4390 4391 4392 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4390 def _importFromExcel(excelFilename,lastColumn = 'j',lastDataRow = 0,worksheetNumber = 1,fieldNameRow = 1,firstDataRow = 2,firstColumn = 'a') importFromExcel( @dbid, excelFilename, lastColumn, lastDataRow, worksheetNumber, fieldNameRow, firstDataRow, firstColumn ) end |
#_listDBPages ⇒ Object
API_ListDBPages, using the active table id.
2872 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2872 def _listDBPages() listDBPages(@dbid) end |
#_printChildElements ⇒ Object
608 |
# File 'lib/broker/client/QuickBaseClient.rb', line 608 def _printChildElements() printChildElements( @qdbapi ) end |
#_provisionUser(roleid, email, fname, lname) ⇒ Object
API_ProvisionUser, using the active table id.
2892 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2892 def _provisionUser( roleid, email, fname, lname ) provisionUser( @dbid, roleid, email, fname, lname ) end |
#_purgeRecords(query = nil, qid = nil, qname = nil) ⇒ Object
API_PurgeRecords, using the active table id.
2906 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2906 def _purgeRecords( query = nil, qid = nil, qname = nil ) purgeRecords( @dbid, query, qid, qname ) end |
#_removeFileAttachment(rid, fileAttachmentFieldName) ⇒ Object
Remove the file from a File Attachment field in an existing record in the active table e.g. _removeFileAttachment( “6”, “Document” )
4647 4648 4649 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4647 def _removeFileAttachment( rid , fileAttachmentFieldName ) updateFile( @dbid, rid, "delete", fileAttachmentFieldName ) end |
#_removeUserFromRole(userid, roleid) ⇒ Object
API_RemoveUserFromRole, using the active table id.
2922 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2922 def _removeUserFromRole( userid, roleid ) removeUserFromRole( @dbid, userid, roleid ) end |
#_renameApp(newappname) ⇒ Object
API_RenameApp, using the active table id.
2937 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2937 def _renameApp( newappname ) renameApp( @dbid, newappname ) end |
#_runImport(id) ⇒ Object
API_RunImport, using the active table id.
2952 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2952 def _runImport( id ) runImport( @dbid, id ) end |
#_sendInvitation(userid, usertext = "Welcome to my application!") ⇒ Object
API_SendInvitation, using the active table id.
2968 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2968 def _sendInvitation( userid, usertext = "Welcome to my application!" ) sendInvitation( @dbid, userid, usertext ) end |
#_setActiveRecord(rid) ⇒ Object
3212 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3212 def _setActiveRecord( rid ) setActiveRecord( @dbid, rid ) end |
#_setAppData(appdata) ⇒ Object
API_SetAppData, using the active table id.
2983 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2983 def _setAppData( appdata ) setAppData( @dbid, appdata ) end |
#_setDBvar(varname, value) ⇒ Object
API_SetDBvar, using the active table id.
2999 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2999 def _setDBvar( varname, value ) setDBvar( @dbid, varname, value ) end |
#_setFieldProperties(properties, fid) ⇒ Object
API_SetFieldProperties, using the active table id.
3028 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3028 def _setFieldProperties( properties, fid ) setFieldProperties( @dbid, properties, fid ) end |
#_setKeyField(fid) ⇒ Object
API_SetKeyField, using the active table id.
3043 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3043 def _setKeyField(fid) setKeyField( @dbid, fid ) end |
#_updateFile(filename, fileAttachmentFieldName) ⇒ Object
Update the file attachment in an existing record in the active record in the active table. e.g. _updateFile( “contacts.txt”, “Contacts File” )
4635 4636 4637 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4635 def _updateFile( filename, fileAttachmentFieldName ) updateFile( @dbid, @rid, filename, fileAttachmentFieldName ) end |
#_uploadFile(filename, fileAttachmentFieldName) ⇒ Object
Upload a file into a new record in the active table. e.g. uploadFile( “contacts.txt”, “Contacts File” )
4607 4608 4609 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4607 def _uploadFile( filename, fileAttachmentFieldName ) uploadFile( @dbid, filename, fileAttachmentFieldName ) end |
#_userRoles ⇒ Object
API_UserRoles, using the active table id.
3084 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3084 def _userRoles() userRoles( @dbid ) end |
#addField(dbid, label, type, mode = nil) ⇒ Object
API_AddField
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1671 def addField( dbid, label, type, mode = nil ) @dbid, @label, @type, @mode = dbid, label, type, mode if isValidFieldType?( type ) xmlRequestData = toXML( :label, @label ) + toXML( :type, @type ) xmlRequestData << toXML( :mode, mode ) if mode sendRequest( :addField, xmlRequestData ) @fid = getResponseValue( :fid ) @label = getResponseValue( :label ) return self if @chainAPIcalls return @fid, @label else raise "addField: Invalid field type '#{type}'. Valid types are " + @validFieldTypes.join( "," ) end end |
#addFieldValuePair(name, fid, filename, value) ⇒ Object
Adds a field value to the list of fields to be set by the next addRecord() or editRecord() call to QuickBase.
-
name: label of the field value to be set.
-
fid: id of the field to be set.
-
filename: if the field is a file attachment field, the name of the file that should be displayed in QuickBase.
-
value: the value to set in this field. If the field is a file attachment field, the name of the file that should be uploaded into QuickBase.
1163 1164 1165 1166 1167 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1163 def addFieldValuePair( name, fid, filename, value ) @fvlist ||= [] @fvlist << FieldValuePairXML.new( self, name, fid, filename, value ).to_s @fvlist end |
#addOrEditRecord(dbid, fvlist, rid = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, key = nil) ⇒ Object
Use this if you aren’t sure whether a particular record already exists or not
3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3095 def addOrEditRecord( dbid, fvlist, rid = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, key = nil ) if rid or key editRecord( dbid, rid, fvlist, disprec, fform, ignoreError, update_id, key ) if !@requestSucceeded addRecord( dbid, fvlist, disprec, fform, ignoreError, update_id ) end else addRecord( dbid, fvlist, disprec, fform, ignoreError, update_id ) end end |
#addRecord(dbid, fvlist = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC = nil) ⇒ Object
API_AddRecord
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1695 def addRecord( dbid, fvlist = nil, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC =nil ) @dbid, @fvlist, @disprec, @fform, @ignoreError, @update_id, @msInUTC = dbid, fvlist, disprec, fform, ignoreError, update_id, msInUTC setFieldValues( fvlist, false ) if fvlist.is_a?(Hash) xmlRequestData = "" if @fvlist and @fvlist.length > 0 @fvlist.each{ |fv| xmlRequestData << fv } #see addFieldValuePair, clearFieldValuePairList, @fvlist end xmlRequestData << toXML( :disprec, @disprec ) if @disprec xmlRequestData << toXML( :fform, @fform ) if @fform xmlRequestData << toXML( :ignoreError, "1" ) if @ignoreError xmlRequestData << toXML( :update_id, @update_id ) if @update_id xmlRequestData << toXML( :msInUTC, "1" ) if @msInUTC xmlRequestData = nil if xmlRequestData.length == 0 sendRequest( :addRecord, xmlRequestData ) @rid = getResponseValue( :rid ) @update_id = getResponseValue( :update_id ) return self if @chainAPIcalls return @rid, @update_id end |
#addReplaceDBPage(dbid, pageid, pagename, pagetype, pagebody, ignoreError = nil) ⇒ Object
API_AddReplaceDBPage
1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1726 def addReplaceDBPage( dbid, pageid, pagename, pagetype, pagebody, ignoreError = nil ) @dbid, @pageid, @pagename, @pagetype, @pagebody, @ignoreError = dbid, pageid, pagename, pagetype, pagebody, ignoreError if pageid xmlRequestData = toXML( :pageid, @pageid ) elsif pagename xmlRequestData = toXML( :pagename, @pagename ) else raise "addReplaceDBPage: missing pageid or pagename" end xmlRequestData << toXML( :pagetype, @pagetype ) xmlRequestData << toXML( :pagebody, encodeXML( @pagebody ) ) xmlRequestData << toXML( :ignoreError, "1" ) if @ignoreError sendRequest( :addReplaceDBPage, xmlRequestData ) @pageid = getResponseValue( :pageid ) @pageid ||= getResponseValue( :pageID ) # temporary return self if @chainAPIcalls @pageid end |
#addUserToRole(dbid, userid, roleid) ⇒ Object
API_AddUserToRole
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1755 def addUserToRole( dbid, userid, roleid ) @dbid, @userid, @roleid = dbid, userid, roleid xmlRequestData = toXML( :userid, @userid ) xmlRequestData << toXML( :roleid, @roleid ) sendRequest( :addUserToRole, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#alias_methods ⇒ Object
Add method aliases that follow the ruby method naming convention.
E.g. sendRequest will be aliased as send_request.
5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 |
# File 'lib/broker/client/QuickBaseClient.rb', line 5021 def alias_methods aliased_methods = [] public_methods.each{|old_method| if old_method.match(/[A-Z]+/) new_method = old_method.gsub(/[A-Z]+/){|uc| "_#{uc.downcase}"} aliased_methods << new_method instance_eval( "alias #{new_method} #{old_method}") end } aliased_methods end |
#applyDeviationToRecords(dbid, numericField, deviationField, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Query records, get the average of the values in a numeric field, calculate each record’s deviation from the average and put the deviation in a percent field each record.
4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4130 def applyDeviationToRecords( dbid, numericField, deviationField, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil) fieldNames = Array[numericField] avg = average( dbid, fieldNames, query, qid, qname, clist, slist, fmt, ) fieldNames << "3" # Record ID# iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, ){|record| result = deviation( [avg[numericField],record[numericField]] ) clearFieldValuePairList addFieldValuePair( deviationField, nil, nil, result.to_s ) editRecord( dbid, record["3"], fvlist ) } end |
#applyPercentToRecords(dbid, numericField, percentField, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Query records, sum the values in a numeric field, calculate each record’s percentage of the sum and put the percent in a percent field each record.
4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4115 def applyPercentToRecords( dbid, numericField, percentField, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil) fieldNames = Array[numericField] total = sum( dbid, fieldNames, query, qid, qname, clist, slist, fmt, ) fieldNames << "3" # Record ID# iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, ){|record| result = percent( [total[numericField],record[numericField]] ) clearFieldValuePairList addFieldValuePair( percentField, nil, nil, result.to_s ) editRecord( dbid, record["3"], fvlist ) } end |
#assertFederatedIdentity(dbid, serviceProviderID, targetURL) ⇒ Object
API_AssertFederatedIdentity (IPP only)
1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1771 def assertFederatedIdentity( dbid, serviceProviderID, targetURL ) @dbid, @serviceProviderID, @targetURL = dbid, serviceProviderID, targetURL xmlRequestData = toXML( :serviceProviderID, @serviceProviderID ) xmlRequestData << toXML( :targetURL, @targetURL ) sendRequest( :assertFederatedIdentity, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#attachIDSRealm(dbid, realm) ⇒ Object
API_AttachIDSRealm (IPP only)
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1784 def attachIDSRealm( dbid, realm ) @dbid, @realm = dbid, realm xmlRequestData = toXML( :realm, @realm ) sendRequest( :attachIDSRealm, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#authenticate(username, password, hours = nil) ⇒ Object
API_Authenticate
1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1837 def authenticate( username, password, hours = nil ) @username, @password, @hours = username, password, hours if username and password @ticket = nil if @hours xmlRequestData = toXML( :hours, @hours ) sendRequest( :authenticate, xmlRequestData ) else sendRequest( :authenticate ) end @userid = getResponseValue( :userid ) return self if @chainAPIcalls return @ticket, @userid elsif username or password raise "authenticate: missing username or password" elsif @ticket raise "authenticate: #{username} is already authenticated" end end |
#average(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Returns the average of the values for one or more fields in the records returned by a query. e.g. averagesHash = average(“dfdfafff”,[“Date Sent”,“Quantity”,“Part Name”])
4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4077 def average( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) count = {} fieldNames.each{|field| count[field]=0 } sum = {} iterateRecords(dbid,fieldNames,query,qid,qname,clist,slist,fmt,){|record| fieldNames.each{|field| value = record[field] if value baseFieldType = lookupBaseFieldTypeByName(field) case baseFieldType when "int32","int64","bool" value = record[field].to_i when "float" value = record[field].to_f end if sum[field].nil? sum[field] = value else sum[field] = sum[field] + value end count[field] += 1 end } } average = {} hasValues = false fieldNames.each{|field| if sum[field] and count[field] > 0 average[field] = (sum[field]/count[field]) hasValues = true end } average = nil if not hasValues average end |
#chainAPIcallsBlock ⇒ Object
This method changes all the API_ wrapper methods to return ‘self’ instead of their normal return values. The change is in effect only within the associated block. This allows mutliple API_ calls to be ‘chained’ together without needing ‘qbClient’ in front of each call.
e.g. qbClient.chainAPIcallsBlock {
qbClient
.addField( @dbid, "a text field", "text" )
.addField( @dbid, "a choice field", "text" )
.fieldAddChoices( @dbid, @fid, %w{ one two three four five } )
}
3192 3193 3194 3195 3196 3197 3198 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3192 def chainAPIcallsBlock if block_given? @chainAPIcalls = true yield end @chainAPIcalls = nil end |
#changePermission(dbid, uname, view, modify, create, delete, saveviews, admin) ⇒ Object
API_ChangePermission (appears to be deprecated)
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1863 def changePermission( dbid, uname, view, modify, create, delete, saveviews, admin ) raise "changePermission: API_ChangePermission is no longer a valid QuickBase HTTP API request." @dbid, @uname, @view, @modify, @create, @delete, @saveviews, @admin = dbid, uname, view, modify, create, delete, saveviews, admin xmlRequestData = toXML( :dbid, @dbid ) xmlRequestData << toXML( :uname, @uname ) viewModifyPermissions = %w{ none any own group } if @view if viewModifyPermissions.include?( @view ) xmlRequestData << toXML( :view, @view ) else raise "changePermission: view must be one of " + viewModifyPermissions.join( "," ) end end if @modify if viewModifyPermissions.include?( @modify ) xmlRequestData << toXML( :modify, @modify ) else raise "changePermission: modify must be one of " + viewModifyPermissions.join( "," ) end end xmlRequestData << toXML( :create, @create ) if @create xmlRequestData << toXML( :delete, @delete ) if @delete xmlRequestData << toXML( :saveviews, @saveviews ) if @saveviews xmlRequestData << toXML( :admin, @admin ) if @admin sendRequest( :changePermission, xmlRequestData ) # not sure the API reference is correct about these return values @username = getResponseValue( :username ) @view = getResponseValue( :view ) @modify = getResponseValue( :modify ) @create = getResponseValue( :create ) @delete = getResponseValue( :delete ) @saveviews = getResponseValue( :saveviews ) @admin = getResponseValue( :admin ) @rolename = getResponseValue( :rolename ) return self if @chainAPIcalls return @username, @view, @modify, @create, @delete, @saveviews, @admin, @rolename end |
#changeRecordOwner(dbid, rid, newowner) ⇒ Object
API_ChangeRecordOwner
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1916 def changeRecordOwner( dbid, rid, newowner ) @dbid, @rid, @newowner = dbid, rid, newowner xmlRequestData = toXML( :dbid, @dbid ) xmlRequestData << toXML( :rid, @rid ) xmlRequestData << toXML( :newowner, @newowner ) sendRequest( :changeRecordOwner, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#changeRecords(fieldNameToSet, fieldValueToSet, fieldNameToTest, test, fieldValueToTest) ⇒ Object
Change a field’s value in multiple records. If the optional test field/operator/value are supplied, only records matching the test field will be modified, otherwise all records will be modified. e.g. changeRecords( “Status”, “special”, “Account Balance”, “>”, “100000.00” )
3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3245 def changeRecords( fieldNameToSet, fieldValueToSet, fieldNameToTest, test, fieldValueToTest ) if @dbid and @fields and fieldNameToSet and fieldValueToSet and fieldNameToTest and test and fieldValueToTest numRecsChanged = 0 numRecs = _getNumRecords if numRecs > "0" fieldType = "text" if fieldNameToTest fieldNameToTestID = lookupFieldIDByName( fieldNameToTest ) field = lookupField( fieldNameToTestID ) if fieldNameToTestID fieldType = field.attributes[ "field_type" ] if field end fieldNameToSetID = lookupFieldIDByName( fieldNameToSet ) if fieldNameToSetID clearFieldValuePairList addFieldValuePair( nil, fieldNameToSetID, nil, fieldValueToSet ) (1..numRecs.to_i).each{ |rid| _getRecordInfo( rid.to_s ) if @num_fields and @update_id and @field_data_list if fieldNameToTestID and test and fieldValueToTest field_data = lookupFieldData( fieldNameToTestID ) if field_data and field_data.is_a?( REXML::Element ) valueElement = field_data.elements[ "value" ] value = valueElement.text if valueElement.has_text? value = formatFieldValue( value, fieldType ) match = eval( "\"#{value}\" #{test} \"#{fieldValueToTest}\"" ) if value if match editRecord( @dbid, rid.to_s, @fvlist ) if @rid numRecsChanged += 1 end end end else editRecord( @dbid, rid.to_s, @fvlist ) if @rid numRecsChanged += 1 end end end } end end end numRecsChanged end |
#changeUserRole(dbid, userid, roleid, newroleid) ⇒ Object
API_ChangeUserRole.
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1934 def changeUserRole( dbid, userid, roleid, newroleid ) @dbid, @userid, @roleid, @newroleid = dbid, userid, roleid, newroleid xmlRequestData = toXML( :userid, @userid ) xmlRequestData << toXML( :roleid, @roleid ) xmlRequestData << toXML( :newroleid, @newroleid ) sendRequest( :changeUserRole, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#childElementsAsString(element, indent = 0) ⇒ Object
Recursive method to generate a simplified (yaml-like) tree of the XML returned by QuickBase.
Translates field IDs into field names.
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
# File 'lib/broker/client/QuickBaseClient.rb', line 612 def childElementsAsString( element, indent = 0 ) ret = "" indentation = "" indent.times{ indentation << " " } if indent > 0 if element and element.is_a?( REXML::Element ) and element.has_elements? attributes = getAttributeString( element ) name = lookupFieldName( element ) ret << "#{indentation}#{name} #{attributes}:\r\n" element.each { |element| if element.is_a?( REXML::Element ) and element.has_elements? ret << childElementsAsString( element, (indent+1) ) elsif element.is_a?( REXML::Element ) and element.has_text? attributes = getAttributeString( element ) name = lookupFieldName( element ) text = formatFieldValue( element.text, lookupFieldType( element ) ) ret << " #{indentation}#{name} #{attributes} = #{text}\r\n" end } elsif element and element.is_a?( Array ) element.each{ |e| ret << childElementsAsString( e ) } end ret end |
#clearFieldValuePairList ⇒ Object
Empty the list of field values used for the next addRecord() or editRecord() call to QuickBase.
1186 1187 1188 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1186 def clearFieldValuePairList @fvlist = nil end |
#clientMethods ⇒ Object
Return an array of all the public methods of this class. Used by CommandLineClient to verify commands entered by the user.
198 199 200 |
# File 'lib/broker/client/QuickBaseClient.rb', line 198 def clientMethods Client.public_instance_methods( false ) end |
#cloneDatabase(dbid, newdbname, newdbdesc, keepData, asTemplate = nil, usersAndRoles = nil) ⇒ Object
API_CloneDatabase
1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1951 def cloneDatabase( dbid, newdbname, newdbdesc, keepData, asTemplate = nil, usersAndRoles = nil ) @dbid, @newdbname, @newdbdesc, @keepData, @asTemplate, @usersAndRoles = dbid, newdbname, newdbdesc, keepData, asTemplate, usersAndRoles @keepData = "1" if @keepData.to_s == "true" @keepData = "0" if @keepData != "1" xmlRequestData = toXML( :newdbname, @newdbname ) xmlRequestData << toXML( :newdbdesc, @newdbdesc ) xmlRequestData << toXML( :keepData, @keepData ) xmlRequestData << toXML( :asTemplate, @asTemplate ) if @asTemplate xmlRequestData << toXML( :usersAndRoles, @usersAndRoles ) if @usersAndRoles sendRequest( :cloneDatabase, xmlRequestData ) @newdbid = getResponseValue( :newdbid ) return self if @chainAPIcalls @newdbid end |
#copyMasterDetail(dbid, destrid, sourcerid, copyfid = nil, recurse = nil, relfids = nil) ⇒ Object
API_CopyMasterDetail
1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1976 def copyMasterDetail( dbid, destrid, sourcerid, copyfid = nil, recurse = nil, relfids = nil ) raise "copyfid must be specified when destrid is 0." if destrid == "0" and copyfid.nil? @dbid, @destrid, @sourcerid, @copyfid, @recurse, @relfids = dbid, destrid, sourcerid, copyfid, recurse, relfids xmlRequestData = toXML( :destrid, @destrid) xmlRequestData << toXML( :sourcerid, @sourcerid ) xmlRequestData << toXML( :copyfid, @copyfid ) if @copyfid xmlRequestData << toXML( :recurse, @recurse ) if @recurse xmlRequestData << toXML( :relfids, @relfids ) if @relfids sendRequest( :copyMasterDetail, xmlRequestData ) @parentrid = getResponseValue( :parentrid ) @numCreated = getResponseValue( :numCreated ) return self if @chainAPIcalls return @parentrid, @numCreated end |
#copyRecord(rid, numCopies = 1, dbid = @dbid) ⇒ Object
Make one or more copies of a record.
4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4287 def copyRecord( rid, numCopies = 1, dbid = @dbid ) clearFieldValuePairList getRecordInfo( dbid, rid ) { |field| if field and field.elements[ "value" ] and field.elements[ "value" ].has_text? if field.elements[ "fid" ].text.to_i > 5 #skip built-in fields addFieldValuePair( field.elements[ "name" ].text, nil, nil, field.elements[ "value" ].text ) end end } newRecordIDs = [] if @fvlist and @fvlist.length > 0 numCopies.times { addRecord( dbid, @fvlist ) newRecordIDs << @rid if @rid and @update_id } end if block_given? newRecordIDs.each{ |newRecordID| yield newRecordID } else newRecordIDs end end |
#count(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Returns the number non-null values for one or more fields in the records returned by a query. e.g. countsHash = count(“dfdfafff”,[“Date Sent”,“Quantity”,“Part Name”])
4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4030 def count( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) count = {} fieldNames.each{|field| count[field]=0 } hasValues = false iterateRecords(dbid,fieldNames,query,qid,qname,clist,slist,fmt,){|record| fieldNames.each{|field| if record[field] and record[field].length > 0 count[field] += 1 hasValues = true end } } count = nil if not hasValues count end |
#createDatabase(dbname, dbdesc, createapptoken = "1") ⇒ Object
API_CreateDatabase
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2001 def createDatabase( dbname, dbdesc, createapptoken = "1" ) @dbname, @dbdesc, @createapptoken = dbname, dbdesc, createapptoken xmlRequestData = toXML( :dbname, @dbname ) xmlRequestData << toXML( :dbdesc, @dbdesc ) xmlRequestData << toXML( :createapptoken, @createapptoken ) sendRequest( :createDatabase, xmlRequestData ) @dbid = getResponseValue( :dbid ) @appdbid = getResponseValue( :appdbid ) @apptoken = getResponseValue( :apptoken ) return self if @chainAPIcalls return @dbid, @appdbid end |
#createTable(tname, pnoun, application_dbid = @dbid) ⇒ Object
API_CreateTable
2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2020 def createTable( tname, pnoun, application_dbid = @dbid ) @tname, @pnoun, @dbid = tname, pnoun, application_dbid xmlRequestData = toXML( :tname, @tname ) xmlRequestData << toXML( :pnoun, @pnoun ) sendRequest( :createTable, xmlRequestData ) @newdbid = getResponseValue( :newdbid ) @newdbid ||= getResponseValue( :newDBID ) #temporary @dbid = @newdbid return self if @chainAPIcalls @newdbid end |
#dateToMS(dateString) ⇒ Object
Returns the milliseconds representation of a date specified in mm-dd-yyyy format.
1488 1489 1490 1491 1492 1493 1494 1495 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1488 def dateToMS( dateString ) milliseconds = 0 if dateString and dateString.match( /[0-9][0-9]\-[0-9][0-9]\-[0-9][0-9][0-9][0-9]/) d = Date.new( dateString[7,4], dateString[4,2], dateString[0,2] ) milliseconds = d.jd end milliseconds end |
#debugHTTPConnection ⇒ Object
Causes useful information to be printed to the screen for every HTTP request.
177 178 179 |
# File 'lib/broker/client/QuickBaseClient.rb', line 177 def debugHTTPConnection() @httpConnection.set_debug_output $stdout if @httpConnection and USING_HTTPCLIENT == false end |
#decodeXML(text) ⇒ Object
Modify the given XML field value for use as a string.
1554 1555 1556 1557 1558 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1554 def decodeXML( text ) encodingStrings( true ) { |key,value| text.gsub!( value, key ) if text } text.gsub!( /&#([0-9]{2,3});/ ) { |c| $1.chr } if text text end |
#deleteAppZip(dbid) ⇒ Object
API_DeleteAppZip
1808 1809 1810 1811 1812 1813 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1808 def deleteAppZip( dbid ) @dbid = dbid sendRequest( :deleteAppZip ) return self if @chainAPIcalls @responseCode end |
#deleteDatabase(dbid) ⇒ Object
API_DeleteDatabase
2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2036 def deleteDatabase( dbid ) @dbid = dbid sendRequest( :deleteDatabase ) @dbid = @rid = nil return self if @chainAPIcalls @requestSucceeded end |
#deleteDuplicateRecords(fnames, fids = nil, options = nil, dbid = @dbid) ⇒ Object
Finds records with the same values in a specified list of fields and deletes all but the first or last duplicate record. The field list may be a list of field IDs or a list of field names. The ‘options’ parameter can be used to keep the oldest record instead of the newest record, and to control whether to ignore the case of field values when deciding which records are duplicates. Returns the number of records deleted.
4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4267 def deleteDuplicateRecords( fnames, fids = nil, = nil, dbid = @dbid ) num_deleted = 0 if and not .is_a?( Hash ) raise "deleteDuplicateRecords: 'options' parameter must be a Hash" else = {} [ "keeplastrecord" ] = true [ "ignoreCase" ] = true end findDuplicateRecordIDs( fnames, fids, dbid, [ "ignoreCase" ] ) { |dupeValues, recordIDs| if [ "keeplastrecord" ] recordIDs[0..(recordIDs.length-2)].each{ |rid| num_deleted += 1 if deleteRecord( dbid, rid ) } elsif [ "keepfirstrecord" ] recordIDs[1..(recordIDs.length-1)].each{ |rid| num_deleted += 1 if deleteRecord( dbid, rid ) } end } num_deleted end |
#deleteField(dbid, fid) ⇒ Object
API_DeleteField
2051 2052 2053 2054 2055 2056 2057 2058 2059 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2051 def deleteField( dbid, fid ) @dbid, @fid = dbid, fid xmlRequestData = toXML( :fid, @fid ) sendRequest( :deleteField, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#deleteRecord(dbid, rid) ⇒ Object
API_DeleteRecord
2076 2077 2078 2079 2080 2081 2082 2083 2084 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2076 def deleteRecord( dbid, rid ) @dbid, @rid = dbid, rid xmlRequestData = toXML( :rid, @rid ) sendRequest( :deleteRecord, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#deleteRecords(fieldNameToTest = nil, test = nil, fieldValueToTest = nil) ⇒ Object
Delete all records in the active table that match the field/operator/value. e.g. deleteRecords( “Status”, “==”, “inactive” ). To delete ALL records, call deleteRecords() with no parameters. This is the same as calling _purgeRecords.
3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3301 def deleteRecords( fieldNameToTest = nil, test = nil, fieldValueToTest = nil) numRecsDeleted = 0 if @dbid and @fields and fieldNameToTest and test and fieldValueToTest numRecs = _getNumRecords if numRecs > "0" fieldNameToTestID = lookupFieldIDByName( fieldNameToTest ) fieldToTest = lookupField( fieldNameToTestID ) if fieldNameToTestID fieldType = fieldToTest.attributes[ "field_type" ] if fieldToTest if fieldNameToTestID (1..numRecs.to_i).each{ |rid| _getRecordInfo( rid.to_s ) if @num_fields and @update_id and @field_data_list field_data = lookupFieldData( fieldNameToTestID ) if field_data and field_data.is_a?( REXML::Element ) valueElement = field_data.elements[ "value" ] value = valueElement.text if valueElement.has_text? value = formatFieldValue( value, fieldType ) match = eval( "\"#{value}\" #{test} \"#{fieldValueToTest}\"" ) if value if match if _deleteRecord( rid.to_s ) numRecsDeleted += 1 end end end end } end end elsif @dbid numRecsDeleted = _purgeRecords end numRecsDeleted end |
#detachIDSRealm(dbid, realm) ⇒ Object
API_DetachIDSRealm (IPP only)
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1796 def detachIDSRealm( dbid, realm ) @dbid, @realm = dbid, realm xmlRequestData = toXML( :realm, @realm ) sendRequest( :detachIDSRealm, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#deviation(inputValues) ⇒ Object
Given an array of two numbers, return the difference between the numbers as a positive number.
4155 4156 4157 4158 4159 4160 4161 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4155 def deviation( inputValues ) raise "'inputValues' must not be nil" if inputValues.nil? raise "'inputValues' must be an Array" if not inputValues.is_a?(Array) raise "'inputValues' must have at least two elements" if inputValues.length < 2 value = inputValues[0].to_f - inputValues[1].to_f value.abs end |
#doQuery(dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
API_DoQuery
2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2090 def doQuery( dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) @dbid, @clist, @slist, @fmt, @options = dbid, clist, slist, fmt, @clist ||= getColumnListForQuery(qid, qname) @slist ||= getSortListForQuery(qid, qname) xmlRequestData = getQueryRequestXML( query, qid, qname ) xmlRequestData << toXML( :clist, @clist ) if @clist xmlRequestData << toXML( :slist, @slist ) if @slist xmlRequestData << toXML( :fmt, @fmt ) if @fmt xmlRequestData << toXML( :options, @options ) if @options sendRequest( :doQuery, xmlRequestData ) if @fmt and @fmt == "structured" @records = getResponseElement( "table/records" ) @fields = getResponseElement( "table/fields" ) @chdbids = getResponseElement( "table/chdbids" ) @queries = getResponseElement( "table/queries" ) @variables = getResponseElement( "table/variables" ) else @records = getResponseElements( "qdbapi/record" ) @fields = getResponseElements( "qdbapi/field" ) @chdbids = getResponseElements( "qdbapi/chdbid" ) @queries = getResponseElements( "qdbapi/query" ) @variables = getResponseElements( "qdbapi/variable" ) end return self if @chainAPIcalls if block_given? if @records @records.each { |element| yield element } else yield nil end else @records end end |
#doQueryCount(dbid, query) ⇒ Object
API_DoQueryCount
2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2156 def doQueryCount( dbid, query ) @dbid, @query = dbid, query xmlRequestData = toXML( :query, @query ) sendRequest( :doQueryCount, xmlRequestData ) @numMatches = getResponseValue( :numMatches ) return self if @chainAPIcalls @numMatches end |
#doSQLInsert(sqlString) ⇒ Object
Translate a simple SQL INSERT statement to a QuickBase addRecord call.
Note: This method is here primarily for Rails integration. Note: This assumes, like SQL, that your column (i.e. field) names do not contain spaces.
4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4912 def doSQLInsert(sqlString) sql = sqlString.dup dbname = "" state = nil fieldName = "" fieldValue = "" fieldNames = [] fieldValues = [] index = 0 clearFieldValuePairList sql.gsub!("("," ") sql.gsub!(")"," ") sql.split(' ').each{ |token| case token when "INSERT", "INTO" state = "getTable" next when "VALUES" state = "getFieldValue" next end if state == "getTable" dbname = token.strip state = "getFieldName" elsif state == "getFieldName" fieldName = token.dup fieldName.gsub!("],","") fieldName.gsub!('[','') fieldName.gsub!(']','') fieldName.gsub!(',','') fieldNames << fieldName elsif state == "getFieldValue" test = token.dup if test[-1,1] == "'" or test[-2,2] == "'," fieldValue << token.dup if fieldValue[-2,2] == "'," fieldValue.gsub!("',",'') end fieldValue.gsub!('\'','') if fieldValue.length > 0 and fieldNames[index] addFieldValuePair(fieldNames[index],nil,nil,fieldValue) fieldName = "" fieldValue = "" end index += 1 elsif token == "," addFieldValuePair(fieldNames[index],nil,nil,"") fieldName = "" fieldValue = "" index += 1 else fieldValue << "#{token.dup} " end end } if dbname and @dbid.nil? dbid = findDBByname( dbname ) else dbid = lookupChdbid( dbname ) end dbid ||= @dbid recordid = nil if dbid recordid,updateid = addRecord(dbid,@fvlist) end recordid end |
#doSQLQuery(sqlString, returnOptions = nil) ⇒ Object
Translate a simple SQL SELECT statement to a QuickBase query and run it.
If any supplied field names are numeric, they will be treated as QuickBase field IDs if
they aren't valid field names.
-
e.g. doSQLQuery( “SELECT FirstName,Salary FROM Contacts WHERE LastName = ”Doe“ ORDER BY FirstName )
-
e.g. doSQLQuery( “SELECT * FROM Books WHERE Author = ”Freud“ )
Note: This method is here primarily for Rails integration. Note: This assumes, like SQL, that your column (i.e. field) names do not contain spaces.
4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4661 def doSQLQuery( sqlString, returnOptions = nil ) ret = nil sql = sqlString.dup dbid = nil clist = nil slist = nil state = nil dbname = "" columns = [] sortFields = [] limit = nil offset = nil = nil getRecordCount = false queryFields = [] query = "{'[" queryState = "getFieldName" queryField = "" sql.split(' ').each{ |token| case token when "SELECT" then state = "getColumns";next when "count(*)" then state = "getCount";next when "FROM" then state = "getTable";next when "WHERE" then state = "getFilter" ;next when "ORDER" then state = "getBy";next when "BY" then state = "getSort";next when "LIMIT" then state = "getLimit";next when "OFFSET" then state = "getOffset";next end if state == "getColumns" if token.index( "," ) token.split(",").each{ |column| columns << column if column.length > 0 } else columns << "#{token} " end elsif state == "getCount" getRecordCount = true elsif state == "getTable" dbname = token.strip elsif state == "getFilter" if token == "AND" query.strip! query << "'}AND{'[" queryState = "getFieldName" elsif token == "OR" query.strip! query << "'}OR{'[" queryState = "getFieldName" elsif token == "=" query << "]'.TV.'" queryState = "getFieldValue" queryFields << queryField queryField = "" elsif token == "<>" or token == "!=" query << "]'.XTV.'" queryState = "getFieldValue" queryFields << queryField queryField = "" elsif queryState == "getFieldValue" fieldValue = token.dup if fieldValue[-2,2] == "')" fieldValue[-1,1] = "" end if fieldValue[-1] == "'" fieldValue.gsub!("'","") query << "#{fieldValue}" else fieldValue.gsub!("'","") query << "#{fieldValue} " end elsif queryState == "getFieldName" fieldName = token.gsub("(","").gsub(")","").gsub( "#{dbname}.","") query << "#{fieldName}" queryField << "#{fieldName} " end elsif state == "getSort" if token.contains( "," ) token.split(",").each{ |sortField| sortFields << sortField if sortField.length > 0 } else sortFields << "#{token} " end elsif state == "getLimit" limit = token.dup if .nil? = "num-#{limit}" else << ".num-#{limit}" end elsif state == "getOffset" offset = token.dup if .nil? = "skp-#{offset}" else << ".skp-#{offset}" end end } if dbname and @dbid.nil? dbid = findDBByname( dbname ) else dbid = lookupChdbid( dbname ) end dbid ||= @dbid if dbid getDBInfo( dbid ) getSchema( dbid ) if columns.length > 0 if columns[0] == "* " columns = getFieldNames( dbid ) end columnNames = [] columns.each{ |column| column.strip! fid = lookupFieldIDByName( column ) if fid.nil? and column.match(/[0-9]+/) fid = column columnNames << lookupFieldNameFromID(fid) else columnNames << column end if fid if clist clist << ".#{fid}" else clist = fid end end } end if sortFields.length > 0 sortFields.each{ |sortField| sortField.strip! fid = lookupFieldIDByName( sortField ) if fid.nil? fid = sortField if sortField.match(/[0-9]+/) end if fid if slist slist << ".#{fid}" else slist = fid end end } end if queryFields.length > 0 query.strip! query << "'}" queryFields.each{ |fieldName| fieldName.strip! fid = lookupFieldIDByName( fieldName ) if fid query.gsub!( "'[#{fieldName} ]'", "'#{fid}'" ) end } else query = nil end if getRecordCount ret = getNumRecords(dbid) elsif returnOptions == :Hash ret = getAllValuesForFields(dbid, columnNames, query, nil, nil, clist, slist,"structured",) elsif returnOptions == :Array ret = getAllValuesForFieldsAsArray(dbid, columnNames, query, nil, nil, clist, slist,"structured",) else ret = doQuery( dbid, query, nil, nil, clist, slist, "structured", ) end end ret end |
#doSQLUpdate(sqlString) ⇒ Object
Translate a simple SQL UPDATE statement to a QuickBase editRecord call.
Note: This method is here primarily for Rails integration. Note: This assumes, like SQL, that your column (i.e. field) names do not contain spaces. Note: This assumes that Record ID# is the key field in your table.
4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4842 def doSQLUpdate(sqlString) sql = sqlString.dup dbname = "" state = nil fieldName = "" fieldValue = "" sqlQuery = "SELECT 3 FROM " clearFieldValuePairList sql.split(' ').each{ |token| case token when "UPDATE" state = "getTable" unless state == "getFilter" next when "SET" state = "getFieldName" unless state == "getFilter" next when "=" sqlQuery << " = " if state == "getFilter" state = "getFieldValue" unless state == "getFilter" next when "WHERE" sqlQuery << " WHERE " state = "getFilter" next end if state == "getTable" dbname = token.dup sqlQuery << dbname elsif state == "getFieldName" fieldName = token.gsub('[','').gsub(']','') elsif state == "getFieldValue" test = token if test[-1,1] == "'" or test[-2,2] == "'," fieldValue << token if fieldValue[-2,2] == "'," state = "getFieldName" fieldValue.gsub!("',","") end fieldValue.gsub!("'","") if fieldName.length > 0 addFieldValuePair(fieldName,nil,nil,fieldValue) fieldName = "" fieldValue = "" end else fieldValue << "#{token} " end elsif state == "getFilter" sqlQuery << token end } rows = doSQLQuery(sqlQuery,:Array) if rows and @dbid and @fvlist idFieldName = lookupFieldNameFromID("3") rows.each{ |row| recordID = row[idFieldName] editRecord(@dbid,recordID,@fvlist) if recordID } end end |
#downloadAndSaveFile(dbid, rid, fid, filename = nil, vid = "0") ⇒ Object
Download and save a file from a file attachment field in QuickBase. Use the filename parameter to override the file name from QuickBase.
2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2229 def downloadAndSaveFile( dbid, rid, fid, filename = nil, vid = "0" ) response, fileContents = downLoadFile( dbid, rid, fid, vid ) if fileContents and fileContents.length > 0 if filename and filename.length > 0 Misc.save_file( filename, fileContents ) else record = getRecord( rid, dbid, [fid] ) if record and record[fid] and record[fid].length > 0 Misc.save_file( record[fid], fileContents ) else Misc.save_file( "#{dbid}_#{rid}_#{fid}", fileContents ) end end end end |
#downLoadFile(dbid, rid, fid, vid = "0") ⇒ Object Also known as: downloadFile
Download a file’s contents from a file attachment field in QuickBase. You must write the contents to disk before a local file exists.
2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2174 def downLoadFile( dbid, rid, fid, vid = "0" ) @dbid, @rid, @fid, @vid = dbid, rid, fid, vid @downLoadFileURL = "http://#{@org}.#{@domain}.com/up/#{dbid}/a/r#{rid}/e#{fid}/v#{vid}" if @useSSL @downLoadFileURL.gsub!( "http:", "https:" ) end @requestHeaders = { "Cookie" => "ticket=#{@ticket}" } if @printRequestsAndResponses puts puts "downLoadFile request: -------------------------------------" p @downLoadFileURL p @requestHeaders end begin if USING_HTTPCLIENT @responseCode = 404 @fileContents = @httpConnection.get_content( @downLoadFileURL, nil, @requestHeaders ) @responseCode = 200 if @fileContents else @responseCode, @fileContents = @httpConnection.get( @downLoadFileURL, @requestHeaders ) end rescue Net::HTTPBadResponse => @lastError rescue Net::HTTPHeaderSyntaxError => @lastError rescue StandardError => @lastError end if @printRequestsAndResponses puts puts "downLoadFile response: -------------------------------------" p @responseCode p @fileContents end return self if @chainAPIcalls return @responseCode, @fileContents end |
#dumpAppZip(dbid) ⇒ Object
API_DumpAppZip
1816 1817 1818 1819 1820 1821 1822 1823 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1816 def dumpAppZip( dbid ) @dbid = dbid @noredirect = true xmlRequestData = toXML( :noredirect, "1" ) sendRequest( :dumpAppZip, xmlRequestData ) return self if @chainAPIcalls @responseCode end |
#eachField(record = @record) ⇒ Object
Iterate record XML and yield only ‘f’ elements.
5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 |
# File 'lib/broker/client/QuickBaseClient.rb', line 5001 def eachField( record = @record ) if record and block_given? record.each{ |field| if field.is_a?( REXML::Element) and field.name == "f" and field.attributes["id"] @field = field yield field end } end nil end |
#eachRecord(records = @records) ⇒ Object
Iterate @records XML and yield only ‘record’ elements.
4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4988 def eachRecord( records = @records ) if records and block_given? records.each { |record| if record.is_a?( REXML::Element) and record.name == "record" @record = record yield record end } end nil end |
#editRecord(dbid, rid, fvlist, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC = nil, key = nil) ⇒ Object
API_EditRecord
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2246 def editRecord( dbid, rid, fvlist, disprec = nil, fform = nil, ignoreError = nil, update_id = nil, msInUTC =nil, key = nil ) @dbid, @rid, @fvlist, @disprec, @fform, @ignoreError, @update_id, @msInUTC, @key = dbid, rid, fvlist, disprec, fform, ignoreError, update_id, msInUTC, key setFieldValues( fvlist, false ) if fvlist.is_a?(Hash) xmlRequestData = toXML( :rid, @rid ) if @rid xmlRequestData = toXML( :key, @key ) if @key @fvlist.each{ |fv| xmlRequestData << fv } #see addFieldValuePair, clearFieldValuePairList, @fvlist xmlRequestData << toXML( :disprec, @disprec ) if @disprec xmlRequestData << toXML( :fform, @fform ) if @fform xmlRequestData << toXML( :ignoreError, "1" ) if @ignoreError xmlRequestData << toXML( :update_id, @update_id ) if @update_id xmlRequestData << toXML( :msInUTC, "1" ) if @msInUTC sendRequest( :editRecord, xmlRequestData ) @rid = getResponseValue( :rid ) @update_id = getResponseValue( :update_id ) return self if @chainAPIcalls return @rid, @update_id end |
#editRecords(dbid, fieldValuesToSet, query = nil, qid = nil, qname = nil) ⇒ Object
Set the values of fields in all records returned by a query. fieldValuesToSet must be a Hash of fieldnames+values, e.g. => “Miami”, “Phone” => “343-4567”
3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3471 def editRecords(dbid,fieldValuesToSet,query=nil,qid=nil,qname=nil) edited_rids = [] if fieldValuesToSet and fieldValuesToSet.is_a?(Hash) verifyFieldList(fieldValuesToSet.keys,nil,dbid) recordIDs = getAllValuesForFields(dbid,["3"],query,qid,qname,"3") if recordIDs numRecords = recordIDs["3"].length (0..(numRecords-1)).each {|i| @rid = recordIDs["3"][i] setFieldValues(fieldValuesToSet) edited_rids << @rid } end else raise "'fieldValuesToSet' must be a Hash of field names and values." end edited_rids end |
#encodeXML(text, doNPChars = false) ⇒ Object
Modify the given string for use as a XML field value.
1547 1548 1549 1550 1551 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1547 def encodeXML( text, doNPChars = false ) encodingStrings { |key,value| text.gsub!( key, value ) if text } text.gsub!( /([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()# ])/ ) { |c| escapeXML( $1 ) } if text and doNPChars text end |
#encodingStrings(reverse = false) ⇒ Object
Returns the list of string substitutions to make to encode or decode field values used in XML.
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1533 def encodingStrings( reverse = false ) @encodingStrings = [ {"&" => "&" }, {"<" => "<"} , {">" => ">"}, {"'" => "'"}, {"\"" => """ } ] if @encodingStrings.nil? if block_given? if reverse @encodingStrings.reverse_each{ |s| s.each{|k,v| yield v,k } } else @encodingStrings.each{ |s| s.each{|k,v| yield k,v } } end else @encodingStrings end end |
#escapeXML(char) ⇒ Object
Returns the URL-encoded version of a non-printing character.
1523 1524 1525 1526 1527 1528 1529 1530 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1523 def escapeXML( char ) if @xmlEscapes.nil? @xmlEscapes = {} (0..255).each{ |i| @xmlEscapes[ i.chr ] = sprintf( "&#%03d;", i ) } end return @xmlEscapes[ char ] if @xmlEscapes[ char ] char end |
#fieldAddChoices(dbid, fid, choice) ⇒ Object
API_FieldAddChoices The choice parameter can be one choice string or an array of choice strings.
2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2274 def fieldAddChoices( dbid, fid, choice ) @dbid, @fid, @choice = dbid, fid, choice xmlRequestData = toXML( :fid, @fid ) if @choice.is_a?( Array ) @choice.each { |c| xmlRequestData << toXML( :choice, c ) } elsif @choice.is_a?( String ) xmlRequestData << toXML( :choice, @choice ) end sendRequest( :fieldAddChoices, xmlRequestData ) @fid = getResponseValue( :fid ) @fname = getResponseValue( :fname ) @numadded = getResponseValue( :numadded ) return self if @chainAPIcalls return @fid, @name, @numadded end |
#fieldRemoveChoices(dbid, fid, choice) ⇒ Object
API_FieldRemoveChoices The choice parameter can be one choice string or an array of choice strings.
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2311 def fieldRemoveChoices( dbid, fid, choice ) @dbid, @fid, @choice = dbid, fid, choice xmlRequestData = toXML( :fid, @fid ) if @choice.is_a?( Array ) @choice.each { |c| xmlRequestData << toXML( :choice, c ) } elsif @choice.is_a?( String ) xmlRequestData << toXML( :choice, @choice ) end sendRequest( :fieldRemoveChoices, xmlRequestData ) @fid = getResponseValue( :fid ) @fname = getResponseValue( :fname ) @numremoved = getResponseValue( :numremoved ) return self if @chainAPIcalls return @fid, @name, @numremoved end |
#fieldTypeForLabel(fieldTypeLabel) ⇒ Object
Returns a field type string given the more human-friendly label for a field type.
1053 1054 1055 1056 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1053 def fieldTypeForLabel( fieldTypeLabel ) @fieldTypeLabelMap ||= Hash["Text","text","Numeric","float","Date / Time","timestamp","Date","date","Checkbox","checkbox","Database Link","dblink","Duration","duration","Email","email","File Attachment","file","Numeric-Currency","currency","Numeric-Rating","rating","Numeric-Percent","percent","Phone Number","phone","Relationship","fkey","Time Of Day","timeofday","URL","url","User","user","Record ID#","recordid","Report Link","dblink","iCalendar","icalendarbutton"] @fieldTypeLabelMap[fieldTypeLabel] end |
#findDBByname(dbname) ⇒ Object Also known as: findDBByName
API_FindDBByname
2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2346 def findDBByname( dbname ) @dbname = dbname xmlRequestData = toXML( :dbname, @dbname ) sendRequest( :findDBByname, xmlRequestData ) @dbid = getResponseValue( :dbid ) return self if @chainAPIcalls @dbid end |
#findDuplicateRecordIDs(fnames, fids, dbid = @dbid, ignoreCase = true) ⇒ Object
Finds records with the same values in a specified list of fields.
The field list may be a list of field IDs or a list of field names. Returns a hash with the structure { “duplicated values” => [ rid, rid, … ] }
4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4217 def findDuplicateRecordIDs( fnames, fids, dbid = @dbid, ignoreCase = true ) verifyFieldList( fnames, fids, dbid ) duplicates = {} if @fids cslist = @fids.join( "." ) ridFields = lookupFieldsByType( "recordid" ) if ridFields and ridFields.last cslist << "." recordidFid = ridFields.last.attributes["id"] cslist << recordidFid valuesUsed = {} doQuery( @dbid, nil, nil, nil, cslist ) { |record| next unless record.is_a?( REXML::Element) and record.name == "record" recordID = "" recordValues = [] record.each { |f| if f.is_a?( REXML::Element) and f.name == "f" and f.has_text? if recordidFid == f.attributes["id"] recordID = f.text else recordValues << f.text end end } if not valuesUsed[ recordValues ] valuesUsed[ recordValues ] = [] end valuesUsed[ recordValues ] << recordID } valuesUsed.each{ |valueArray, recordArray| if recordArray.length > 1 duplicates[ valueArray ] = recordArray end } end end if block_given? duplicates.each{ |duplicate| yield duplicate } else duplicates end end |
#findElementByAttributeValue(elements, attribute_name, attribute_value) ⇒ Object
Returns the first XML sub-element with the specified attribute value.
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
# File 'lib/broker/client/QuickBaseClient.rb', line 708 def findElementByAttributeValue( elements, attribute_name, attribute_value ) element = nil if elements if elements.is_a?( REXML::Element ) elements.each_element_with_attribute( attribute_name, attribute_value ) { |e| element = e } elsif elements.is_a?( Array ) elements.each{ |e| if e.is_a?( REXML::Element ) and e.attributes[ attribute_name ] == attribute_value element = e end } end end element end |
#findElementsByAttributeName(elements, attribute_name) ⇒ Object
Returns an array of XML sub-elements with the specified attribute name.
742 743 744 745 746 747 748 |
# File 'lib/broker/client/QuickBaseClient.rb', line 742 def findElementsByAttributeName( elements, attribute_name ) elementArray = [] if elements elements.each_element_with_attribute( attribute_name ) { |e| elementArray << e } end elementArray end |
#findElementsByAttributeValue(elements, attribute_name, attribute_value) ⇒ Object
Returns an array of XML sub-elements with the specified attribute value.
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File 'lib/broker/client/QuickBaseClient.rb', line 725 def findElementsByAttributeValue( elements, attribute_name, attribute_value ) elementArray = [] if elements if elements.is_a?( REXML::Element ) elements.each_element_with_attribute( attribute_name, attribute_value ) { |e| elementArray << e } elsif elements.is_a?( Array ) elements.each{ |e| if e.is_a?( REXML::Element ) and e.attributes[ attribute_name ] == attribute_value element = e end } end end elementArray end |
#formatChdbidName(tableName) ⇒ Object
Given the name of a QuickBase table, returns the QuickBase representation of the table name.
898 899 900 901 902 903 |
# File 'lib/broker/client/QuickBaseClient.rb', line 898 def formatChdbidName( tableName ) tableName.downcase! tableName.strip! tableName.gsub!( /\W/, "_" ) "_dbid_#{tableName}" end |
#formatCurrency(value, options = nil) ⇒ Object
Returns a string formatted for a currency value.
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1433 def formatCurrency( value, = nil ) value ||= "0.00" if !value.include?( '.' ) value << ".00" end currencySymbol = currencyFormat = nil if currencySymbol = ["currencySymbol"] currencyFormat = ["currencyFormat"] end if currencySymbol if currencyFormat if currencyFormat == "0" value = "#{currencySymbol}#{value}" elsif currencyFormat == "1" if value.include?("-") value.gsub!("-","-#{currencySymbol}") elsif value.include?("+") value.gsub!("+","+#{currencySymbol}") else value = "#{currencySymbol}#{value}" end elsif currencyFormat == "2" value = "#{value}#{currencySymbol}" end else value = "#{currencySymbol}#{value}" end end value end |
#formatDate(milliseconds, fmtString = nil, addDay = false) ⇒ Object
Returns the human-readable string represntation of a date, given the milliseconds version of the date. Also needed for requests to QuickBase.
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1386 def formatDate( milliseconds, fmtString = nil, addDay = false ) fmt = "" fmtString = "%m-%d-%Y" if fmtString.nil? if milliseconds milliseconds_s = milliseconds.to_s if milliseconds_s.length == 13 t = Time.at( milliseconds_s[0,10].to_i, milliseconds_s[10,3].to_i ) t += (60 * 60 * 24) if addDay fmt = t.strftime( fmtString ) elsif milliseconds_s.length > 0 t = Time.at( (milliseconds_s.to_i) / 1000 ) t += (60 * 60 * 24) if addDay fmt = t.strftime( fmtString ) end end fmt end |
#formatDuration(value, option = "hours") ⇒ Object
Converts milliseconds to hours and returns the value as a string.
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1405 def formatDuration( value, option = "hours" ) option = "hours" if option.nil? if value.nil? value = "" else seconds = (value.to_i/1000) minutes = (seconds/60) hours = (minutes/60) days = (hours/24) if option == "days" value = days.to_s elsif option == "hours" value = hours.to_s elsif option == "minutes" value = minutes.to_s end end value end |
#formatFieldValue(value, type, options = nil) ⇒ Object
Returns a human-readable string representation of a QuickBase field value.
Also required for subsequent requests to QuickBase.
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
# File 'lib/broker/client/QuickBaseClient.rb', line 559 def formatFieldValue( value, type, = nil ) if value and type case type when "date" value = formatDate( value ) when "date / time","timestamp" value = formatDate( value, "%m-%d-%Y %I:%M %p" ) when "timeofday" value = formatTimeOfDay( value, ) when "duration" value = formatDuration( value, ) when "currency" value = formatCurrency( value, ) when "percent" value = formatPercent( value, ) end end value end |
#formatImportCSV(csv) ⇒ Object
Returns the string required for emebedding CSV data in a request.
1380 1381 1382 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1380 def formatImportCSV( csv ) "<![CDATA[#{csv}]]>" end |
#formatPercent(value, options = nil) ⇒ Object
Returns a string formatted for a percent value, given the data from QuickBase
1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1469 def formatPercent( value, = nil ) if value percent = (value.to_f * 100) value = percent.to_s if value.include?(".") int,fraction = value.split('.') if fraction.to_i == 0 value = int else value = "#{int}.#{fraction[0,2]}" end end else value = "0" end value end |
#formatTimeOfDay(milliseconds, format = "%I:%M %p") ⇒ Object
Returns a string format for a time of day value.
1426 1427 1428 1429 1430 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1426 def formatTimeOfDay(milliseconds, format = "%I:%M %p" ) format ||= "%I:%M %p" timeOfDay = "" timeOfDay = Time.at(milliseconds.to_i/1000).utc.strftime(format) if milliseconds end |
#genAddRecordForm(dbid, fvlist = nil) ⇒ Object
API_GenAddRecordForm
2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2359 def genAddRecordForm( dbid, fvlist = nil ) @dbid, @fvlist = dbid, fvlist setFieldValues( fvlist, false ) if fvlist.is_a?(Hash) xmlRequestData = "" @fvlist.each { |fv| xmlRequestData << fv } if @fvlist #see addFieldValuePair, clearFieldValuePairList, @fvlist sendRequest( :genAddRecordForm, xmlRequestData ) @HTML = @responseXML return self if @chainAPIcalls @HTML end |
#genResultsTable(dbid, query = nil, clist = nil, slist = nil, jht = nil, jsa = nil, options = nil, qid = nil, qname = nil) ⇒ Object
API_GenResultsTable
2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2379 def genResultsTable( dbid, query = nil, clist = nil, slist = nil, jht = nil, jsa = nil, = nil, qid = nil, qname = nil ) @dbid, @query, @clist, @slist, @jht, @jsa, @options = dbid, query, clist, slist, jht, jsa, @clist ||= getColumnListForQuery(qid, qname) @slist ||= getSortListForQuery(qid, qname) xmlRequestData = getQueryRequestXML( query, qid, qname ) xmlRequestData << toXML( :clist, @clist ) if @clist xmlRequestData << toXML( :slist, @slist ) if @slist xmlRequestData << toXML( :jht, @jht ) if @jht xmlRequestData << toXML( :jsa, @jsa ) if @jsa xmlRequestData << toXML( :options, @options ) if @options sendRequest( :genResultsTable, xmlRequestData ) @HTML = @responseXML return self if @chainAPIcalls @HTML end |
#getAllRecordIDs(dbid) ⇒ Object
Get an array of all the record IDs for a specified table. e.g. IDs = getAllRecordIDs( “dhnju5y7” ){ |id| puts “Record ##id” }
4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4191 def getAllRecordIDs( dbid ) rids = [] if dbid getSchema( dbid ) next_record_id = getResponseElement( "table/original/next_record_id" ) if next_record_id and next_record_id.has_text? next_record_id = next_record_id.text (1..next_record_id.to_i).each{ |rid| begin _getRecordInfo( rid ) rids << rid.to_s if update_id rescue end } end end if block_given? rids.each { |id| yield id } else rids end end |
#getAllValuesForFields(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object Also known as: getRecordsHash
Get all the values for one or more fields from a specified table.
e.g. getAllValuesForFields( “dhnju5y7”, [ “Name”, “Phone” ] )
The results are returned in Hash, e.g. { “Name” => values[ “Name” ], “Phone” => values[ “Phone” ] } The parameters after ‘fieldNames’ are passed directly to the doQuery() API_ call.
Invalid 'fieldNames' will be treated as field IDs by default, e.g. getAllValuesForFields( "dhnju5y7", [ "3" ] )
returns a list of Record ID#s even if the 'Record ID#' field name has been changed.
3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3349 def getAllValuesForFields( dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) if dbid getSchema(dbid) values = {} fieldIDs = {} if fieldNames and fieldNames.is_a?( String ) values[ fieldNames ] = [] fieldID = lookupFieldIDByName( fieldNames ) if fieldID fieldIDs[ fieldNames ] = fieldID elsif fieldNames.match(/[0-9]+/) # assume fieldNames is a field ID fieldIDs[ fieldNames ] = fieldNames end elsif fieldNames and fieldNames.is_a?( Array ) fieldNames.each{ |name| if name values[ name ] = [] fieldID = lookupFieldIDByName( name ) if fieldID fieldIDs[ fieldID ] = name elsif name.match(/[0-9]+/) # assume name is a field ID fieldIDs[ name ] = name end end } elsif fieldNames.nil? getFieldNames(dbid).each{|name| values[ name ] = [] fieldID = lookupFieldIDByName( name ) fieldIDs[ fieldID ] = name } end if clist clist << "." clist = fieldIDs.keys.join('.') elsif qid.nil? and qname.nil? clist = fieldIDs.keys.join('.') end if clist clist = clist.split('.') clist.uniq! clist = clist.join(".") end doQuery( dbid, query, qid, qname, clist, slist, fmt, ) if @records and values.length > 0 and fieldIDs.length > 0 @records.each { |r| if r.is_a?( REXML::Element) and r.name == "record" values.each{ |k,v| v << "" } r.each{ |f| if f.is_a?( REXML::Element) and f.name == "f" fid = f.attributes[ "id" ] name = fieldIDs[ fid ] if fid if name and values[ name ] v = values[ name ] v[-1] = f.text if v and f.has_text? end end } end } end end if values and block_given? values.each{ |field, values| yield field, values } else values end end |
#getAllValuesForFieldsAsArray(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object Also known as: getRecordsArray
Get all the values for one or more fields from a specified table. This also formats the field values instead of returning the raw value.
3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3429 def getAllValuesForFieldsAsArray( dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) ret = [] valuesForFields = getAllValuesForFields(dbid, fieldNames, query, qid, qname, clist, slist,fmt,) if valuesForFields fieldNames ||= getFieldNames(@dbid) if fieldNames and fieldNames[0] ret = Array.new(valuesForFields[fieldNames[0]].length) fieldType = {} fieldNames.each{|field|fieldType[field]=lookupFieldTypeByName(field)} valuesForFields.each{ |field,values| values.each_index { |i| ret[i] ||= {} ret[i][field]=formatFieldValue(values[i],fieldType[field]) } } end end ret end |
#getAllValuesForFieldsAsJSON(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object Also known as: getRecordsAsJSON
Get all the values for one or more fields from a specified table, in JSON format. This formats the field values instead of returning raw values.
3453 3454 3455 3456 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3453 def getAllValuesForFieldsAsJSON( dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) ret = getAllValuesForFieldsAsArray(dbid,fieldNames,query,qid,qname,clist,slist,fmt,) ret = JSON.generate(ret) if ret end |
#getAllValuesForFieldsAsPrettyJSON(dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object Also known as: getRecordsAsPrettyJSON
Get all the values for one or more fields from a specified table, in human-readable JSON format. This formats the field values instead of returning raw values.
3462 3463 3464 3465 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3462 def getAllValuesForFieldsAsPrettyJSON( dbid, fieldNames = nil, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) ret = getAllValuesForFieldsAsArray(dbid,fieldNames,query,qid,qname,clist,slist,fmt,) ret = JSON.pretty_generate(ret) if ret end |
#getAncestorInfo(dbid) ⇒ Object
API_GetAncestorInfo
2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2405 def getAncestorInfo( dbid ) @dbid = dbid sendRequest( :getAncestorInfo ) @ancestorappid = getResponseValue( :ancestorappid ) @oldestancestorappid = getResponseValue( :oldestancestorappid ) @qarancestorappid = getResponseValue( :qarancestorappid ) return self if @chainAPIcalls return @ancestorappid, @oldestancestorappid, @qarancestorappid end |
#getAppDTMInfo(dbid) ⇒ Object
API_GetAppDTMInfo
2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2421 def getAppDTMInfo( dbid ) @dbid = dbid sendRequest( :getAppDTMInfo ) @requestTime = getResponseElement( "RequestTime" ) @requestNextAllowedTime = getResponseElement( "RequestNextAllowedTime" ) @app = getResponseElement( "app" ) @lastModifiedTime = getResponsePathValue( "app/lastModifiedTime" ) @lastRecModTime = getResponsePathValue( "app/lastRecModTime" ) @tables = getResponseElement( :tables ) return self if @chainAPIcalls if @app and @tables and block_given? @app.each { |element| yield element } @tables.each { |element| yield element } else return @app, @tables end end |
#getApplicationVariable(variableName, dbid = nil) ⇒ Object
Get the value of an application variable.
866 867 868 869 |
# File 'lib/broker/client/QuickBaseClient.rb', line 866 def getApplicationVariable(variableName,dbid=nil) variablesHash = getApplicationVariables(dbid) variablesHash[variableName] end |
#getApplicationVariables(dbid = nil) ⇒ Object
Get a Hash of application variables.
851 852 853 854 855 856 857 858 859 860 861 862 863 |
# File 'lib/broker/client/QuickBaseClient.rb', line 851 def getApplicationVariables(dbid=nil) variablesHash = {} dbid ||= @dbid qbc.getSchema(dbid) if @variables @variables.each_element_with_attribute( "name" ){ |var| if var.name == "var" and var.has_text? variablesHash[var.attributes["name"]] = var.text end } end variablesHash end |
#getAttributeString(element) ⇒ Object
Returns a string representation of the attributes of an XML element.
464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/broker/client/QuickBaseClient.rb', line 464 def getAttributeString( element ) attributes = "" if element.is_a?( REXML::Element ) and element.has_attributes? attributes = "(" element.attributes.each { |name,value| attributes << "#{name}=#{value} " } attributes << ")" end attributes end |
#getAuthenticationXMLforRequest(api_Request) ⇒ Object
Returns the request XML for either a ticket or a username and password. The XML includes a apptoken if one has been set.
303 304 305 306 307 308 309 310 311 |
# File 'lib/broker/client/QuickBaseClient.rb', line 303 def getAuthenticationXMLforRequest( api_Request ) @authenticationXML = "" if @ticket @authenticationXML = toXML( :ticket, @ticket ) elsif @username and @password @authenticationXML = toXML( :username, @username ) + toXML( :password, @password ) end @authenticationXML << toXML( :apptoken, @apptoken ) if @apptoken end |
#getBillingStatus(dbid) ⇒ Object
API_GetBillingStatus
2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2447 def getBillingStatus( dbid ) @dbid = dbid sendRequest( :getBillingStatus ) @lastPaymentDate = getResponseValue( :lastPaymentDate ) @status = getResponseValue( :status ) return self if @chainAPIcalls return @lastPaymentDate, @status end |
#getColumnListForQuery(id, name) ⇒ Object Also known as: getColumnListForReport
Returns the clist associated with a query.
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1253 def getColumnListForQuery( id, name ) clistForQuery = nil if id query = lookupQuery( id ) elsif name query = lookupQueryByName( name ) end if query and query.elements["qyclst"] clistForQuery = query.elements["qyclst"].text.dup end clistForQuery end |
#getCriteriaForQuery(id, name) ⇒ Object Also known as: getCriteriaForReport
Returns the criteria associated with a query.
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1285 def getCriteriaForQuery( id, name ) criteriaForQuery = nil if id query = lookupQuery( id ) elsif name query = lookupQueryByName( name ) end if query and query.elements["qycrit"] criteriaForQuery = query.elements["qycrit"].text.dup end criteriaForQuery end |
#getCSVForReport(dbid, query = nil, qid = nil, qname = nil) ⇒ Object
Get the CSV data for a Report.
4567 4568 4569 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4567 def getCSVForReport(dbid,query=nil,qid=nil,qname=nil) genResultsTable(dbid,query,nil,nil,nil,nil,"csv",qid,qname) end |
#getDBforRequestURL(api_Request) ⇒ Object
Determines whether the URL for a QuickBase request is for a specific database table or not, and returns the appropriate string for that portion of the request URL.
291 292 293 294 295 296 297 298 299 |
# File 'lib/broker/client/QuickBaseClient.rb', line 291 def getDBforRequestURL( api_Request ) @dbidForRequestURL = "/db/#{@dbid}" case api_Request when :getAppDTMInfo @dbidForRequestURL = "/db/main?a=#{:getAppDTMInfo}&dbid=#{@dbid}" when :authenticate, :createDatabase, :deleteAppZip, :dumpAppZip, :getUserInfo, :findDBByname, :getOneTimeTicket, :getFileUploadToken, :grantedDBs, :installAppZip, :obStatus, :signOut @dbidForRequestURL = "/db/main" end end |
#getDBInfo(dbid) ⇒ Object
API_GetDBInfo
2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2463 def getDBInfo( dbid ) @dbid = dbid sendRequest( :getDBInfo ) @lastRecModTime = getResponseValue( :lastRecModTime ) @lastModifiedTime = getResponseValue( :lastModifiedTime ) @createdTime = getResponseValue( :createdTime ) @lastAccessTime = getResponseValue( :lastAccessTime ) @numRecords = getResponseValue( :numRecords ) @mgrID = getResponseValue( :mgrID ) @mgrName = getResponseValue( :mgrName ) @dbname = getResponseValue( :dbname) @version = getResponseValue( :version) return self if @chainAPIcalls return @lastRecModTime, @lastModifiedTime, @createdTime, @lastAccessTime, @numRecords, @mgrID, @mgrName end |
#getDBPage(dbid, pageid, pagename = nil) ⇒ Object
API_GetDBPage
2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2486 def getDBPage( dbid, pageid, pagename = nil ) @dbid, @pageid, @pagename = dbid, pageid, pagename xmlRequestData = nil if @pageid xmlRequestData = toXML( :pageid, @pageid ) elsif @pagename xmlRequestData = toXML( :pagename, @pagename ) else raise "getDBPage: missing pageid or pagename" end sendRequest( :getDBPage, xmlRequestData ) @pagebody = getResponseElement( :pagebody ) return self if @chainAPIcalls @pagebody end |
#getDBPagesAsArray(dbid) ⇒ Object Also known as: getDBPages
Get an array Pages for an application. Each item in the array is a Hash.
3151 3152 3153 3154 3155 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3151 def getDBPagesAsArray(dbid) dbPagesArray = [] iterateDBPages(dbid){|page| dbPagesArray << page } dbPagesArray end |
#getDBvar(dbid, varname) ⇒ Object
API_GetDBVar
2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2511 def getDBvar( dbid, varname ) @dbid, @varname = dbid, varname xmlRequestData = toXML( :varname, @varname ) sendRequest( :getDBvar, xmlRequestData ) @value = getResponseValue( :value ) return self if @chainAPIcalls @value end |
#getEntitlementValues(dbid) ⇒ Object
API_GetEntitlementValues
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2528 def getEntitlementValues( dbid ) @dbid = dbid sendRequest( :getEntitlementValues ) @productID = getResponseValue( :productID ) @planName = getResponseValue( :planName ) @planType = getResponseValue( :planType ) @maxUsers = getResponseValue( :maxUsers ) @currentUsers = getResponseValue( :currentUsers ) @daysRemainingTrial = getResponseValue( :daysRemainingTrial ) @entitlements = getResponseElement( :entitlements ) return self if @chainAPIcalls return @productID, @planName, @planType, @maxUsers, @currentUsers, @daysRemainingTrial, @entitlements end |
#getErrorInfoFromResponse ⇒ Object
Extracts error info from XML responses returned by QuickBase.
391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/broker/client/QuickBaseClient.rb', line 391 def getErrorInfoFromResponse if @responseXMLdoc errcode = getResponseValue( :errcode ) @errcode = errcode ? errcode : "" errtext = getResponseValue( :errtext ) @errtext = errtext ? errtext : "" errdetail = getResponseValue( :errdetail ) @errdetail = errdetail ? errdetail : "" if @errcode != "0" @lastError = "Error code: #{@errcode} text: #{@errtext}: detail: #{@errdetail}" end end @lastError end |
#getFieldChoices(dbid, fieldName = nil, fid = nil) ⇒ Object
Get an array of the existing choices for a multiple-choice text field.
4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4164 def getFieldChoices(dbid,fieldName=nil,fid=nil) getSchema(dbid) if fieldName fid = lookupFieldIDByName(fieldName) elsif not fid raise "'fieldName' or 'fid' must be specified" end field = lookupField( fid ) if field choices = [] choicesProc = proc { |element| if element.is_a?(REXML::Element) if element.name == "choice" and element.has_text? choices << element.text end end } processChildElements(field,true,choicesProc) choices = nil if choices.length == 0 choices else nil end end |
#getFieldDataPrintableValue(fid) ⇒ Object
Returns the printable value for a field returned by a getRecordInfo call.
786 787 788 789 790 791 792 793 794 795 796 |
# File 'lib/broker/client/QuickBaseClient.rb', line 786 def getFieldDataPrintableValue(fid) printable = nil if @field_data_list field_data = lookupFieldData(fid) if field_data printableElement = field_data.elements[ "printable" ] printable = printableElement.text if printableElement and printableElement.has_text? end end printable end |
#getFieldDataValue(fid) ⇒ Object
Returns the value for a field returned by a getRecordInfo call.
773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/broker/client/QuickBaseClient.rb', line 773 def getFieldDataValue(fid) value = nil if @field_data_list field_data = lookupFieldData(fid) if field_data valueElement = field_data.elements[ "value" ] value = valueElement.text if valueElement.has_text? end end value end |
#getFieldIDs(dbid = nil, exclude_built_in_fields = false) ⇒ Object
Get an array of field IDs for a table.
815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'lib/broker/client/QuickBaseClient.rb', line 815 def getFieldIDs(dbid = nil, exclude_built_in_fields = false ) fieldIDs = [] dbid ||= @dbid getSchema(dbid) if @fields @fields.each_element_with_attribute( "id" ){|f| next if exclude_built_in_fields and isBuiltInField?(f.attributes["id"]) fieldIDs << f.attributes[ "id" ].dup } end fieldIDs end |
#getFieldNames(dbid = nil, lowerOrUppercase = "", exclude_built_in_fields = false) ⇒ Object
Get an array of field names for a table.
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/broker/client/QuickBaseClient.rb', line 829 def getFieldNames( dbid = nil, lowerOrUppercase = "", exclude_built_in_fields = false ) fieldNames = [] dbid ||= @dbid getSchema(dbid) if @fields @fields.each_element_with_attribute( "id" ){ |f| next if exclude_built_in_fields and isBuiltInField?(f.attributes["id"]) if f.name == "field" if lowerOrUppercase == "lowercase" fieldNames << f.elements[ "label" ].text.downcase elsif lowerOrUppercase == "uppercase" fieldNames << f.elements[ "label" ].text.upcase else fieldNames << f.elements[ "label" ].text.dup end end } end fieldNames end |
#getFileAttachmentUsage(dbid) ⇒ Object
API_GetFileAttachmentUsage
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2549 def getFileAttachmentUsage( dbid ) @dbid = dbid sendRequest( :getFileAttachmentUsage ) @accountLimit = getResponseValue( :accountLimit ) @accountUsage = getResponseValue( :accountUsage ) @applicationLimit = getResponseValue( :applicationLimit ) @applicationUsage = getResponseValue( :applicationUsage ) return self if @chainAPIcalls return @accountLimit, @accountUsage, @applicationLimit, @applicationUsage end |
#getFileDownloadURL(dbid, rid, fid, vid = "0", org = "www", domain = "quickbase", ssl = "s") ⇒ Object
Get the URL string for downloading a file from a File Attachment field
4612 4613 4614 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4612 def getFileDownloadURL(dbid, rid, fid, vid = "0",org="www",domain="quickbase",ssl="s") "http#{ssl}://#{org}.#{domain}.com/up/#{dbid}/a/r#{rid}/e#{fid}/v#{vid}" end |
#getFileUploadToken ⇒ Object
API_GetFileUploadToken
2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2593 def getFileUploadToken() sendRequest( :getFileUploadToken) @fileUploadToken = getResponseValue( :fileUploadToken ) @userid = getResponseValue( :userid ) return self if @chainAPIcalls return @fileUploadToken, @userid end |
#getFilteredRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object Also known as: findRecords, find_records
3544 3545 3546 3547 3548 3549 3550 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3544 def getFilteredRecords( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) filteredRecords = [] iterateFilteredRecords(dbid, fieldNames, query, qid, qname, clist, slist, fmt, ){ |filteredRecord| filteredRecords << filteredRecord } filteredRecords end |
#getIDSRealm(dbid) ⇒ Object
API_GetIDSRealm (IPP only)
1826 1827 1828 1829 1830 1831 1832 1833 1834 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1826 def getIDSRealm( dbid ) @dbid = dbid sendRequest( :getIDSRealm ) @realm = getResponseValue( :realm) return self if @chainAPIcalls @realm end |
#getJoinRecords(tablesAndFields) ⇒ Object
Get an array of records from two or more tables and/or queries with the same value in a ‘join’ field. The ‘joinfield’ does not have to have the same name in each table. Fields with the same name in each table will be merged, with the value from the last table being assigned. This is similar to an SQL JOIN.
3669 3670 3671 3672 3673 3674 3675 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3669 def getJoinRecords(tablesAndFields) joinRecords = [] iterateJoinRecords(tablesAndFields) { |joinRecord| joinRecords << joinRecord.dup } joinRecords end |
#getNumRecords(dbid) ⇒ Object
API_GetNumRecords
2567 2568 2569 2570 2571 2572 2573 2574 2575 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2567 def getNumRecords( dbid ) @dbid = dbid sendRequest( :getNumRecords ) @num_records = getResponseValue( :num_records ) return self if @chainAPIcalls @num_records end |
#getNumTables(dbid) ⇒ Object
Get the number of child tables of an application
986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/broker/client/QuickBaseClient.rb', line 986 def getNumTables(dbid) numTables = 0 dbid ||= @dbid if getSchema(dbid) if @chdbids chdbidArray = findElementsByAttributeName( @chdbids, "name" ) numTables = chdbidArray.length end end numTables end |
#getOneTimeTicket ⇒ Object
API_GetOneTimeTicket
2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2581 def getOneTimeTicket() sendRequest( :getOneTimeTicket ) @ticket = getResponseValue( :ticket ) @userid = getResponseValue( :userid ) return self if @chainAPIcalls return @ticket, @userid end |
#getQueryRequestXML(query = nil, qid = nil, qname = nil) ⇒ Object
Builds the request XML for retrieving the results of a query.
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1234 def getQueryRequestXML( query = nil, qid = nil, qname = nil ) @query = @qid = @qname = nil if query @query = query == "" ? "{'0'.CT.''}" : query xmlRequestData = toXML( :query, @query ) elsif qid @qid = qid xmlRequestData = toXML( :qid, @qid ) elsif qname @qname = qname xmlRequestData = toXML( :qname, @qname ) else @query = "{'0'.CT.''}" xmlRequestData = toXML( :query, @query ) end xmlRequestData end |
#getRealmForDbid(dbid) ⇒ Object
Given a DBID, get the QuickBase realm it is in.
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1016 def getRealmForDbid(dbid) @realm = nil if USING_HTTPCLIENT begin httpclient = HTTPClient.new resp = httpclient.get("https://www.quickbase.com/db/#{dbid}") location = resp.header['Location'][0] location.sub!("https://","") parts = location.split(/\./) @realm = parts[0] rescue StandardError => error @realm = nil end else raise "Please get the HTTPClient gem: gem install httpclient" end @realm end |
#getRecord(rid, dbid = @dbid, fieldNames = nil) ⇒ Object
Get a record as a Hash, using the record id and dbid . e.g. getRecord(“24105”,“8emtadvk”){|myRecord| p myRecord}
3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3108 def getRecord(rid, dbid = @dbid, fieldNames = nil) rec = nil fieldNames ||= getFieldNames(dbid) iterateRecords(dbid, fieldNames,"{'3'.EX.'#{rid}'}"){|r| rec = r } if block_given? yield rec else rec end end |
#getRecordAsHTML(dbid, rid, jht = nil, dfid = nil) ⇒ Object
API_GetRecordAsHTML
2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2605 def getRecordAsHTML( dbid, rid, jht = nil, dfid = nil ) @dbid, @rid, @jht, @dfid = dbid, rid, jht, dfid xmlRequestData = toXML( :rid, @rid ) xmlRequestData << toXML( :jht, "1" ) if @jht xmlRequestData << toXML( :dfid, @dfid ) if @dfid sendRequest( :getRecordAsHTML, xmlRequestData ) @HTML = @responseXML return self if @chainAPIcalls @HTML end |
#getRecordInfo(dbid, rid) ⇒ Object
API_GetRecordInfo
2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2625 def getRecordInfo( dbid, rid ) @dbid, @rid = dbid, rid xmlRequestData = toXML( :rid , @rid ) sendRequest( :getRecordInfo, xmlRequestData ) @num_fields = getResponseValue( :num_fields ) @update_id = getResponseValue( :update_id ) @rid = getResponseValue( :rid ) @field_data_list = getResponseElements( "qdbapi/field" ) return self if @chainAPIcalls if block_given? @field_data_list.each { |field| yield field } else return @num_fields, @update_id, @field_data_list end end |
#getRecords(rids, dbid = @dbid, fieldNames = nil) ⇒ Object
Get an array of records as Hashes, using the record ids and dbid . e.g. getRecords(,“8emtadvk”){|myRecord| p myRecord}
3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3121 def getRecords(rids, dbid = @dbid, fieldNames = nil) records = [] if rids.length > 0 query = "" rids.each{|rid| query << "{'3'.EX.'#{rid}'}OR"} query[-2] = "" fieldNames ||= getFieldNames(dbid) iterateRecords(dbid,fieldNames,query){|r| records << r } end if block_given? records.each{|rec|yield rec} else records end end |
#getReportNames(dbid = @dbid) ⇒ Object
Get a list of the names of the reports (i.e. queries) for a table.
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 |
# File 'lib/broker/client/QuickBaseClient.rb', line 999 def getReportNames(dbid = @dbid) reportNames = [] getSchema(dbid) if @queries queriesProc = proc { |element| if element.is_a?(REXML::Element) if element.name == "qyname" and element.has_text? reportNames << element.text end end } processChildElements(@queries,true,queriesProc) end reportNames end |
#getResponseElement(path) ⇒ Object
Gets the element at an Xpath in the XML from QuickBase.
456 457 458 459 460 461 |
# File 'lib/broker/client/QuickBaseClient.rb', line 456 def getResponseElement( path ) if path and @responseXMLdoc @responseElement = @responseXMLdoc.root.elements[ path.to_s ] end @responseElement end |
#getResponseElements(path) ⇒ Object
Gets an array of elements at an Xpath in the XML from QuickBase.
448 449 450 451 452 453 |
# File 'lib/broker/client/QuickBaseClient.rb', line 448 def getResponseElements( path ) if path and @responseXMLdoc @responseElements = @responseXMLdoc.get_elements( path.to_s ) end @responseElements end |
#getResponsePathValue(path) ⇒ Object
Gets the value of a field using an XPath spec., e.g. field/name
430 431 432 433 434 435 436 437 |
# File 'lib/broker/client/QuickBaseClient.rb', line 430 def getResponsePathValue( path ) @fieldValue = "" e = getResponseElement( path ) if e and e.is_a?( REXML::Element ) and e.has_text? @fieldValue = e.text end @fieldValue end |
#getResponsePathValues(path) ⇒ Object
Gets an array of values at an Xpath in the XML from QuickBase.
440 441 442 443 444 445 |
# File 'lib/broker/client/QuickBaseClient.rb', line 440 def getResponsePathValues( path ) @fieldValue = "" e = getResponseElements( path ) e.each{ |e| @fieldValue << e.text if e and e.is_a?( REXML::Element ) and e.has_text? } @fieldValue end |
#getResponseValue(field) ⇒ Object
Gets the value for a specific field at the top level of the XML returned from QuickBase.
420 421 422 423 424 425 426 427 |
# File 'lib/broker/client/QuickBaseClient.rb', line 420 def getResponseValue( field ) @fieldValue = nil if field and @responseXMLdoc @fieldValue = @responseXMLdoc.root.elements[ field.to_s ] @fieldValue = fieldValue.text if fieldValue and fieldValue.has_text? end @fieldValue end |
#getRoleInfo(dbid) ⇒ Object
API_GetRoleInfo
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2651 def getRoleInfo( dbid ) @dbid = dbid sendRequest( :getRoleInfo ) @roles = getResponseElement( :roles ) return self if @chainAPIcalls if block_given? role_list = getResponseElements( "qdbapi/roles/role" ) if role_list role_list.each {|role| yield role} else yield nil end else @roles end end |
#getSchema(dbid) ⇒ Object
API_GetSchema
2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2677 def getSchema( dbid ) @dbid = dbid if @cacheSchemas and @cachedSchemas and @cachedSchemas[dbid] @responseXMLdoc = @cachedSchemas[dbid] else sendRequest( :getSchema ) if @cacheSchemas and @requestSucceeded @cachedSchemas ||= {} @cachedSchemas[dbid] ||= @responseXMLdoc.dup end end @chdbids = getResponseElement( "table/chdbids" ) @variables = getResponseElement( "table/variables" ) @fields = getResponseElement( "table/fields" ) @queries = getResponseElement( "table/queries" ) @table = getResponseElement( :table ) @key_fid = getResponseElement( "table/original/key_fid" ) @key_fid = @key_fid.text if @key_fid and @key_fid.has_text? return self if @chainAPIcalls if @table and block_given? @table.each { |element| yield element } else @table end end |
#getServerStatus ⇒ Object
Get the status of the QuickBase server.
2730 2731 2732 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2730 def getServerStatus obStatus end |
#getSortListForQuery(id, name) ⇒ Object Also known as: getSortListForReport
Returns the slist associated with a query.
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1269 def getSortListForQuery( id, name ) slistForQuery = nil if id query = lookupQuery( id ) elsif name query = lookupQueryByName( name ) end if query and query.elements["qyslst"] slistForQuery = query.elements["qyslst"].text.dup end slistForQuery end |
#getSummaryRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Collect summary records into an array.
3846 3847 3848 3849 3850 3851 3852 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3846 def getSummaryRecords( dbid, fieldNames,query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) summaryRecords = [] iterateSummaryRecords(dbid, fieldNames,query, qid, qname, clist, slist, fmt = "structured", ){|summaryRecord| summaryRecords << summaryRecord.dup } summaryRecords end |
#getTableIDs(dbid) ⇒ Object
Get a list of the dbids of the child tables of an application.
970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
# File 'lib/broker/client/QuickBaseClient.rb', line 970 def getTableIDs(dbid) tableIDs = [] dbid ||= @dbid getSchema(dbid) if @chdbids chdbidArray = findElementsByAttributeName( @chdbids, "name" ) chdbidArray.each{ |chdbid| if chdbid.has_text? tableIDs << chdbid.text end } end tableIDs end |
#getTableName(dbid) ⇒ Object
Get the name of a table given its id.
933 934 935 936 937 938 939 940 |
# File 'lib/broker/client/QuickBaseClient.rb', line 933 def getTableName(dbid) tableName = nil dbid ||= @dbid if getSchema(dbid) tableName = getResponseElement( "table/name" ).text end tableName end |
#getTableNames(dbid, lowercaseOrUpperCase = "") ⇒ Object
Get a list of the names of the child tables of an application.
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
# File 'lib/broker/client/QuickBaseClient.rb', line 943 def getTableNames(dbid, lowercaseOrUpperCase = "") tableNames = [] dbid ||= @dbid getSchema(dbid) if @chdbids chdbidArray = findElementsByAttributeName( @chdbids, "name" ) chdbidArray.each{ |chdbid| if chdbid.has_text? dbid = chdbid.text getSchema( dbid ) name = getResponseElement( "table/name" ) if name and name.has_text? if lowercaseOrUpperCase == "lowercase" tableNames << name.text.downcase elsif lowercaseOrUpperCase == "uppercase" tableNames << name.text.upcase else tableNames << name.text.dup end end end } end tableNames end |
#getUnionRecords(tables, fieldNames) ⇒ Object
Returns an Array of values from the same fields in two or more tables and/or queries. The merged records will be unique. This is similar to an SQL UNION.
3728 3729 3730 3731 3732 3733 3734 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3728 def getUnionRecords(tables,fieldNames) unionRecords = [] iterateUnionRecords(tables,fieldNames) { |unionRecord| unionRecords << unionRecord.dup } unionRecords end |
#getUserInfo(email = nil) ⇒ Object
API_GetUserInfo
2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2735 def getUserInfo( email = nil ) @email = email if @email and @email.length > 0 xmlRequestData = toXML( :email, @email) sendRequest( :getUserInfo, xmlRequestData ) else sendRequest( :getUserInfo ) @login = getResponsePathValue( "user/login" ) end @name = getResponsePathValue( "user/name" ) @firstName = getResponsePathValue( "user/firstName" ) @lastName = getResponsePathValue( "user/lastName" ) @login = getResponsePathValue( "user/login" ) @email = getResponsePathValue( "user/email" ) @screenName = getResponsePathValue( "user/screenName" ) @externalAuth = getResponsePathValue( "user/externalAuth" ) @user = getResponseElement( :user ) @userid = @user.attributes["id"] if @user return self if @chainAPIcalls @user end |
#getUserRole(dbid, userid, inclgrps = nil) ⇒ Object
API_GetUserRole
2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2761 def getUserRole( dbid, userid, inclgrps = nil ) @dbid, @userid, @inclgrps = dbid, userid, inclgrps xmlRequestData = toXML( :userid , @userid ) xmlRequestData << toXML( :inclgrps , "1" ) if @inclgrps sendRequest( :getUserRole, xmlRequestData ) @user = getResponseElement( :user ) @userid = @user.attributes["id"] if @user @username = getResponsePathValue("user/name") @role = getResponseElement( "user/roles/role" ) @roleid = @role.attributes["id"] if @role @rolename = getResponsePathValue("user/roles/role/name") access = getResponseElement("user/roles/role/access") @accessid = access.attributes["id"] if access @access = getResponsePathValue("user/roles/role/access") if access member = getResponseElement("user/roles/role/member") @member_type = member.attributes["type"] if member @member = getResponsePathValue("user/roles/role/member") if member return self if @chainAPIcalls return @user, @role end |
#grantedDBs(withembeddedtables = nil, excludeparents = nil, adminOnly = nil, includeancestors = nil, showAppData = nil) ⇒ Object
API_GrantedDBs
2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2789 def grantedDBs( = nil, excludeparents = nil, adminOnly = nil, includeancestors = nil, showAppData = nil ) @withembeddedtables, @excludeparents, @adminOnly, @includeancestors, @showAppData = , excludeparents, adminOnly, includeancestors, showAppData xmlRequestData = "" xmlRequestData << toXML( :withembeddedtables, @withembeddedtables ) if @withembeddedtables xmlRequestData << toXML( "Excludeparents", @excludeparents ) if @excludeparents xmlRequestData << toXML( :adminOnly, @adminOnly ) if @adminOnly xmlRequestData << toXML( :includeancestors, @includeancestors ) if @includeancestors xmlRequestData << toXML( :showAppData, @showAppData ) if @showAppData sendRequest( :grantedDBs, xmlRequestData ) @databases = getResponseElement( :databases ) return self if @chainAPIcalls if @databases and block_given? @databases.each { |element| yield element } else @databases end end |
#importCSVFile(filename, dbid = @dbid, targetFieldNames = nil, validateLines = true) ⇒ Object
Add records from lines in a CSV file. If dbid is not specified, the active table will be used. values in subsequent lines. The file must not contain commas inside field names or values.
4397 4398 4399 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4397 def importCSVFile( filename, dbid = @dbid, targetFieldNames = nil, validateLines = true ) importSVFile( filename, ",", dbid, targetFieldNames, validateLines ) end |
#importFromCSV(dbid, records_csv, clist, skipfirst = nil, msInUTC = nil) ⇒ Object
API_ImportFromCSV
2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2814 def importFromCSV( dbid, records_csv, clist, skipfirst = nil, msInUTC = nil ) @dbid, @records_csv, @clist, @skipfirst, @msInUTC = dbid, records_csv, clist, skipfirst, msInUTC @clist ||= "0" xmlRequestData = toXML( :records_csv, @records_csv ) xmlRequestData << toXML( :clist, @clist ) xmlRequestData << toXML( :skipfirst, "1" ) if @skipfirst xmlRequestData << toXML( :msInUTC, "1" ) if @msInUTC sendRequest( :importFromCSV, xmlRequestData ) @num_recs_added = getResponseValue( :num_recs_added ) @num_recs_input = getResponseValue( :num_recs_input ) @num_recs_updated = getResponseValue( :num_recs_updated ) @rids = getResponseElement( :rids ) @update_id = getResponseValue( :update_id ) return self if @chainAPIcalls if block_given? @rids.each{ |rid| yield rid } else return @num_recs_added, @num_recs_input, @num_recs_updated, @rids, @update_id end end |
#importFromExcel(dbid, excelFilename, lastColumn = 'j', lastDataRow = 0, worksheetNumber = 1, fieldNameRow = 1, firstDataRow = 2, firstColumn = 'a') ⇒ Object
Import data directly from an Excel file into a table The field names are expected to be on line 1 by default. By default, data will be read starting from row 2 and ending on the first empty row. Commas in field values will be converted to semi-colons. e.g. importFromExcel( @dbid, “my_spreadsheet.xls”, ‘h’ )
4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4315 def importFromExcel( dbid,excelFilename,lastColumn = 'j',lastDataRow = 0,worksheetNumber = 1,fieldNameRow = 1,firstDataRow = 2,firstColumn = 'a') num_recs_imported = 0 if require 'win32ole' if FileTest.readable?( excelFilename ) getSchema( dbid ) excel = WIN32OLE::new( 'Excel.Application' ) workbook = excel.Workbooks.Open( excelFilename ) worksheet = workbook.Worksheets( worksheetNumber ) worksheet.Select fieldNames = nil rows = nil skipFirstRow = nil if fieldNameRow > 0 fieldNames = worksheet.Range("#{firstColumn}#{fieldNameRow}:#{lastColumn}#{fieldNameRow}")['Value'] skipFirstRow = true end if lastDataRow <= 0 lastDataRow = 1 while worksheet.Range("#{firstColumn}#{lastDataRow}")['Value'] lastDataRow += 1 end end if firstDataRow > 0 and lastDataRow >= firstDataRow rows = worksheet.Range("#{firstColumn}#{firstDataRow}:#{lastColumn}#{lastDataRow}")['Value'] end workbook.Close excel.Quit csvData = "" targetFieldIDs = [] if fieldNames and fieldNames.length > 0 fieldNames.each{ |fieldNameRow| fieldNameRow.each{ |fieldName| if fieldName fieldName.gsub!( ",", ";" ) #strip commas csvData << "#{fieldName}," targetFieldIDs << lookupFieldIDByName( fieldName ) else csvData << "," end } csvData[-1] = "\n" } end rows.each{ |row| row.each{ |cell| if cell cell = cell.to_s cell.gsub!( ",", ";" ) #strip commas csvData << "#{cell}," else csvData << "," end } csvData[-1] = "\n" } clist = targetFieldIDs.join( '.' ) num_recs_imported = importFromCSV( dbid, formatImportCSV( csvData ), clist, skipFirstRow ) else raise "importFromExcel: '#{excelFilename}' is not a readable file." end end num_recs_imported end |
#importSVFile(filename, fieldSeparator = ",", dbid = @dbid, targetFieldNames = nil, validateLines = true) ⇒ Object
Add records from lines in a separated values text file, using a specified field name/value separator.
e.g. importSVFile( “contacts.txt”, “::”, “dhnju5y7”, [ “Name”, “Phone”, “Email” ] )
If targetFieldNames is not specified, the first line in the file must be a list of field names that match the values in subsequent lines.
If there are no commas in any of the field names or values, the file will be treated as if it were a CSV file and imported using the QuickBase importFromCSV API call. Otherwise, records will be added using addRecord() for each line. Lines with the wrong number of fields will be skipped. Double-quoted fields can contain the field separator, e.g. f1,“f,2”,f3 Spaces will not be trimmed from the beginning or end of field values.
4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4419 def importSVFile( filename, fieldSeparator = ",", dbid = @dbid, targetFieldNames = nil, validateLines = true ) num_recs_imported = 0 if FileTest.readable?( filename ) if dbid getSchema( dbid ) targetFieldIDs = [] if targetFieldNames and targetFieldNames.is_a?( Array ) targetFieldNames.each{ |fieldName| targetFieldIDs << lookupFieldIDByName( fieldName ) } return 0 if targetFieldIDs.length != targetFieldNames.length end useAddRecord = false invalidLines = [] validLines = [] linenum = 1 IO.foreach( filename ){ |line| if fieldSeparator != "," and line.index( "," ) useAddRecord = true end if linenum == 1 and targetFieldNames.nil? targetFieldNames = splitString( line, fieldSeparator ) targetFieldNames.each{ |fieldName| fieldName.strip! targetFieldIDs << lookupFieldIDByName( fieldName ) } return 0 if targetFieldIDs.length != targetFieldNames.length else fieldValues = splitString( line, fieldSeparator ) if !validateLines validLines[ linenum ] = fieldValues elsif validateLines and fieldValues.length == targetFieldIDs.length validLines[ linenum ] = fieldValues else invalidLines[ linenum ] = fieldValues end end linenum += 1 } if targetFieldIDs.length > 0 and validLines.length > 0 if useAddRecord validLines.each{ |line| clearFieldValuePairList targetFieldIDs.each_index{ |i| addFieldValuePair( nil, targetFieldIDs[i], nil, line[i] ) } addRecord( dbid, @fvlist ) num_recs_imported += 1 if @rid } else csvdata = "" validLines.each{ |line| if line csvdata << line.to_csv # these 2 lines don't handle columns with commas, ex "My field, needs escaped" # using CSV library's to_csv will correctly escape any quoted fields to preserve the commas # and not mistake them for wrong fields #csvdata << line.join( ',' ) #csvdata << "\n" end } clist = targetFieldIDs.join( '.' ) num_recs_imported = importFromCSV( dbid, formatImportCSV( csvdata ), clist ) end end end end return num_recs_imported, invalidLines end |
#importTSVFile(filename, dbid = @dbid, targetFieldNames = nil, validateLines = true) ⇒ Object
Import records from a text file in Tab-Separated-Values format.
4402 4403 4404 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4402 def importTSVFile( filename, dbid = @dbid, targetFieldNames = nil, validateLines = true ) importSVFile( filename, "\t", dbid, targetFieldNames, validateLines ) end |
#installAppZip(dbid) ⇒ Object
API_InstallAppZip
2845 2846 2847 2848 2849 2850 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2845 def installAppZip( dbid ) @dbid = dbid sendRequest( :installAppZip ) return self if @chainAPIcalls @responseCode end |
#isAverageField?(fieldName) ⇒ Boolean
Returns whether a field will show an Average on reports.
541 542 543 544 |
# File 'lib/broker/client/QuickBaseClient.rb', line 541 def isAverageField?(fieldName) does_average = lookupFieldPropertyByName(fieldName,"does_average") ret = does_average and does_average == "1" end |
#isBuiltInField?(fid) ⇒ Boolean
Returns whether a field ID is the ID for a built-in field
553 554 555 |
# File 'lib/broker/client/QuickBaseClient.rb', line 553 def isBuiltInField?( fid ) fid.to_i < 6 end |
#isHTMLRequest?(api_Request) ⇒ Boolean
Returns whether a request will return HTML rather than XML.
314 315 316 317 318 319 320 321 |
# File 'lib/broker/client/QuickBaseClient.rb', line 314 def isHTMLRequest?( api_Request ) ret = false case api_Request when :genAddRecordForm, :genResultsTable, :getRecordAsHTML ret = true end ret end |
#isRecordidField?(fid) ⇒ Boolean
Returns whether a field ID is the ID for the key field in a QuickBase table.
547 548 549 550 |
# File 'lib/broker/client/QuickBaseClient.rb', line 547 def isRecordidField?( fid ) fields = lookupFieldsByType( "recordid" ) (fields and fields.last and fields.last.attributes[ "id" ] == fid) end |
#isTotalField?(fieldName) ⇒ Boolean
Returns whether a field will show a Total on reports.
535 536 537 538 |
# File 'lib/broker/client/QuickBaseClient.rb', line 535 def isTotalField?(fieldName) does_total = lookupFieldPropertyByName(fieldName,"does_total") ret = does_total and does_total == "1" end |
#isValidFieldProperty?(property) ⇒ Boolean
Returns whether a given string represents a valid QuickBase field property.
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1059 def isValidFieldProperty?( property ) if @validFieldProperties.nil? @validFieldProperties = %w{ allow_new_choices allowHTML appears_by_default append_only blank_is_zero bold carrychoices comma_start cover_text currency_format currency_symbol decimal_places default_kind default_today default_today default_value display_dow display_graphic display_month display_relative display_time display_today display_user display_zone does_average does_total doesdatacopy exact fieldhelp find_enabled foreignkey format formula has_extension hours24 label max_versions maxlength nowrap num_lines required sort_as_given source_fid source_fieldname target_dbid target_dbname target_fid target_fieldname unique units use_new_window width } end ret = @validFieldProperties.include?( property ) end |
#isValidFieldType?(type) ⇒ Boolean
Returns whether a given string represents a valid QuickBase field type.
1046 1047 1048 1049 1050 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1046 def isValidFieldType?( type ) @validFieldTypes ||= %w{ checkbox dblink date duration email file fkey float formula currency lookup multiuserid phone percent rating recordid text timeofday timestamp url userid icalendarbutton } @validFieldTypes.include?( type ) end |
#iterateDBPages(dbid) ⇒ Object
Loop through the list of Pages for an application
3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3138 def iterateDBPages(dbid) listDBPages(dbid){|page| if page.is_a?( REXML::Element) and page.name == "page" @pageid = page.attributes["id"] @pagetype = page.attributes["type"] @pagename = page.text if page.has_text? @page = { "name" => @pagename, "id" => @pageid, "type" => @pagetype } yield @page end } end |
#iterateFilteredRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3513 def iterateFilteredRecords( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) fields = [] regexp = {} fieldNames.each{|field| if field.is_a?(Hash) fields << field.keys[0] regexp[field.keys[0]] = field.values[0] elsif field.is_a?(String) fields << field end } regexp = nil if regexp.length == 0 iterateRecords(dbid,fields,query,qid,qname,clist,slist,fmt,){|record| if regexp match = true fields.each{|field| if regexp[field] unless record[field] and record[field].match(regexp[field]) match = false break end end } yield record if match else yield record end } end |
#iterateJoinRecords(tablesAndFields) ⇒ Object
Get records from two or more tables and/or queries with the same value in a ‘join’ field and loop through the joined results. The ‘joinfield’ does not have to have the same name in each table. Fields with the same name in each table will be merged, with the value from the last table being assigned. This is similar to an SQL JOIN.
3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3560 def iterateJoinRecords(tablesAndFields) raise "'iterateJoinRecords' must be called with a block." if not block_given? if tablesAndFields and tablesAndFields.is_a?(Array) # get all the records from QuickBase that we might need - fewer API calls is faster than processing extra data tables = [] numRecords = {} tableRecords = {} joinfield = {} tablesAndFields.each{|tableAndFields| if tableAndFields and tableAndFields.is_a?(Hash) if tableAndFields["dbid"] and tableAndFields["fields"] and tableAndFields["joinfield"] if tableAndFields["fields"].is_a?(Array) tables << tableAndFields["dbid"] joinfield[tableAndFields["dbid"]] = tableAndFields["joinfield"] tableAndFields["fields"] << tableAndFields["joinfield"] if not tableAndFields["fields"].include?(tableAndFields["joinfield"]) tableRecords[tableAndFields["dbid"]] = getAllValuesForFields( tableAndFields["dbid"], tableAndFields["fields"], tableAndFields["query"], tableAndFields["qid"], tableAndFields["qname"], tableAndFields["clist"], tableAndFields["slist"], "structured", tableAndFields["options"]) numRecords[tableAndFields["dbid"]] = tableRecords[tableAndFields["dbid"]][tableAndFields["fields"][0]].length else raise "'tableAndFields[\"fields\"]' must be an Array of fields to retrieve." end else raise "'tableAndFields' is missing one of 'dbid', 'fields' or 'joinfield'." end else raise "'tableAndFields' must be a Hash" end } numTables = tables.length # go through the records in the first table (0..(numRecords[tables[0]]-1)).each{|i| # get the value of the join field in each record of the first table joinfieldValue = tableRecords[tables[0]][joinfield[tables[0]]][i] # save the other tables' record indices of records containing the joinfield value tableIndices = [] (1..(numTables-1)).each{|tableNum| tableIndices[tableNum] = [] (0..(numRecords[tables[tableNum]]-1)).each{|j| if joinfieldValue == tableRecords[tables[tableNum]][joinfield[tables[tableNum]]][j] tableIndices[tableNum] << j end } } # if all the tables had at least one matching record, build a joined record and yield it buildJoinRecord = true (1..(numTables-1)).each{|tableNum| buildJoinRecord = false if not tableIndices[tableNum].length > 0 } if buildJoinRecord joinRecord = {} tableRecords[tables[0]].each_key{|field| joinRecord[field] = tableRecords[tables[0]][field][i] } # nested loops for however many tables we have currentIndex = [] numTables.times{ currentIndex << 0 } loop { (1..(numTables-1)).each{|tableNum| index = tableIndices[tableNum][currentIndex[tableNum]] tableRecords[tables[tableNum]].each_key{|field| joinRecord[field] = tableRecords[tables[tableNum]][field][index] } if currentIndex[tableNum] == tableIndices[tableNum].length-1 currentIndex[tableNum] = -1 else currentIndex[tableNum] += 1 end if tableNum == numTables-1 yield joinRecord end } finishLooping = true (1..(numTables-1)).each{|tableNum| finishLooping = false if currentIndex[tableNum] != -1 } break if finishLooping } end } else raise "'tablesAndFields' must be Array of Hashes of table query parameters." end end |
#iterateRecordInfos(dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Loop through a list of records returned from a query. Each record will contain all the fields with values formatted for readability by QuickBase via API_GetRecordInfo.
3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3856 def iterateRecordInfos(dbid, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil) getSchema(dbid) recordIDFieldName = lookupFieldNameFromID("3") fieldNames = getFieldNames fieldIDs = {} fieldNames.each{|name|fieldIDs[name] = lookupFieldIDByName(name)} iterateRecords(dbid, [recordIDFieldName], query, qid, qname, clist, slist, fmt, ){|r| getRecordInfo(dbid,r[recordIDFieldName]) fieldValues = {} fieldIDs.each{|k,v| fieldValues[k] = getFieldDataPrintableValue(v) fieldValues[k] ||= getFieldDataValue(v) } yield fieldValues } end |
#iterateRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3492 def iterateRecords( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) if block_given? queryResults = getAllValuesForFields(dbid,fieldNames,query,qid,qname,clist,slist,fmt,) if queryResults numRecords = 0 numRecords = queryResults[fieldNames[0]].length if queryResults[fieldNames[0]] (0..(numRecords-1)).each{|recNum| recordHash = {} fieldNames.each{|fieldName| recordHash[fieldName]=queryResults[fieldName][recNum] } yield recordHash } end else raise "'iterateRecords' must be called with a block." end end |
#iterateSummaryRecords(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) {|summaryRecord| ... } ⇒ Object
(The QuickBase API does not supply a method for this.) Loop through summary records, like the records in a QuickBase Summary report. Fields with ‘Total’ and ‘Average’ checked in the target table will be summed and/or averaged. Other fields with duplicate values will be merged into a single ‘record’. The results will be sorted by the merged fields, in ascending order. e.g. -
iterateSummaryRecords( "vavaa4sdd", ["Customer", "Amount"] ) {|record|
puts "Customer: #{record['Customer']}, Amount #{record['Amount']}
}
would print the total Amount for each Customer, sorted by Customer.
3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3746 def iterateSummaryRecords( dbid, fieldNames,query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) getSchema(dbid) slist = "" summaryRecord = {} doesTotal = {} doesAverage = {} summaryField = {} fieldType = {} fieldNames.each{ |fieldName| fieldType[fieldName] = lookupFieldTypeByName(fieldName) isSummaryField = true doesTotal[fieldName] = isTotalField?(fieldName) doesAverage[fieldName] = isAverageField?(fieldName) if doesTotal[fieldName] summaryRecord["#{fieldName}:Total"] = 0 isSummaryField = false end if doesAverage[fieldName] summaryRecord["#{fieldName}:Average"] = 0 isSummaryField = false end if isSummaryField summaryField[fieldName] = true fieldID = lookupFieldIDByName(fieldName) slist << "#{fieldID}." end } slist[-1] = "" count = 0 iterateRecords( dbid, fieldNames, query, qid, qname, clist, slist, fmt, ) { |record| summaryFieldValuesHaveChanged = false fieldNames.each{ |fieldName| if summaryField[fieldName] and record[fieldName] != summaryRecord[fieldName] summaryFieldValuesHaveChanged = true break end } if summaryFieldValuesHaveChanged summaryRecord["Count"] = count fieldNames.each{|fieldName| if doesTotal[fieldName] summaryRecord["#{fieldName}:Total"] = formatFieldValue(summaryRecord["#{fieldName}:Total"],fieldType[fieldName]) end if doesAverage[fieldName] summaryRecord["#{fieldName}:Average"] = summaryRecord["#{fieldName}:Average"]/count if count > 0 summaryRecord["#{fieldName}:Average"] = formatFieldValue(summaryRecord["#{fieldName}:Average"],fieldType[fieldName]) end } yield summaryRecord count=0 summaryRecord = {} fieldNames.each{|fieldName| if doesTotal[fieldName] summaryRecord["#{fieldName}:Total"] = 0 end if doesAverage[fieldName] summaryRecord["#{fieldName}:Average"] = 0 end } end count += 1 fieldNames.each{|fieldName| if doesTotal[fieldName] summaryRecord["#{fieldName}:Total"] += record[fieldName].to_i end if doesAverage[fieldName] summaryRecord["#{fieldName}:Average"] += record[fieldName].to_i end if summaryField[fieldName] summaryRecord[fieldName] = record[fieldName] end } } summaryRecord["Count"] = count fieldNames.each{|fieldName| if doesTotal[fieldName] summaryRecord["#{fieldName}:Total"] = formatFieldValue(summaryRecord["#{fieldName}:Total"],fieldType[fieldName]) end if doesAverage[fieldName] summaryRecord["#{fieldName}:Average"] = summaryRecord["#{fieldName}:Average"]/count summaryRecord["#{fieldName}:Average"] = formatFieldValue(summaryRecord["#{fieldName}:Average"],fieldType[fieldName]) end } yield summaryRecord end |
#iterateUnionRecords(tables, fieldNames) ⇒ Object
Get values from the same fields in two or more tables and/or queries and loop through the merged results. The merged records will be unique. This is similar to an SQL UNION.
3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3679 def iterateUnionRecords(tables,fieldNames) raise "'iterateUnionRecords' must be called with a block." if not block_given? if tables and tables.is_a?(Array) if fieldNames and fieldNames.is_a?(Array) tableRecords = [] tables.each{|table| if table and table.is_a?(Hash) and table["dbid"] tableRecords << getAllValuesForFields( table["dbid"], fieldNames, table["query"], table["qid"], table["qname"], table["clist"], table["slist"], "structured", table["options"]) else raise "'table' must be a Hash that includes an entry for 'dbid'." end } else raise "'fieldNames' must be an Array of field names valid in all the tables." end else raise "'tables' must be an Array of Hashes." end usedRecords = {} tableRecords.each{|queryResults| if queryResults numRecords = 0 numRecords = queryResults[fieldNames[0]].length if queryResults[fieldNames[0]] (0..(numRecords-1)).each{|recNum| recordHash = {} fieldNames.each{|fieldName| recordHash[fieldName]=queryResults[fieldName][recNum] } if not usedRecords[recordHash.values.join] usedRecords[recordHash.values.join]=true yield recordHash end } end } end |
#listDBPages(dbid) ⇒ Object
API_ListDBPages
2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2853 def listDBPages(dbid) @dbid = dbid sendRequest( :listDBPages ) @pages = getResponseValue( :pages ) return self if @chainAPIcalls if block_given? if @pages @pages.each{ |element| yield element } else yield nil end else @pages end end |
#logToFile(filename) ⇒ Object
Log requests to QuickBase and responses from QuickBase in a file. Useful for utilities that run unattended.
5015 5016 5017 |
# File 'lib/broker/client/QuickBaseClient.rb', line 5015 def logToFile( filename ) setLogger( Logger.new( filename ) ) end |
#lookupBaseFieldTypeByName(fieldName) ⇒ Object
Get a field’s base type using its name.
1362 1363 1364 1365 1366 1367 1368 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1362 def lookupBaseFieldTypeByName( fieldName ) type = "" fid = lookupFieldIDByName( fieldName ) field = lookupField( fid ) if fid type = field.attributes[ "base_type" ] if field type end |
#lookupChdbid(tableName, dbid = nil) ⇒ Object
Makes the table with the specified name the ‘active’ table, and returns the id from the table.
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
# File 'lib/broker/client/QuickBaseClient.rb', line 906 def lookupChdbid( tableName, dbid=nil ) getSchema(dbid) if dbid unmodifiedTableName = tableName.dup @chdbid = findElementByAttributeValue( @chdbids, "name", formatChdbidName( tableName ) ) if @chdbid @dbid = @chdbid.text return @dbid end if @chdbids chdbidArray = findElementsByAttributeName( @chdbids, "name" ) chdbidArray.each{ |chdbid| if chdbid.has_text? dbid = chdbid.text getSchema( dbid ) name = getResponseElement( "table/name" ) if name and name.has_text? and name.text.downcase == unmodifiedTableName.downcase @chdbid = chdbid @dbid = dbid return @dbid end end } end nil end |
#lookupField(fid) ⇒ Object
Returns the XML element for a field definition. getSchema() or doQuery() should be called before this.
752 753 754 |
# File 'lib/broker/client/QuickBaseClient.rb', line 752 def lookupField( fid ) @field = findElementByAttributeValue( @fields, "id", fid ) end |
#lookupFieldData(fid) ⇒ Object
Returns the XML element for a field returned by a getRecordInfo call.
757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
# File 'lib/broker/client/QuickBaseClient.rb', line 757 def lookupFieldData( fid ) @field_data = nil if @field_data_list @field_data_list.each{ |field| if field and field.is_a?( REXML::Element ) and field.has_elements? fieldid = field.elements[ "fid" ] if fieldid and fieldid.has_text? and fieldid.text == fid.to_s @field_data = field end end } end @field_data end |
#lookupFieldIDByName(fieldName, dbid = nil) ⇒ Object
Gets the ID for a field using the QuickBase field label. getSchema() or doQuery() should be called before this if you don’t supply the dbid.
800 801 802 803 804 805 806 807 808 809 810 811 812 |
# File 'lib/broker/client/QuickBaseClient.rb', line 800 def lookupFieldIDByName( fieldName, dbid=nil ) getSchema(dbid) if dbid ret = nil if @fields @fields.each_element_with_attribute( "id" ){ |f| if f.name == "field" and f.elements[ "label" ].text.downcase == fieldName.downcase ret = f.attributes[ "id" ].dup break end } end ret end |
#lookupFieldName(element) ⇒ Object
Returns the name of field given an “fid” XML element.
490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/broker/client/QuickBaseClient.rb', line 490 def lookupFieldName( element ) name = "" if element and element.is_a?( REXML::Element ) name = element.name if element.name == "f" and @fields fid = element.attributes[ "id" ] field = lookupField( fid ) if fid label = field.elements[ "label" ] if field name = label.text if label end end name end |
#lookupFieldNameFromID(fid, dbid = nil) ⇒ Object
Gets a field name (i.e. QuickBase field label) using a field ID. getSchema() or doQuery() should be called before this if you don’t supply the dbid.
478 479 480 481 482 483 484 485 486 487 |
# File 'lib/broker/client/QuickBaseClient.rb', line 478 def lookupFieldNameFromID( fid, dbid=nil ) getSchema(dbid) if dbid name = nil if @fields field = lookupField( fid ) if fid label = field.elements[ "label" ] if field name = label.text if label end name end |
#lookupFieldPropertyByName(fieldName, property) ⇒ Object
Returns the value of a field property, or nil.
523 524 525 526 527 528 529 530 531 532 |
# File 'lib/broker/client/QuickBaseClient.rb', line 523 def lookupFieldPropertyByName( fieldName, property ) theproperty = nil if isValidFieldProperty?(property) fid = lookupFieldIDByName( fieldName ) field = lookupField( fid ) if fid theproperty = field.elements[ property ] if field theproperty = theproperty.text if theproperty and theproperty.has_text? end theproperty end |
#lookupFieldsByType(type) ⇒ Object
Returns an array of XML field elements matching a QuickBase field type.
518 519 520 |
# File 'lib/broker/client/QuickBaseClient.rb', line 518 def lookupFieldsByType( type ) findElementsByAttributeValue( @fields, "field_type", type ) end |
#lookupFieldType(element) ⇒ Object
Returns a QuickBase field type, given an XML “fid” element.
505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/broker/client/QuickBaseClient.rb', line 505 def lookupFieldType( element ) type = "" if element and element.is_a?( REXML::Element ) if element.name == "f" and @fields fid = element.attributes[ "id" ] field = lookupField( fid ) if fid type = field.attributes[ "field_type" ] if field end end type end |
#lookupFieldTypeByName(fieldName) ⇒ Object
Get a field’s type using its name.
1371 1372 1373 1374 1375 1376 1377 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1371 def lookupFieldTypeByName( fieldName ) type = "" fid = lookupFieldIDByName( fieldName ) field = lookupField( fid ) if fid type = field.attributes[ "field_type" ] if field type end |
#lookupQuery(qid, dbid = nil) ⇒ Object
Returns the XML element for a query with the specified ID. getSchema() or doQuery() should be called before this if you don’t supply the dbid.
878 879 880 881 |
# File 'lib/broker/client/QuickBaseClient.rb', line 878 def lookupQuery( qid, dbid=nil ) getSchema(dbid) if dbid @query = findElementByAttributeValue( @queries, "id", qid ) end |
#lookupQueryByName(name, dbid = nil) ⇒ Object
Returns the XML element for a query with the specified ID. getSchema() or doQuery() should be called before this if you don’t supply the dbid.
885 886 887 888 889 890 891 892 893 894 895 |
# File 'lib/broker/client/QuickBaseClient.rb', line 885 def lookupQueryByName( name, dbid=nil ) getSchema(dbid) if dbid if @queries @queries.each_element_with_attribute( "id" ){|q| if q.name == "query" and q.elements["qyname"].text.downcase == name.downcase return q end } end nil end |
#lookupRecord(rid) ⇒ Object
Returns the XML element for a record with the specified ID.
872 873 874 |
# File 'lib/broker/client/QuickBaseClient.rb', line 872 def lookupRecord( rid ) @record = findElementByAttributeValue( @records, "id", rid ) end |
#makeCSVFileForReport(filename, dbid = @dbid, query = nil, qid = nil, qname = nil) ⇒ Object
Create a CSV file using the records for a Report.
4561 4562 4563 4564 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4561 def makeCSVFileForReport(filename,dbid=@dbid,query=nil,qid=nil,qname=nil) csv = getCSVForReport(dbid,query,qid,qname) File.open(filename,"w"){|f|f.write(csv || "")} end |
#makeSVFile(filename, fieldSeparator = ",", dbid = @dbid, query = nil, qid = nil, qname = nil) ⇒ Object
Make a CSV file using the results of a query. Specify a different separator in the second paramater. Fields containing the separator will be double-quoted.
e.g. makeSVFile( “contacts.txt”, “t”, nil ) e.g. makeSVFile( “contacts.txt”, “,”, “dhnju5y7”, nil, nil, “List Changes” )
4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4503 def makeSVFile( filename, fieldSeparator = ",", dbid = @dbid, query = nil, qid = nil, qname = nil ) File.open( filename, "w" ) { |file| if dbid doQuery( dbid, query, qid, qname ) end if @records and @fields # ------------- write field names on first line ---------------- output = "" fieldNamesBlock = proc { |element| if element.is_a?(REXML::Element) and element.name == "label" and element.has_text? output << "#{element.text}#{fieldSeparator}" end } processChildElements( @fields, true, fieldNamesBlock ) output << "\n" output.sub!( "#{fieldSeparator}\n", "\n" ) file.write( output ) # ------------- write records ---------------- output = "" valuesBlock = proc { |element| if element.is_a?(REXML::Element) if element.name == "record" if output.length > 1 output << "\n" output.sub!( "#{fieldSeparator}\n", "\n" ) file.write( output ) end output = "" elsif element.name == "f" if element.has_text? text = element.text text.gsub!("<BR/>","\n") text = "\"#{text}\"" if text.include?( fieldSeparator ) output << "#{text}#{fieldSeparator}" else output << "#{fieldSeparator}" end end end } processChildElements( @records, false, valuesBlock ) if output.length > 1 output << "\n" output.sub!( "#{fieldSeparator}\n", "\n" ) file.write( output ) output = "" end end } end |
#max(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Find the highest value for one or more fields in the records returned by a query. e.g. maximumsHash = max(“dfdfafff”,[“Date Sent”,“Quantity”,“Part Name”])
4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4003 def max( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) max = {} hasValues = false iterateRecords(dbid,fieldNames,query,qid,qname,clist,slist,fmt,){|record| fieldNames.each{|field| value = record[field] if value baseFieldType = lookupBaseFieldTypeByName(field) case baseFieldType when "int32","int64","bool" value = record[field].to_i when "float" value = record[field].to_f end end if max[field].nil? or (value and value > max[field]) max[field] = value hasValues = true end } } max = nil if not hasValues max end |
#min(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Find the lowest value for one or more fields in the records returned by a query. e.g. minimumsHash = min(“dfdfafff”,[“Date Sent”,“Quantity”,“Part Name”])
3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3976 def min( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) min = {} hasValues = false iterateRecords(dbid,fieldNames,query,qid,qname,clist,slist,fmt,){|record| fieldNames.each{|field| value = record[field] if value baseFieldType = lookupBaseFieldTypeByName(field) case baseFieldType when "int32","int64","bool" value = record[field].to_i when "float" value = record[field].to_f end end if min[field].nil? or (value and value < min[field]) min[field] = value hasValues = true end } } min = nil if not hasValues min end |
#obStatus ⇒ Object
API_obstatus: get the status of the QuickBase server.
2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2711 def obStatus sendRequest( :obStatus ) @serverVersion = getResponseElement("version") @serverUsers = getResponseElement("users") @serverGroups = getResponseElement("groups") @serverDatabases = getResponseElement("databases") @serverUptime = getResponseElement("uptime") @serverUpdays = getResponseElement("updays") @serverStatus = { "version" => @serverVersion.text, "users" => @serverUsers.text, "groups" => @serverGroups.text, "databases" => @serverDatabases.text, "uptime" => @serverUptime.text, "updays" => @serverUpdays.text } end |
#onChangedDbid ⇒ Object
Reset appropriate member variables after a different table is accessed.
1597 1598 1599 1600 1601 1602 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1597 def onChangedDbid _getDBInfo _getSchema resetrid resetfid end |
#parseResponseXML(xml) ⇒ Object
Called by processResponse to put the XML from QuickBase into a DOM tree using the REXML module that comes with Ruby.
408 409 410 411 412 413 414 415 416 |
# File 'lib/broker/client/QuickBaseClient.rb', line 408 def parseResponseXML( xml ) if xml xml.gsub!( "\r", "" ) if @ignoreCR and @ignoreCR == true xml.gsub!( "\n", "" ) if @ignoreLF and @ignoreLF == true xml.gsub!( "\t", "" ) if @ignoreTAB and @ignoreTAB == true xml.gsub!( "<BR/>", "<BR/>" ) if @escapeBR @qdbapi = @responseXMLdoc = REXML::Document.new( xml ) end end |
#percent(inputValues) ⇒ Object
Given an array of two numbers, return the second number as a percentage of the first number.
4144 4145 4146 4147 4148 4149 4150 4151 4152 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4144 def percent( inputValues ) raise "'inputValues' must not be nil" if inputValues.nil? raise "'inputValues' must be an Array" if not inputValues.is_a?(Array) raise "'inputValues' must have at least two elements" if inputValues.length < 2 total = inputValues[0].to_f total = 1.0 if total == 0.00 value = inputValues[1].to_f ((value/total)*100) end |
#prependAPI?(request) ⇒ Boolean
Returns whether to prepend ‘API_’ to request string
324 325 326 327 328 |
# File 'lib/broker/client/QuickBaseClient.rb', line 324 def prependAPI?( request ) ret = true ret = false if request.to_s.include?("API_") or request.to_s.include?("QBIS_") ret end |
#printChildElements(element, indent = 0) ⇒ Object
Recursive method to print a simplified (yaml-like) tree of the XML returned by QuickBase.
Translates field IDs into field names. Very useful during debugging.
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/broker/client/QuickBaseClient.rb', line 582 def printChildElements( element, indent = 0 ) indentation = "" indent.times{ indentation << " " } if indent > 0 if element and element.is_a?( REXML::Element ) and element.has_elements? attributes = getAttributeString( element ) name = lookupFieldName( element ) puts "#{indentation}#{name} #{attributes}:" element.each { |element| if element.is_a?( REXML::Element ) and element.has_elements? printChildElements( element, (indent+1) ) elsif element.is_a?( REXML::Element ) and element.has_text? attributes = getAttributeString( element ) name = lookupFieldName( element ) text = formatFieldValue( element.text, lookupFieldType( element ) ) puts " #{indentation}#{name} #{attributes} = #{text}" end } elsif element and element.is_a?( Array ) element.each{ |e| printChildElements( e ) } end self end |
#printLastError ⇒ Object
Prints the error info, if any, for the last request sent to QuickBase.
370 371 372 373 374 375 376 377 |
# File 'lib/broker/client/QuickBaseClient.rb', line 370 def printLastError if @lastError puts puts "Last error: ------------------------------------------" p @lastError end self end |
#printRequest(url, headers, xml) ⇒ Object
Called by sendRequest if @printRequestsAndResponses is true
351 352 353 354 355 356 357 358 |
# File 'lib/broker/client/QuickBaseClient.rb', line 351 def printRequest( url, headers, xml ) puts puts "Request: -------------------------------------------" p url if url p headers if headers p xml if xml self end |
#printResponse(code, xml) ⇒ Object
Called by sendRequest if @printRequestsAndResponses is true
361 362 363 364 365 366 367 |
# File 'lib/broker/client/QuickBaseClient.rb', line 361 def printResponse( code, xml ) puts puts "Response: ------------------------------------------" p code if code p xml if xml self end |
#processChildElements(element, leafElementsOnly, block) ⇒ Object
Recursive method to process leaf and (optionally) parent elements of any XML element returned by QuickBase.
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
# File 'lib/broker/client/QuickBaseClient.rb', line 639 def processChildElements( element, leafElementsOnly, block ) if element if element.is_a?( Array ) element.each{ |e| processChildElements( e, leafElementsOnly, block ) } elsif element.is_a?( REXML::Element ) and element.has_elements? block.call( element ) if not leafElementsOnly element.each{ |e| if e.is_a?( REXML::Element ) and e.has_elements? processChildElements( e, leafElementsOnly, block ) else block.call( e ) end } end end end |
#processResponse(responseXML) ⇒ Object
Except for requests that return HTML, processes the XML responses returned from QuickBase.
380 381 382 383 384 385 386 387 388 |
# File 'lib/broker/client/QuickBaseClient.rb', line 380 def processResponse( responseXML ) fire( "onProcessResponse" ) parseResponseXML( responseXML ) @ticket ||= getResponseValue( :ticket ) @udata = getResponseValue( :udata ) getErrorInfoFromResponse end |
#processRESTFieldNameOrRecordKeyRequest(dbid, fieldNameOrRecordKey) ⇒ Object
3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3942 def processRESTFieldNameOrRecordKeyRequest(dbid,fieldNameOrRecordKey) returnvalue = "" requestType = "" getSchema(dbid) fieldNames = getFieldNames if fieldNames.include?(fieldNameOrRecordKey) # name of a field in the table requestType = "fieldName" iterateRecordInfos(dbid){|r| returnvalue << "#{fieldNameOrRecordKey}:#{r[fieldNameOrRecordKey]}\n" if r } elsif @key_fid # key field value requestType = "keyFieldValue" iterateRecordInfos(dbid,"{'#{@key_fid}'.EX.'#{fieldNameOrRecordKey}'}"){|r| r.each{|k,v| returnvalue << "#{k}:#{v}\n"} if r } elsif fieldNameOrRecordKey.match(/[0-9]+/) # guess that this is a Record #ID value requestType = "recordID" iterateRecordInfos(dbid,"{'3'.EX.'#{fieldNameOrRecordKey}'}"){|r| r.each{|k,v| returnvalue << "#{k}:#{v}\n"} if r } else # guess that the first non-built-in field is a secondary non-numeric key field requestType = "field6" iterateRecordInfos(dbid,"{'6'.TV.'#{fieldNameOrRecordKey}'}"){|r| if r returnvalue << "Record:\n" r.each{|k,v| returnvalue << "#{k}:#{v}\n"} end } end return returnvalue, requestType end |
#processRESTRequest(requestString) ⇒ Object
Returns table or record values using REST syntax. e.g. - puts processRESTRequest(“8emtadvk/24105”) # prints record 24105 from Community Forum puts processRESTRequest(“8emtadvk”) # prints name of table with dbid of ‘8emtadvk’ puts qbc.processRESTRequest(“6ewwzuuj/Function Name”) # prints list of QuickBase Functions
3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3877 def processRESTRequest(requestString) ret = nil request = requestString.dup request.gsub!("//","ESCAPED/") requestParts = request.split('/') requestParts.each{|part| part.gsub!("ESCAPED/","//") } applicationName = nil applicationDbid= nil tableName = nil tableDbid = nil requestType = "" requestParts.each_index{|i| if i == 0 dbid = findDBByName(requestParts[0].dup) if dbid applicationDbid= dbid.dup # app/ applicationName = requestParts[0].dup ret = "dbid:#{applicationDbid}" elsif QuickBase::Misc.isDbidString?(requestParts[0].dup) and getSchema(requestParts[0].dup) tableDbid = requestParts[0].dup # dbid/ tableName = getTableName(tableDbid) ret = "table:#{tableName}" else ret = "Unable to process '#{requestParts[0].dup}' part of '#{requestString}'." end elsif i == 1 if applicationDbid getSchema(applicationDbid) tableDbid = lookupChdbid(requestParts[1].dup) if tableDbid # app/chdbid/ tableName = requestParts[1].dup ret = "dbid:#{tableDbid}" else getSchema(applicationDbid.dup) tableDbid = lookupChdbid(applicationName.dup) if tableDbid # app+appchdbid/ tableName = applicationName ret, requestType = processRESTFieldNameOrRecordKeyRequest(tableDbid,requestParts[1].dup) else ret = "Unable to process '#{requestParts[1].dup}' part of '#{requestString}'." end end elsif tableDbid ret, requestType = processRESTFieldNameOrRecordKeyRequest(tableDbid,requestParts[1].dup) else ret = "Unable to process '#{requestParts[1].dup}' part of '#{requestString}'." end elsif (i==2 or i == 3) and ["keyFieldValue","recordID"].include?(requestType) fieldValues = ret.split(/\n/) fieldValues.each{|fieldValue| if fieldValue.index("#{requestParts[i].dup}:") == 0 ret = fieldValue.gsub("#{requestParts[i].dup}:","") break end } elsif i == 2 and tableDbid ret, requestType = processRESTFieldNameOrRecordKeyRequest(tableDbid,requestParts[2].dup) else ret = "Unable to process '#{requestString}'." end } ret end |
#provisionUser(dbid, roleid, email, fname, lname) ⇒ Object
API_ProvisionUser
2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2875 def provisionUser( dbid, roleid, email, fname, lname ) @dbid, @roleid, @email, @fname, @lname = dbid, roleid, email, fname, lname xmlRequestData = toXML( :roleid, @roleid) xmlRequestData << toXML( :email, @email ) xmlRequestData << toXML( :fname, @fname ) xmlRequestData << toXML( :lname, @lname ) sendRequest( :provisionUser, xmlRequestData ) @userid = getResponseValue( :userid ) return self if @chainAPIcalls @userid end |
#purgeRecords(dbid, query = nil, qid = nil, qname = nil) ⇒ Object
API_PurgeRecords
2895 2896 2897 2898 2899 2900 2901 2902 2903 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2895 def purgeRecords( dbid, query = nil, qid = nil, qname = nil ) @dbid = dbid xmlRequestData = getQueryRequestXML( query, qid, qname ) sendRequest( :purgeRecords, xmlRequestData ) @num_records_deleted = getResponseValue( :num_records_deleted ) return self if @chainAPIcalls @num_records_deleted end |
#removeFileAttachment(dbid, rid, fileAttachmentFieldName) ⇒ Object
Remove the file from a File Attachment field in an existing record. e.g. removeFileAttachment( “bdxxxibz4”, “6”, “Document” )
4641 4642 4643 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4641 def removeFileAttachment( dbid, rid , fileAttachmentFieldName ) updateFile( dbid, rid, "delete", fileAttachmentFieldName ) end |
#removeUserFromRole(dbid, userid, roleid) ⇒ Object
API_RemoveUserFromRole
2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2909 def removeUserFromRole( dbid, userid, roleid ) @dbid, @userid, @roleid = dbid, userid, roleid xmlRequestData = toXML( :userid, @userid ) xmlRequestData << toXML( :roleid, @roleid ) sendRequest( :removeUserFromRole, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#renameApp(dbid, newappname) ⇒ Object
API_RenameApp
2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2925 def renameApp( dbid, newappname ) @dbid, @newappname = dbid, newappname xmlRequestData = toXML( :newappname , @newappname ) sendRequest( :renameApp, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#replaceFieldValuePair(name, fid, filename, value) ⇒ Object
Replaces a field value in the list of fields to be set by the next addRecord() or editRecord() call to QuickBase.
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1170 def replaceFieldValuePair( name, fid, filename, value ) if @fvlist name = name.downcase if name name = name.gsub( /\W/, "_" ) if name @fvlist.each_index{|i| if (name and @fvlist[i].include?("<field name='#{name}'")) or (fid and @fvlist[i].include?("<field fid='#{fid}'")) @fvlist[i] = FieldValuePairXML.new( self, name, fid, filename, value ).to_s break end } end @fvlist end |
#resetErrorInfo ⇒ Object
Resets error info before QuickBase requests are sent.
279 280 281 282 283 284 285 286 |
# File 'lib/broker/client/QuickBaseClient.rb', line 279 def resetErrorInfo @errcode = "0" @errtext = "" @errdetail = "" @lastError = "" @requestSucceeded = true self end |
#resetfid ⇒ Object
Set the @fid (‘active’ field ID) member variable to nil.
1592 1593 1594 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1592 def resetfid @fid = nil end |
#resetrid ⇒ Object
Set the @rid (‘active’ record ID) member variable to nil.
1587 1588 1589 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1587 def resetrid @rid = nil end |
#runImport(dbid, id) ⇒ Object
API_RunImport
2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2940 def runImport( dbid, id ) @dbid, @id = dbid, id xmlRequestData = toXML( :id , @id ) sendRequest( :runImport, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#sendInvitation(dbid, userid, usertext = "Welcome to my application!") ⇒ Object
API_SendInvitation
2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2955 def sendInvitation( dbid, userid, usertext = "Welcome to my application!" ) @dbid, @userid, @usertext = dbid, userid, usertext xmlRequestData = toXML( :userid, @userid ) xmlRequestData << toXML( :usertext, @usertext ) sendRequest( :sendInvitation, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#sendRequest(api_Request, xmlRequestData = nil) ⇒ Object
Sends requests to QuickBase and processes the reponses.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/broker/client/QuickBaseClient.rb', line 203 def sendRequest( api_Request, xmlRequestData = nil ) fire( "onSendRequest" ) resetErrorInfo # set up the request getDBforRequestURL( api_Request ) getAuthenticationXMLforRequest( api_Request ) isHTMLRequest = isHTMLRequest?( api_Request ) api_Request = "API_" + api_Request.to_s if prependAPI?( api_Request ) xmlRequestData << toXML( :udata, @udata ) if @udata and @udata.length > 0 xmlRequestData << toXML( :rdr, @rdr ) if @rdr and @rdr.length > 0 xmlRequestData << toXML( :xsl, @xsl ) if @xsl and @xsl.length > 0 xmlRequestData << toXML( :encoding, @encoding ) if @encoding and @encoding.length > 0 if xmlRequestData @requestXML = toXML( :qdbapi, @authenticationXML + xmlRequestData ) else @requestXML = toXML( :qdbapi, @authenticationXML ) end @requestHeaders = @standardRequestHeaders @requestHeaders["Content-Length"] = "#{@requestXML.length}" @requestHeaders["QUICKBASE-ACTION"] = api_Request @requestURL = "#{@qbhost}#{@dbidForRequestURL}" printRequest( @requestURL, @requestHeaders, @requestXML ) if @printRequestsAndResponses @logger.logRequest( @dbidForRequestURL, api_Request, @requestXML ) if @logger begin # send the request if USING_HTTPCLIENT response = @httpConnection.post( @requestURL, @requestXML, @requestHeaders ) @responseCode = response.status @responseXML = response.content else if Net::HTTP.version_1_2? response = @httpConnection.post( @requestURL, @requestXML, @requestHeaders ) @responseCode = response.code @responseXML = response.body else @responseCode, @responseXML = @httpConnection.post( @requestURL, @requestXML, @requestHeaders ) end end printResponse( @responseCode, @responseXML ) if @printRequestsAndResponses if not isHTMLRequest processResponse( @responseXML ) end @logger.logResponse( @lastError, @responseXML ) if @logger fireDBChangeEvents rescue Net::HTTPBadResponse => error @lastError = "Bad HTTP Response: #{error}" rescue Net::HTTPHeaderSyntaxError => error @lastError = "Bad HTTP header syntax: #{error}" rescue StandardError => error @lastError = "Error processing #{api_Request} request: #{error}" end @requestSucceeded = ( @errcode == "0" and @lastError == "" ) fire( @requestSucceeded ? "onRequestSucceeded" : "onRequestFailed" ) if @stopOnError and !@requestSucceeded raise @lastError end end |
#setActiveRecord(dbid, rid) ⇒ Object
Set the active database and record for subsequent method calls.
3206 3207 3208 3209 3210 3211 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3206 def setActiveRecord( dbid, rid ) if dbid and rid getRecordInfo( dbid, rid ) end @rid end |
#setActiveTable(dbid) ⇒ Object
Set the active database table subsequent method calls.
3201 3202 3203 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3201 def setActiveTable( dbid ) @dbid = dbid end |
#setAppData(dbid, appdata) ⇒ Object
API_SetAppData
2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2971 def setAppData( dbid, appdata ) @dbid, @appdata = dbid, appdata xmlRequestData = toXML( :appdata , @appdata ) sendRequest( :setAppData ) return self if @chainAPIcalls @appdata end |
#setDBvar(dbid, varname, value) ⇒ Object
API_SetDBvar
2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 |
# File 'lib/broker/client/QuickBaseClient.rb', line 2986 def setDBvar( dbid, varname, value ) @dbid, @varname, @value = dbid, varname, value xmlRequestData = toXML( :varname, @varname ) xmlRequestData << toXML( :value, @value ) sendRequest( :setDBvar, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#setFieldProperties(dbid, properties, fid) ⇒ Object
API_SetFieldProperties
3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3002 def setFieldProperties( dbid, properties, fid ) @dbid, @properties, @fid = dbid, properties, fid if @properties and @properties.is_a?( Hash ) xmlRequestData = toXML( :fid, @fid ) @properties.each{ |key, value| if isValidFieldProperty?( key ) xmlRequestData << toXML( key, value ) else raise "setFieldProperties: Invalid field property '#{key}'. Valid properties are " + @validFieldProperties.join( "," ) end } sendRequest( :setFieldProperties, xmlRequestData ) else raise "setFieldProperties: @properties is not a Hash of key/value pairs" end return self if @chainAPIcalls @requestSucceeded end |
#setFieldValue(fieldName, fieldValue, dbid = nil, rid = nil, key = nil) ⇒ Object
Change a named field’s value in the active record. e.g. setFieldValue( “Location”, “Miami” )
3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3216 def setFieldValue( fieldName, fieldValue, dbid = nil, rid = nil, key =nil ) @dbid ||= dbid @rid ||= rid @key ||= key if @dbid and (@rid or @key) clearFieldValuePairList addFieldValuePair( fieldName, nil, nil, fieldValue ) editRecord( @dbid, @rid, @fvlist, nil, nil, nil, nil, nil, @key ) end end |
#setFieldValues(fields, editRecord = true) ⇒ Object
Set several named fields’ values. Will modify the active record if there is one. e.g. setFieldValues( {“Location” => “Miami”, “Phone” => “343-4567” } )
3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3229 def setFieldValues( fields, editRecord=true ) if fields.is_a?(Hash) clearFieldValuePairList fields.each{ |fieldName,fieldValue| addFieldValuePair( fieldName, nil, nil, fieldValue ) } if editRecord and @dbid and (@rid or @key) editRecord( @dbid, @rid, @fvlist, nil, nil, nil, nil, nil, @key ) end end end |
#setHTTPConnection(useSSL, org = "www", domain = "quickbase", proxy_options = nil) ⇒ Object
Initializes the connection to QuickBase.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/broker/client/QuickBaseClient.rb', line 153 def setHTTPConnection( useSSL, org = "www", domain = "quickbase", = nil ) @useSSL = useSSL @org = org @domain = domain if USING_HTTPCLIENT if @httpConnection = HTTPClient.new( "#{["proxy_server"]}:#{["proxy_port"] || useSSL ? "443" : "80"}" ) @httpConnection.set_auth(["proxy_server"], ["proxy_user"], ["proxy_password"]) else @httpConnection = HTTPClient.new end else if @httpProxy = Net::HTTP::Proxy(["proxy_server"], ["proxy_port"], ["proxy_user"], ["proxy_password"]) @httpConnection = @httpProxy.new( "#{@org}.#{@domain}.com", useSSL ? 443 : 80) else @httpConnection = Net::HTTP.new( "#{@org}.#{@domain}.com", useSSL ? 443 : 80 ) end @httpConnection.use_ssl = useSSL @httpConnection.verify_mode = OpenSSL::SSL::VERIFY_NONE end end |
#setHTTPConnectionAndqbhost(useSSL, org = "www", domain = "quickbase", proxy_options = nil) ⇒ Object
Initializes the connection to QuickBase and sets the QuickBase URL and port to use for requests.
191 192 193 194 |
# File 'lib/broker/client/QuickBaseClient.rb', line 191 def setHTTPConnectionAndqbhost( useSSL, org = "www", domain = "quickbase", = nil ) setHTTPConnection( useSSL, org, domain, ) setqbhost( useSSL, org, domain ) end |
#setKeyField(dbid, fid) ⇒ Object
API_SetKeyField
3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3031 def setKeyField( dbid, fid ) @dbid, @fid = dbid, fid xmlRequestData = toXML( :fid, @fid ) sendRequest( :setKeyField, xmlRequestData ) return self if @chainAPIcalls @requestSucceeded end |
#setLogger(logger) ⇒ Object
Set the instance of a QuickBase::Logger to be used by QuickBase::Client. Closes the open log file if necessary.
1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1643 def setLogger( logger ) if logger if logger.is_a?( Logger ) if @logger and @logger != logger @logger.closeLogFile() end @logger = logger end else @logger.closeLogFile() if @logger @logger = nil end end |
#setqbhost(useSSL, org = "www", domain = "quickbase") ⇒ Object
Sets the QuickBase URL and port to use for requests.
182 183 184 185 186 187 188 |
# File 'lib/broker/client/QuickBaseClient.rb', line 182 def setqbhost( useSSL, org = "www", domain = "quickbase" ) @useSSL = useSSL @org = org @domain = domain @qbhost = useSSL ? "https://#{@org}.#{@domain}.com:443" : "http://#{@org}.#{@domain}.com" @qbhost end |
#signOut ⇒ Object
API_SignOut
3046 3047 3048 3049 3050 3051 3052 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3046 def signOut sendRequest( :signOut ) @ticket = @username = @password = nil return self if @chainAPIcalls @requestSucceeded end |
#splitString(string, fieldSeparator = ",") ⇒ Object
shenley - gem’s method was flawed and removed nil values, used CSV lib to separate correctly
1501 1502 1503 1504 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1501 def splitString(string, fieldSeparator = ",") string &&= string.encode("UTF-8", "binary", :invalid => :replace, :undef => :replace, :replace => "") CSV.parse(string, :col_sep => fieldSeparator).shift end |
#subscribe(event, handler) ⇒ Object
Subscribe to a specified event published by QuickBase::Client.
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1616 def subscribe( event, handler ) @events = %w{ onSendRequest onProcessResponse onSetActiveTable onRequestSucceeded onRequestFailed onSetActiveRecord onSetActiveField } if @events.nil? if @events.include?( event ) if handler and handler.is_a?( EventHandler ) if @eventSubscribers.nil? @eventSubscribers = {} end if not @eventSubscribers.include?( event ) @eventSubscribers[ event ] = [] end if not @eventSubscribers[ event ].include?( handler ) @eventSubscribers[ event ] << handler end else raise "subscribe: 'handler' must be a class derived from QuickBase::EventHandler." end else raise "subscribe: invalid event '#{event}'. Valid events are #{@events.sort.join( ', ' )}." end end |
#sum(dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil) ⇒ Object
Returns the sum of the values for one or more fields in the records returned by a query. e.g. sumsHash = sum(“dfdfafff”,[“Date Sent”,“Quantity”,“Part Name”])
4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4048 def sum( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", = nil ) sum = {} hasValues = false iterateRecords(dbid,fieldNames,query,qid,qname,clist,slist,fmt,){|record| fieldNames.each{|field| value = record[field] if value baseFieldType = lookupBaseFieldTypeByName(field) case baseFieldType when "int32","int64","bool" value = record[field].to_i when "float" value = record[field].to_f end if sum[field].nil? sum[field] = value else sum[field] = sum[field] + value end hasValues = true end } } sum = nil if not hasValues sum end |
#toggleTraceInfo(showTrace) ⇒ Object
Turns program stack tracing on or off.
If followed by a block, the tracing will be toggled on or off at the end of the block.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/broker/client/QuickBaseClient.rb', line 332 def toggleTraceInfo( showTrace ) if showTrace # this will print a very large amount of stuff set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } if block_given? yield set_trace_func nil end else set_trace_func nil if block_given? yield set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } end end self end |
#toXML(tag, value = nil) ⇒ Object
Builds the XML for a specific item included in a request to QuickBase.
1036 1037 1038 1039 1040 1041 1042 1043 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1036 def toXML( tag, value = nil ) if value ret = "<#{tag}>#{value}</#{tag}>" else ret = "<#{tag}/>" end ret end |
#updateFile(dbid, rid, filename, fileAttachmentFieldName, additionalFieldsToSet = nil) ⇒ Object
Update the file attachment in an existing record in a table. Additional field values can optionally be set. e.g. updateFile( “dhnju5y7”, “6”, “contacts.txt”, “Contacts File”, { “Notes” => “#Time.now” }
4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4619 def updateFile( dbid, rid, filename, fileAttachmentFieldName, additionalFieldsToSet = nil ) if dbid and rid and filename and fileAttachmentFieldName clearFieldValuePairList addFieldValuePair( fileAttachmentFieldName, nil, filename, nil ) if additionalFieldsToSet and additionalFieldsToSet.is_a?( Hash ) additionalFieldsToSet.each{ |fieldName,fieldValue| addFieldValuePair( fieldName, nil, nil, fieldValue ) } end return editRecord( dbid, rid, @fvlist ) end nil end |
#uploadFile(dbid, filename, fileAttachmentFieldName, additionalFieldsToSet = nil) ⇒ Object
Upload a file into a new record in a table. Additional field values can optionally be set. e.g. uploadFile( “dhnju5y7”, “contacts.txt”, “Contacts File”, { “Notes” => “#Time.now” }
4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4574 def uploadFile( dbid, filename, fileAttachmentFieldName, additionalFieldsToSet = nil ) if dbid and filename and fileAttachmentFieldName clearFieldValuePairList addFieldValuePair( fileAttachmentFieldName, nil, filename, nil ) if additionalFieldsToSet and additionalFieldsToSet.is_a?( Hash ) additionalFieldsToSet.each{ |fieldName,fieldValue| addFieldValuePair( fieldName, nil, nil, fieldValue ) } end return addRecord( dbid, @fvlist ) end nil end |
#uploadFileContents(dbid, filename, fileContents, fileAttachmentFieldName, additionalFieldsToSet = nil) ⇒ Object
Add a File Attachment into a new record in a table, using a string containing the file contents. Additional field values can optionally be set. e.g. uploadFile( “dhnju5y7”, “contacts.txt”, “fred: 1-222-333-4444”, “Contacts File”, { “Notes” => “#Time.now” }
4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 |
# File 'lib/broker/client/QuickBaseClient.rb', line 4591 def uploadFileContents( dbid, filename, fileContents, fileAttachmentFieldName, additionalFieldsToSet = nil ) if dbid and filename and fileAttachmentFieldName clearFieldValuePairList addFieldValuePair( fileAttachmentFieldName, nil, filename, fileContents ) if additionalFieldsToSet and additionalFieldsToSet.is_a?( Hash ) additionalFieldsToSet.each{ |fieldName,fieldValue| addFieldValuePair( fieldName, nil, nil, fieldValue ) } end return addRecord( dbid, @fvlist ) end nil end |
#userRoles(dbid) ⇒ Object
API_UserRoles
3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 |
# File 'lib/broker/client/QuickBaseClient.rb', line 3063 def userRoles( dbid ) @dbid = dbid sendRequest( :userRoles ) @users = getResponseElement( :users ) return self if @chainAPIcalls if block_given? if @users user_list = getResponseElements("qdbapi/users/user") user_list.each{|user| yield user} else yield nil end else @users end end |
#verifyFieldList(fnames, fids = nil, dbid = @dbid) ⇒ Object
Given an array of field names or field IDs and a table ID, builds an array of valid field IDs and field names. Throws an exception when an invalid name or ID is encountered.
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1192 def verifyFieldList( fnames, fids = nil, dbid = @dbid ) getSchema( dbid ) @fids = @fnames = nil if fids if fids.is_a?( Array ) and fids.length > 0 fids.each { |id| fid = lookupField( id ) if fid fname = lookupFieldNameFromID( id ) @fnames ||= [] @fnames << fname else raise "verifyFieldList: '#{id}' is not a valid field ID" end } @fids = fids else raise "verifyFieldList: fids must be an array of one or more field IDs" end elsif fnames if fnames.is_a?( Array ) and fnames.length > 0 fnames.each { |name| fid = lookupFieldIDByName( name ) if fid @fids ||= [] @fids << fid else raise "verifyFieldList: '#{name}' is not a valid field name" end } @fnames = fnames else raise "verifyFieldList: fnames must be an array of one or more field names" end else raise "verifyFieldList: must specify fids or fnames" end @fids end |
#verifyQueryOperator(operator, fieldType) ⇒ Object
Returns a valid query operator.
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
# File 'lib/broker/client/QuickBaseClient.rb', line 1301 def verifyQueryOperator( operator, fieldType ) queryOperator = "" if @queryOperators.nil? @queryOperators = {} @queryOperatorFieldType = {} @queryOperators[ "CT" ] = [ "contains", "[]" ] @queryOperators[ "XCT" ] = [ "does not contain", "![]" ] @queryOperators[ "EX" ] = [ "is", "==", "eq" ] @queryOperators[ "TV" ] = [ "true value" ] @queryOperators[ "XEX" ] = [ "is not", "!=", "ne" ] @queryOperators[ "SW" ] = [ "starts with" ] @queryOperators[ "XSW" ] = [ "does not start with" ] @queryOperators[ "BF" ] = [ "is before", "<" ] @queryOperators[ "OBF" ] = [ "is on or before", "<=" ] @queryOperators[ "AF" ] = [ "is after", ">" ] @queryOperators[ "OAF" ] = [ "is on or after", ">=" ] @queryOperatorFieldType[ "BF" ] = [ "date" ] @queryOperatorFieldType[ "OBF" ] = [ "date" ] @queryOperatorFieldType[ "ABF" ] = [ "date" ] @queryOperatorFieldType[ "OAF" ] = [ "date" ] @queryOperators[ "LT" ] = [ "is less than", "<" ] @queryOperators[ "LTE" ] = [ "is less than or equal to", "<=" ] @queryOperators[ "GT" ] = [ "is greater than", ">" ] @queryOperators[ "GTE" ] = [ "is greater than or equal to", ">=" ] end upcaseOperator = operator.upcase @queryOperators.each { |queryop,aliases| if queryop == upcaseOperator if @queryOperatorFieldType[ queryop ] and @queryOperatorFieldType[ queryop ].include?( fieldType ) queryOperator = upcaseOperator break else queryOperator = upcaseOperator break end else aliases.each { |a| if a == upcaseOperator if @queryOperatorFieldType[ queryop ] and @queryOperatorFieldType[ queryop ].include?( fieldType ) queryOperator = queryop break else queryOperator = queryop break end end } end } queryOperator end |