Identify Zambian mobile networks (Airtel, MTN, Zamtel, Zed Mobile) from a phone number.
Prefixes
| Network | Local | With country code (260) |
|---|---|---|
| Airtel | 097, 077, 057 | 26097, 26077, 26057 |
| MTN | 096, 076, 056 | 26096, 26076, 26056 |
| Zamtel | 095, 075, 055 | 26095, 26075, 26055 |
| Zed Mobile | 098, 078*, 058* | 26098, 26078*, 26058* |
* 078/058 are reserved for Zed Mobile but not yet officially enabled by the network provider; they are detected pre-emptively.
Installation
Add zambia_mobile_networks to your deps in mix.exs:
def deps do
[
{:zambia_mobile_networks, "~> 0.1"}
]
endUsage
ZambiaMobileNetworks.detect("0971234567") # :airtel
ZambiaMobileNetworks.detect("260761234567") # :mtn
ZambiaMobileNetworks.detect("+260 95 123 4567") # :zamtel
ZambiaMobileNetworks.detect("0911234567") # nil
ZambiaMobileNetworks.supports?("0961234567", :mtn) # true
ZambiaMobileNetworks.label(:zamtel) # "Zamtel"
ZambiaMobileNetworks.networks() # [:airtel, :mtn, :zamtel, :zed]
# Logos — bundled 200x200 PNG as a base64 data URI
ZambiaMobileNetworks.logo(:mtn) # "data:image/png;base64,..."
ZambiaMobileNetworks.logo(:mtn, "path/to/logo.png") # use your own (path or binary)Test
mix test
License
This project is open-source and available under the terms of the MIT License.