databasedotcom 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,10 +84,12 @@ module Databasedotcom
84
84
  #
85
85
  # Raises SalesForceError if an error occurs
86
86
  def authenticate(options = nil)
87
- if (options[:username] && options[:password])
87
+ if user_and_pass?(options)
88
88
  req = Net::HTTP.new(self.host, 443)
89
89
  req.use_ssl=true
90
- path = "/services/oauth2/token?grant_type=password&client_id=#{self.client_id}&client_secret=#{client_secret}&username=#{options[:username]}&password=#{options[:password]}"
90
+ user = self.username || options[:username]
91
+ pass = self.password || options[:password]
92
+ path = "/services/oauth2/token?grant_type=password&client_id=#{self.client_id}&client_secret=#{client_secret}&username=#{user}&password=#{pass}"
91
93
  log_request("https://#{self.host}/#{path}")
92
94
  result = req.post(path, "")
93
95
  log_response(result)
@@ -417,5 +419,9 @@ module Databasedotcom
417
419
  def key_from_label(label)
418
420
  label.gsub(' ', '_')
419
421
  end
422
+
423
+ def user_and_pass?(options)
424
+ (self.username && self.password) || (options && options[:username] && options[:password])
425
+ end
420
426
  end
421
427
  end
@@ -1,3 +1,3 @@
1
1
  module Databasedotcom
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: databasedotcom
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Glenn Gillen, Danny Burkes & Richard Zhao