Class: LeapSalesforce::Session
- Inherits:
-
Object
- Object
- LeapSalesforce::Session
- Defined in:
- lib/leap_salesforce/session.rb
Overview
Holds information about a login session
Instance Attribute Summary collapse
-
#login_response ⇒ Hash
Login response.
-
#session_id ⇒ String
Session id returned from SOAP API.
-
#user_id ⇒ String
User id returned from SOAP API.
Class Method Summary collapse
-
.soap_login(username, password, security_token) ⇒ Object
Login via SOAP API.
Instance Method Summary collapse
-
#initialize(username, password, security_token = '') ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize(username, password, security_token = '') ⇒ Session
Returns a new instance of Session.
15 16 17 18 19 20 21 |
# File 'lib/leap_salesforce/session.rb', line 15 def initialize(username, password, security_token = '') login_body = LeapSalesforce::Session.soap_login username, password, security_token self.session_id = login_body[:login_response][:result][:session_id] self.user_id = login_body[:login_response][:result][:user_id] self.login_response = login_body[:login_response] end |
Instance Attribute Details
#login_response ⇒ Hash
Returns Login response.
13 14 15 |
# File 'lib/leap_salesforce/session.rb', line 13 def login_response @login_response end |
#session_id ⇒ String
Returns Session id returned from SOAP API.
9 10 11 |
# File 'lib/leap_salesforce/session.rb', line 9 def session_id @session_id end |
#user_id ⇒ String
Returns User id returned from SOAP API.
11 12 13 |
# File 'lib/leap_salesforce/session.rb', line 11 def user_id @user_id end |
Class Method Details
.soap_login(username, password, security_token) ⇒ Object
Login via SOAP API
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/leap_salesforce/session.rb', line 26 def soap_login(username, password, security_token) client = Savon.client do endpoint "#{SoqlHandler.instance_url}/services/Soap/u/51.0" namespace "urn:partner.soap.sforce.com" log true # See request and response. (Put this in traffic file) log_level :debug logger Soaspec::SpecLogger.create pretty_print_xml true # Prints XML pretty end response = client.call(:login, message: { username: username, password: password + security_token.to_s }) response.body end |