Class: Copyleaks::ClientUtils
- Inherits:
-
Object
- Object
- Copyleaks::ClientUtils
- Defined in:
- lib/copyleaks/utils/copyleaks_client.utils.rb
Class Method Summary collapse
Class Method Details
.handle_response(response, used_by) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/copyleaks/utils/copyleaks_client.utils.rb', line 27 def self.handle_response(response, used_by) if Utils.is_success_status_code(response.code) if response.body.nil? || response.body == '' nil else parsed_response = JSON.parse(response.body) puts "Parsed response: #{parsed_response.inspect}" parsed_response end elsif Utils.is_under_maintenance_response(response.code) raise UnderMaintenanceException.new.reason elsif Utils.is_rate_limit_response(response.code) raise RateLimitException.new.reason else = '---------Copyleaks SDK Error (' + used_by + ')---------' + "\n\n" += 'status code: ' + response.code + "\n\n" += 'response body:' + "\n" + response.body.to_json + "\n\n" unless response.body.nil? += '-------------------------------------' raise CommandException.new().reason + "\n" end end |
.verify_auth_token(authToken) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/copyleaks/utils/copyleaks_client.utils.rb', line 51 def self.verify_auth_token(authToken) if authToken.nil? || !authToken.instance_of?(CopyleaksAuthToken) raise 'authToken is Invalid, must be instance of CopyleaksAuthToken' end _time = DateTime.now _expiresTime = DateTime.parse(authToken.expires) if _expiresTime <= _time raise AuthExipredException.new.reason # expired end end |