For $n$ prime, such quadratic representations have been studied by Christian Elsholtz in A combinatorial approach to sums of two squares and related problems (2010).
For general $n$, the number of representations is calculated by N. Bagis and M.L Glasser in On the Number of Representations of Integers by various Quadratic and Higher Forms (2014), formulas 12 and 13.