Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update node.md #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 74 additions & 152 deletions docs/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ By default all Filters set to be `false`. If certain value is required set that

#### Countries

- Retrieve Countries
- Returns Countries

```js
const hawqal = require("@capregsoft/hawqal");
const AllCountries = async () => console.log(await hawqal.getCountries());
AllCountries();
```
<span style="font-weight:bold;"> Success Response</span>

```
[
{
country_name: 'Cameroon',
Expand Down Expand Up @@ -87,57 +83,12 @@ By default all Filters set to be `false`. If certain value is required set that
latitude: '60',
longitude: '-95'
},
{
country_name: 'Cape Verde',
iso_code: 'CPV',
phone_code: '+238',
capital: 'Praia',
currency: 'CVE',
currency_name: 'Cape Verdean escudo',
currency_symbol: '$',
country_domain: '.cv',
region: 'Africa',
subregion: 'Western Africa',
timezone: 'Atlantic ',
UTC: ' -1:00 ',
latitude: '16',
longitude: '-24'
},
...
]

```

- Search Country

```js
const searchCountry = async (countryName) => console.log(await hawqal.getCountry(countryName));
searchCountry('pakistan');
```
<span style="font-weight:bold;"> Success Response</span>

```
[
{
country_name: 'Pakistan',
iso_code: 'PAK',
phone_code: '+92',
capital: 'Islamabad',
currency: 'PKR',
currency_name: 'Pakistani rupee',
currency_symbol: '₨',
country_domain: '.pk',
region: 'Asia',
subregion: 'Southern Asia',
timezone: 'Asia ',
UTC: ' 05:00 ',
latitude: '30',
longitude: '70'
}
]
```

- Show all Countries along `filter`
- Returns Countries with Filters

```js
const allCountries = async (filters) =>
Expand All @@ -148,11 +99,6 @@ By default all Filters set to be `false`. If certain value is required set that
country_name:true
});

```

<span style="font-weight:bold;"> Success Response</span>

```
[
{
phone_code: '+93',
Expand All @@ -171,20 +117,44 @@ By default all Filters set to be `false`. If certain value is required set that
},
...
]
```
```
### Country
- Returns single Country data

#### States
```js
const searchCountry = async (countryName) => console.log(await hawqal.getCountry(countryName));
searchCountry('pakistan');

[
{
country_name: 'Pakistan',
iso_code: 'PAK',
phone_code: '+92',
capital: 'Islamabad',
currency: 'PKR',
currency_name: 'Pakistani rupee',
currency_symbol: '₨',
country_domain: '.pk',
region: 'Asia',
subregion: 'Southern Asia',
timezone: 'Asia ',
UTC: ' 05:00 ',
latitude: '30',
longitude: '70'
}
]
```

- Retrieve States of all Countries


### States

- Returns States

```js
const allStates = async () => console.log(await hawqal.getStates());
allStates();
```

<span style="font-weight:bold;"> Success Response</span>

```

[
{
state_id: 3901,
Expand All @@ -200,59 +170,22 @@ By default all Filters set to be `false`. If certain value is required set that
latitude: '35.1671339',
longitude: '63.7695384'
},
{
state_id: 3875,
state_name: 'Baghlan',
country_name: 'Afghanistan',
latitude: '36.1789026',
longitude: '68.7453064'
},
...
]
```

- Search specific State
```js
const searchState = async (state) => console.log(await hawqal.getState(state));
searchState('punjab');

```

<span style="font-weight:bold;"> Success Response</span>

```
[
{
state_id: 4015,
state_name: 'Punjab',
country_name: 'India',
latitude: '31.1471305',
longitude: '75.3412179'
},
{
state_id: 3176,
state_name: 'Punjab',
country_name: 'Pakistan',
latitude: '31.1471305',
longitude: '75.3412179'
}
]
```
- Use of filter
- Return State with Filters

```js
```js
const allStatesCountry = async (country,filter) => console.log(await hawqal.getStates(country,filter));
allStatesCountry("finland",{
state_name:true,
country_name:true,
longitude:true,
latitude:true
});
```

<span style="font-weight:bold;"> Success Response</span>

```

[
{
state_name: 'Åland Islands',
Expand All @@ -275,18 +208,38 @@ By default all Filters set to be `false`. If certain value is required set that
...
]
```
#### Cities
### State
- Returns Single State
```js
const searchState = async (state) => console.log(await hawqal.getState(state));
searchState('punjab');

- Retrieve Cities of Country
[
{
state_id: 4015,
state_name: 'Punjab',
country_name: 'India',
latitude: '31.1471305',
longitude: '75.3412179'
},
{
state_id: 3176,
state_name: 'Punjab',
country_name: 'Pakistan',
latitude: '31.1471305',
longitude: '75.3412179'
},
...
]
```
#### Cities

- Returns Cities

```js
const getCities = async (country,state,filter) => console.log(await hawqal.getCities(country,state,filter));
getCities('finland','',{});
```

<span style="font-weight:bold;"> Success Response</span>

```

[
{
city_id: 39132,
Expand All @@ -306,28 +259,15 @@ By default all Filters set to be `false`. If certain value is required set that
latitude: '62.38333',
longitude: '26.43333'
},
{
city_id: 38809,
city_name: 'Jämsä',
state_id: 1511,
state_name: 'Central Finland',
country_name: 'Finland',
latitude: '61.8642',
longitude: '25.19002'
},
...
]
```
- Retrieve all Cities within State
- Retrieve all Cities with State name

```js
```js
const getCities = async (country,state,filter) => console.log(await hawqal.getCities(country,state,filter));
getCities('','Kainuu',{});
```

<span style="font-weight:bold;"> Success Response</span>

```

[
{
city_id: 38778,
Expand All @@ -347,31 +287,18 @@ By default all Filters set to be `false`. If certain value is required set that
latitude: '64.22728',
longitude: '27.72846'
},
{
city_id: 38877,
city_name: 'Kuhmo',
state_id: 1496,
state_name: 'Kainuu',
country_name: 'Finland',
latitude: '64.13333',
longitude: '29.51667'
},
...
]

```

### City
- Returns Single City

- Search City

```js
```js
const searchCity = async (city) => console.log(await hawqal.getCity(city));
searchCity('islamabad');
```

<span style="font-weight:bold;"> Success Response</span>

```

[
{
city_id: 85475,
Expand All @@ -387,20 +314,16 @@ By default all Filters set to be `false`. If certain value is required set that



- Search City `with filter`
- Returns Single City with Filter

```js
```js
const searchCity = async (city,filter) => console.log(await hawqal.getCity(city,filter));
searchCity('islamabad',{
city_name:true,
state_name:true,
country_name:true
});
```

<span style="font-weight:bold;"> Success Response</span>

```

[
{
city_name: 'Islamabad',
Expand All @@ -410,4 +333,3 @@ By default all Filters set to be `false`. If certain value is required set that
]

```