module GettyConnect class Client module Session def request_token(options={}) options = { :RequestHeader => { :Token => '' }, :CreateSessionRequestBody => { :SystemId => GettyConnect.system_id, :SystemPassword => GettyConnect.system_password, :UserName => GettyConnect.api_username, :UserPassword => GettyConnect.api_password } }.merge options response = post(@create_session_endpoint, options, 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 def renew_token(options={}) if self.secure_token options = { :RequestHeader => { :Token => self.secure_token }, :RenewSessionRequestBody => { :SystemId => GettyConnect.system_id, :SystemPassword => GettyConnect.system_password } }.merge options else "Token must be first requested." end response = post(@renew_session_endpoint, options, use_ssl=true) if response.ResponseHeader.Status == "success" self.token_renewed_at = Time.now() end response end end end end