private function getEmailObject($emails)
    {
        // Try to find an email address which is primary and verified.
        foreach ($emails as $email) {
            if ($email[ 'primary' ] && $email[ 'verified' ]) {
                return $email;
            }
        }

        // Try to find an email address which is primary.
        foreach ($emails as $email) {
            if ($email[ 'primary' ]) {
                return $email;
            }
        }

        return $emails[ 0 ];
    }