Extend api to support getting badges

and some cleanup.

Tests got added in https://gerrit.wikimedia.org/r/#/c/82246/

Bug: 40810
Change-Id: I1ebef94eabf24ca3524b33c47bd28367e0f6a46e
Merge "Extend api to support getting badges"