Method: Umbreo::Models::Service#validate
- Defined in:
- lib/umbreo/models/service.rb
#validate(file_path) ⇒ Object
check valid json params
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/umbreo/models/service.rb', line 120 def validate(file_path) @errors << "File directory is required." if file_path.blank? begin file = File.open(file_path, "r") content = file.read json = JSON.parse(content) encode = Helpers::JsonBaseConvert.encode(json) rescue @errors << "Error on file. Please check again." end @errors << "Content of file is required." if content.blank? if valid? Helpers::ErrorException.rescue do response = Typhoeus.get( "#{@endpoint}/api/v1/services/validate", body: { authenticate_token: @api_key, email: @email, content: encode } ) @response = JSON.parse response.response_body if @response["success"] Helpers::AlertMessage.(@response["message"]) else Helpers::AlertMessage.(@response["message"]) end end else Helpers::AlertMessage.(error) end end |