require_relative "request_parser"

module Devops
  module API3
    module Parser
      class UserParser < RequestParser

        def create
          create_object_from_json_body
        end

        def update_user
          create_object_from_json_body
        end

        def roles
          roles = create_object_from_json_body(Array)
          check_array(roles, "Body must be a not empty array of strings")
          roles
        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 action
          body = create_object_from_json_body
          check_string(body[action], "Parameter '#{action}' must be a not empty string")
        end

      end
    end
  end
end

