require_relative "request_parser" module Devops module API2_0 module Parser class UserParser < RequestParser def create user = create_object_from_json_body ["username", "password", "email"].each do |p| check_string(user[p], "Parameter '#{p}' must be a not empty string") end Devops::Model::User.new(user) end def user_privileges data = create_object_from_json_body cmd = check_string(data["cmd"], "Parameter 'cmd' should be a not empty string", true) privileges = check_string(data["privileges"], "Parameter 'privileges' should be a string", true, true) return cmd, privileges end def change_password body = create_object_from_json_body check_string(body["password"], "Parameter 'password' must be a not empty string") end def change_email body = create_object_from_json_body check_string(body["email"], "Parameter 'email' must be a not empty string") end end end end end