Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mccraigmccraig
Created September 4, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccraigmccraig/1e8dafda6d86ea6ae0018b492992ee40 to your computer and use it in GitHub Desktop.
Save mccraigmccraig/1e8dafda6d86ea6ae0018b492992ee40 to your computer and use it in GitHub Desktop.
(ns er-model.util.phone-number.impl
(:require
["google-libphonenumber" :as phone-number :refer [PhoneNumber]]))
(def PhoneNumberUtil (.-PhoneNumberUtil phone-number))
(def PhoneNumberFormat (.-PhoneNumberFormat phone-number))
(defn phone-number-instance [] (PhoneNumber.))
(defn phone-number-util-instance [] (.getInstance PhoneNumberUtil))
(def key->country-code-source-map
(let [ccs (.-CountryCodeSource PhoneNumber)]
{:from-number-with-plus-sign
(.-FROM_NUMBER_WITH_PLUS_SIGN ccs)
:from-number-with-idd
(.-FROM_NUMBER_WITH_IDD ccs)
:from-number-without-plus-sign
(.-FROM_NUMBER_WITHOUT_PLUS_SIGN ccs)
:from-default-country
(.-FROM_DEFAULT_COUNTRY ccs)}))
(def key->phone-number-format-map
{:E164 (.-E164 PhoneNumberFormat)
:INTERNATIONAL (.-INTERNATIONAL PhoneNumberFormat)
:NATIONAL (.-NATIONAL PhoneNumberFormat)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment