                       :content (get-in e [:claim :endorsementComment] "")
                       :issued_on (u/str->epoch (:issuedOn e))
                       :issuer (as-> (:issuer e) $
-                                (if (map? $) $ (http/json-get $))
-                                {:id (:id $)
-                                 :language_code ""
-                                 :name (:name $)
-                                 :description (:description $)
-                                 :url (:url $)
-                                 :email (:email $)
-                                 :image_file (:image $)
-                                 :revocation_list_url nil})}
+                                    (if (map? $) $ (http/json-get $))
+                                    {:id (:id $)
+                                     :language_code ""
+                                     :name (:name $)
+                                     :description (:description $)
+                                     :url (:url $)
+                                     :email (:email $)
+                                     :image_file (:image $)
+                                     :revocation_list_url nil})}
                      nil)))
             (remove nil?)
             (map (fn [e]

                      :json_url creator-url}]))]

    (assoc initial
           :badge {:id ""
                   :remote_url nil
                   :remote_id nil
                   :remote_issuer_id nil
                   :issuer_verified 0
                   :default_language_code ""
                   :content [{:id ""
                              :language_code ""
                              :name (:name badge)
                              :image_file (:image badge)
                              :description (:description badge)
                              :alignment (get badge :alignment [])
                              :tags (get badge :tags [])}]
                   :criteria [{:id ""
                               :language_code ""
                               :url (:criteria badge)
                               :markdown_text (http/alternate-get "text/x-markdown" criteria)}]
                   :issuer [{:id ""
                             :language_code ""
                             :name (:name issuer)
                             :description (:description issuer)
                             :url (:url issuer)
                             :email (:email issuer)
                             :image_file nil
                             :endorsement []
                             :revocation_list_url (:revocationList issuer)}]
                   :creator creator
                   :endorsement []
                   :published 0
                   :last_received 0
                   :recipient_count 0}
           :issued_on  (u/str->epoch (:issuedOn assertion))
           :expires_on (u/str->epoch (:expires assertion))
           :evidence [(when-not (nil? evidence_url)
                        {:id nil
                         :user_badge_id nil
                         :url evidence_url
                         :narrative nil
                         :name nil
                         :description nil
                         :genre nil
                         :audience nil
                         :ctime now
                         :mtime now})])))

; old v1.0/v1.1 badge content
#_{:badge_url    (:badge assertion)
            :issuer_url   (:issuer badge)
            :criteria_url (:criteria badge)
            :creator_url  creator-url
            :badge_content {:id ""
                            :name (:name badge)
                            :image_file (:image badge)
                            :description (:description badge)
                            :alignment (get badge :alignment [])
                            :tags (get badge :tags [])}
            :issuer_content {:id ""
                             :name (:name issuer)
                             :description (:description issuer)
                             :url (:url issuer)
                             :email (:email issuer)
                             :image_file (:image issuer)
                             :revocation_list_url (:revocationList issuer)}
            :criteria_content {:id ""
                               :html_content criteria
                               :markdown_text (http/alternate-get "text/x-markdown" criteria)}
            :creator_content  creator
            :issued_on  (u/str->epoch (:issuedOn assertion))
            :expires_on (u/str->epoch (:expires assertion))
            :evidence_url (:evidence assertion)}
;;;

(defmulti recipient (fn [_ asr] (class (:recipient asr))))

                   ;; list of evidences
                   (coll? (:evidence assertion)) (mapv (fn [e]
                                                         {:id nil
                                                          :user_badge_id nil
                                                          :url (:id e)
                                                          :narrative (:narrative e)
                                                          :name (:name e)
                                                          :description (:description e)
                                                          :genre (:genre e)
                                                          :audience (:audience e)
                                                          :ctime now
                                                          :mtime now}) (:evidence assertion))
                   :else [])

        badge  (if (map? (:badge assertion)) (:badge assertion) (http/json-get (:badge assertion)))
        related (->> (get badge :related [])
                     (map #(http/json-get (:id %)))
                     (remove #(nil? ((keyword "@language") %))))
        default-language (get badge (keyword "@language") "")
        endorsement (cond
                      (map? (:endorsement assertion)) [{:id nil
                                                        :external_id (get-in assertion [:endorsement :id])
                                                        :user_badge_id nil
                                                        :issuer_id nil
                                                        :issuer_name (get-in assertion [:endorsement :issuer :name])
                                                        :issuer_url (get-in assertion [:endorsement :issuer :id])
                                                        :content (get-in assertion [:endorsement :claim :endorsementComment])
                                                        :ctime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
                                                        :mtime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
                                                        }]

                      (coll? (:endorsement assertion)) (mapv (fn [e]
                                                              {:id nil
                                                               :external_id (get-in assertion [:endorsement :id])
                                                               :user_badge_id nil
                                                               :issuer_id nil
                                                               :issuer_name (get-in assertion [:endorsement :issuer :name])
                                                               :issuer_url (get-in assertion [:endorsement :issuer :id])
                                                               :content (get-in assertion [:endorsement :claim :endorsementComment])
                                                               :ctime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
                                                               :mtime (u/str->epoch (get-in assertion [:endorsement :issuedOn]))
                                                               }) (:endorsement assertion))
                      :else []
                      ) ]

    (assoc initial
      :badge (merge {:id ""
                     :remote_url nil
                     :remote_id nil
                     :remote_issuer_id nil
                     :issuer_verified 0
                     :default_language_code default-language
                     :published 0
                     :last_received 0
                     :recipient_count 0
                     }
                    (apply merge-with (cons concat (map parser (cons badge related)))))
      :issued_on  (u/str->epoch (:issuedOn assertion))
      :expires_on (u/str->epoch (:expires assertion))
      :evidence evidence
      :endorsement endorsement
      )))
;;;

(defmethod badge-content :default [initial assertion]
