Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions lib/QuickBaseClient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Client
attr_reader :serverStatus, :serverVersion , :serverUsers, :serverGroups, :serverDatabases, :serverUptime, :serverUpdays
attr_reader :showAppData, :skipfirst, :slist, :sourcerid, :standardRequestHeaders, :status, :stopOnError
attr_reader :table, :tables, :ticket, :type, :udata, :uname, :update_id, :user, :userid
attr_reader :username, :users, :value, :validFieldProperties, :validFieldTypes, :variables
attr_reader :username, :users, :value, :validFieldProperties, :validFieldTypes, :variables , :usertoken
attr_reader :varname, :version, :vid, :view, :withembeddedtables
attr_reader :eventSubscribers, :logger

Expand All @@ -82,6 +82,7 @@ class Client
# use QuickBase::Client.init(options) instead of QuickBase::Client.new()
def initialize( username = nil,
password = nil,
usertoken = nil,
appname = nil,
useSSL = true,
printRequestsAndResponses = false,
Expand All @@ -104,6 +105,8 @@ def initialize( username = nil,
setHTTPConnectionAndqbhost( useSSL, org, domain, proxy_options )
debugHTTPConnection() if debugHTTPConnection
@standardRequestHeaders = { "Content-Type" => "application/xml" }


if username and password
authenticate( username, password )
if appname and @errcode == "0"
Expand All @@ -114,6 +117,12 @@ def initialize( username = nil,
end
end
end

if usertoken
@usertoken = usertoken
end


rescue Net::HTTPBadRequest => @lastError
rescue Net::HTTPBadResponse => @lastError
rescue Net::HTTPHeaderSyntaxError => @lastError
Expand All @@ -137,6 +146,7 @@ def Client.init( options )

instance = Client.new( options["username"],
options["password"],
options["usertoken"],
options["appname"],
options["useSSL"],
options["printRequestsAndResponses"],
Expand Down Expand Up @@ -208,7 +218,10 @@ def sendRequest( api_Request, xmlRequestData = nil )

# 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 )

Expand Down Expand Up @@ -302,11 +315,17 @@ def getDBforRequestURL( api_Request )
# The XML includes a apptoken if one has been set.
def getAuthenticationXMLforRequest( api_Request )
@authenticationXML = ""
if @ticket
@authenticationXML = toXML( :ticket, @ticket )
elsif @username and @password
@authenticationXML = toXML( :username, @username ) + toXML( :password, @password )

if @usertoken
@authenticationXML = toXML( :usertoken, @usertoken )
else
if @ticket
@authenticationXML = toXML( :ticket, @ticket )
elsif @username and @password
@authenticationXML = toXML( :username, @username ) + toXML( :password, @password )
end
end

@authenticationXML << toXML( :apptoken, @apptoken ) if @apptoken
end

Expand Down Expand Up @@ -1818,6 +1837,10 @@ def getIDSRealm( dbid )
def authenticate( username, password, hours = nil )

@username, @password, @hours = username, password, hours

if @usertoken
return
end

if username and password

Expand Down