Skip to content
/ leblad Public

A go module providing a list of Algerian administrative areas with many useful APIs, based on dzcode-io/leblad

License

Notifications You must be signed in to change notification settings

omdxp/leblad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leblad

Build Status codecov Go Report Card

A go module providing a list of Algerian administrative areas with many useful APIs, based on dzcode-io/leblad

Installation

go get -u github.com/omdxp/leblad

Quick Start

package main

import (
    "fmt"

    "github.com/omdxp/leblad"
)

func main() {
    l := leblad.New()

    // Get all wilayas
    wilayas, err := l.GetWilayaList()
    if err != nil {
        panic(err)
    }

    fmt.Println(wilayas)

    // Get only wilayas names
    wilayas, err = l.GetWilayaList("name")
    if err != nil {
        panic(err)
    }
}

API

init a new leblad instance

l := leblad.New()

GetWilayaList

Get all wilayas

wilayas, err := l.GetWilayaList()
if err != nil {
    panic(err)
}

Filter wilayas by a specific field

wilayas, err := l.GetWilayaList("name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

wilayas, err := l.GetWilayaList("name", "dairats", "matricule")
if err != nil {
    panic(err)
}

fields can be one of the following:

wilaya field description
matricule wilaya matricule
name_ar wilaya name in arabic
name_ber wilaya name in berber
name_en wilaya name in english
name wilaya name in french
phoneCodes wilaya phone codes
postalCodes wilaya postal codes
dairats wilaya dairats
adjacentWilayas wilaya adjacent wilayas

GetWilayaByZipCode

Get wilaya by zip code

wilaya, err := l.GetWilayaByZipCode(1000)
if err != nil {
    panic(err)
}

Filter wilaya by a specific field

wilaya, err := l.GetWilayaByZipCode(1000, "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

wilaya, err := l.GetWilayaByZipCode(1000, "name", "dairats", "matricule")
if err != nil {
    panic(err)
}

GetWilayaByCode

Get wilaya by code

wilaya, err := l.GetWilayaByCode(1)
if err != nil {
    panic(err)
}

Filter wilaya by a specific field

wilaya, err := l.GetWilayaByCode(1, "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

wilaya, err := l.GetWilayaByCode(1, "name", "dairats", "matricule")
if err != nil {
    panic(err)
}

GetAdjacentWilayas

Get adjacent wilayas as a slice of wilaya codes

wilayas, err := l.GetAdjacentWilayas(1)
if err != nil {
    panic(err)
}

GetZipCodesForWilaya

Get zip codes for a wilaya

zipCodes, err := l.GetZipCodesForWilaya(1)
if err != nil {
    panic(err)
}

GetDairatsForWilaya

Get dairats for a wilaya

dairats, err := l.GetDairatsForWilaya(1)
if err != nil {
    panic(err)
}

Filter dairats by a specific field

dairats, err := l.GetDairatsForWilaya(1, "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

dairats, err := l.GetDairatsForWilaya(1, "name", "code", "baladyiats")
if err != nil {
    panic(err)
}

fields can be one of the following:

daira field description
code daira code
name daira name
name_ar daira name in arabic
name_en daira name in english
baladyiats daira baladyiats

GetWilayaByPhoneCode

Get wilaya by phone code

wilaya, err := l.GetWilayaByPhoneCode(49)
if err != nil {
    panic(err)
}

Filter wilaya by a specific field

wilaya, err := l.GetWilayaByPhoneCode(49, "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

wilaya, err := l.GetWilayaByPhoneCode(49, "name", "dairats", "matricule")
if err != nil {
    panic(err)
}

GetWilayaByDairaName

Get wilaya by daira name

wilaya, err := l.GetWilayaByDairaName("ADRAR")
if err != nil {
    panic(err)
}

Filter wilaya by a specific field

wilaya, err := l.GetWilayaByDairaName("ADRAR", "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

wilaya, err := l.GetWilayaByDairaName("ADRAR", "name", "dairats", "matricule")
if err != nil {
    panic(err)
}

GetBaladyiatsForDaira

Get baladyiats for a daira

baladyiats, err := l.GetBaladyiatsForDaira("ADRAR")
if err != nil {
    panic(err)
}

Filter baladyiats by a specific field

baladyiats, err := l.GetBaladyiatsForDaira("ADRAR", "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

baladyiats, err := l.GetBaladyiatsForDaira("ADRAR", "name", "code")
if err != nil {
    panic(err)
}

fields can be one of the following:

baladyia field description
code baladyia code
name baladyia name
name_ar baladyia name in arabic
name_en baladyia name in english

GetBaladyiatsForDairaCode

Get baladyiats for a daira code

baladyiats, err := l.GetBaladyiatsForDairaCode(101)
if err != nil {
    panic(err)
}

Filter baladyiats by a specific field

baladyiats, err := l.GetBaladyiatsForDairaCode(101, "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

baladyiats, err := l.GetBaladyiatsForDairaCode(101, "name", "code")
if err != nil {
    panic(err)
}

GetPhoneCodesForWilaya

Get phone codes for a wilaya

phoneCodes, err := l.GetPhoneCodesForWilaya("Adrar")
if err != nil {
    panic(err)
}

GetFirstPhoneCodeForWilaya

Get first phone code for a wilaya

phoneCode, err := l.GetFirstPhoneCodeForWilaya("Adrar")
if err != nil {
    panic(err)
}

GetBaladyiatsForWilaya

Get baladyiats for a wilaya

baladyiats, err := l.GetBaladyiatsForWilaya("Adrar")
if err != nil {
    panic(err)
}

Filter baladyiats by a specific field

baladyiats, err := l.GetBaladyiatsForWilaya("Adrar", "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

baladyiats, err := l.GetBaladyiatsForWilaya("Adrar", "name", "code")
if err != nil {
    panic(err)
}

GetWilayaByBaladyiaName

Get wilaya by baladyia name

wilaya, err := l.GetWilayaByBaladyiaName("ADRAR")
if err != nil {
    panic(err)
}

Filter wilaya by a specific field

wilaya, err := l.GetWilayaByBaladyiaName("ADRAR", "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

wilaya, err := l.GetWilayaByBaladyiaName("ADRAR", "name", "dairats", "matricule")
if err != nil {
    panic(err)
}

GetDairaByBaladyiaName

Get daira by baladyia name

daira, err := l.GetDairaByBaladyiaName("ADRAR")
if err != nil {
    panic(err)
}

Filter daira by a specific field

daira, err := l.GetDairaByBaladyiaName("ADRAR", "name")
if err != nil {
    panic(err)
}

it accept a variadic number of fields

daira, err := l.GetDairaByBaladyiaName("ADRAR", "name", "code")
if err != nil {
    panic(err)
}

Contributing

Contributions are welcome, please read the contributing guide for more information.

License

MIT

About

A go module providing a list of Algerian administrative areas with many useful APIs, based on dzcode-io/leblad

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Languages