6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/models/gemgento/session.rb', line 6
def self.get(client, force_new_session)
if Session.last.nil? || Session.last.expired || force_new_session
response = client.call(:login, message: { username: Config[:magento][:username], apiKey: Config[:magento][:api_key] })
unless response.success?
puts 'Login Failed - Check Session'
exit end
session = response.body[:login_response][:login_return];
s = Session.new
s.session_id = session
s.save
else
s = Session.last
s.touch
session = s.session_id
end
return session
end
|