Module: GettyConnect::Client::Session
- Included in:
- GettyConnect::Client
- Defined in:
- lib/getty_connect/client/session.rb
Instance Method Summary collapse
Instance Method Details
#renew_token(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/getty_connect/client/session.rb', line 28 def renew_token(={}) if self.secure_token = { :RequestHeader => { :Token => self.secure_token }, :RenewSessionRequestBody => { :SystemId => GettyConnect.system_id, :SystemPassword => GettyConnect.system_password } }.merge else "Token must be first requested." end response = post(@renew_session_endpoint, , use_ssl=true) if response.ResponseHeader.Status == "success" self.token_renewed_at = Time.now() end response end |
#request_token(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/getty_connect/client/session.rb', line 5 def request_token(={}) = { :RequestHeader => { :Token => '' }, :CreateSessionRequestBody => { :SystemId => GettyConnect.system_id, :SystemPassword => GettyConnect.system_password, :UserName => GettyConnect.api_username, :UserPassword => GettyConnect.api_password } }.merge response = post(@create_session_endpoint, , use_ssl=true) if response.ResponseHeader.Status == "success" self.token = response.CreateSessionResult.Token self.secure_token = response.CreateSessionResult.SecureToken self.token_issued_at = Time.now() self.token_duration = response.CreateSessionResult.TokenDurationMinutes end response end |