Skip to content

The International Standard for country codes and codes for their subdivisions on Nim

Notifications You must be signed in to change notification settings

KingDarBoja/Iridium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iridium

The International Standard for country codes and codes for their subdivisions on Nim (ISO-3166).

GitHub issues GitHub stars

Usage

>>> import iridium
>>> echo getCountryByCode("CO")
(name: "Colombia", alpha2: "CO", alpha3: "COL", numeric: "170", official: "Republic of Colombia")
>>> echo getSubdivisionByCode("CO-QUI")
(name: "Quindío", category: "Department", parent: "")

Install

nimble install iridium

Requisites

Documentation

Types

The country data is stored as a CountryDivision object with the following fields:

type
  CountryDivision* = object
    name*: string       ## Country name (short)
    alpha2*: string     ## Two letter alphabetic code of the country
    alpha3*: string     ## Three letter alphabetic code of the country
    numeric*: string    ## Three digit numeric code of the country, including leading zeros
    official*: string   ## Official name of the country (optional)

The country subdivision is stored as a CountrySubdivision object with the following fields:

type
  CountrySubdivision* = object
    name*: string        ## Name of the country subdivision
    category*: string    ## Type of subdivision of the country (i.e. Province, Region, Emirate)
    parent*: string      ## Parent of the country subdivision

Procedures

Each procedure will raise a KeyError if the code does not satisfy certain checks (i.e. code does not exist, invalid numeric code).

ISO-3166-1 Related

  • getAllCountries()

    Get all the countries data as a Nim Table whose keys are the country alpha2 code and the values as CountryDivision object.

    • Arguments: None
    • Returns: Table[string, CountryDivision]
  • getCountryByCode()

    Get the country data by its alpha2 code.

    • Arguments:
      • code ISO-3166-1 alpha2 code, required.
    • Returns: CountryDivision
  • getCountryByName()

    Get the country data by its name.

    • Arguments:
      • countryName The common name, required.
    • Returns: CountryDivision
  • getCountryByAlpha3()

    Get the country data by its alpha3 code.

    • Arguments:
      • alpha3Code ISO-3166-1 alpha3 code, required.
    • Returns: CountryDivision
  • getCountryByNumeric()

    Get the country data by its numeric code.

    • Arguments:
      • numericCode ISO-3166-1 numeric code as string or integer, required.
    • Returns: CountryDivision

ISO-3166-2 Related

  • getAllSubdivisions()

    Get all the subdivisions data as a Nim Table whose keys are the subdivision code (country-subdivision) and the values as CountrySubdivision object.

    • Arguments: None
    • Returns: Table[string, CountrySubdivision]
  • getSubdivisionsByCountry()

    Get the country subdivisions data by its code as a sequence.

    • Arguments:
      • countryCode ISO-3166-1 alpha2 country code as string, required.
    • Returns: seq[CountrySubdivision]
  • getSubdivisionByCode()

    Get the subdivision data by its code.

    • Arguments:
      • numericCode ISO-3166-2 code as string, required.
    • Returns: CountrySubdivision

ISO-4217 Related

  • getAllCurrencies()

    Get all the currencies as a Nim table whose keys are the currency alphabetic code and the values as CurrencyCode object.

    • Arguments: None
    • Returns: Table[string, CurrencyCode]
  • getCurrencyByCode()

    Get the currency data by its alphabetic code.

    • Arguments:
      • code ISO-4217 alphabetic code as string, required.
    • Returns: CurrencyCode

About

The International Standard for country codes and codes for their subdivisions on Nim

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages