Skip to content

Commit

Permalink
Merge pull request #3 from JohnnyTheTank/5-day-forecast
Browse files Browse the repository at this point in the history
bump to new version (v0.6.0)
  • Loading branch information
JohnnyTheTank authored Sep 25, 2016
2 parents 6adafb8 + 3ae1316 commit 74be4ea
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 14 deletions.
66 changes: 59 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
1. `bower install --save angular-openweathermap-api-factory`
2. `npm install --save angular-openweathermap-api-factory`
3. download [angular-openweathermap-api-factory.zip](https://github.com/JohnnyTheTank/angular-openweathermap-api-factory/zipball/master)
2. Add `jtt_openweathermap` to your application's module dependencies.
2. Add **`jtt_openweathermap`** to your application's module dependencies.
3. Include dependencies in your HTML.
1. When using bower:
```html
Expand All @@ -28,9 +28,11 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
4. Use the factory `openweathermapFactory`


### factory methods
## factory methods

#### weather from city by name
### current weather

#### current weather from city by name
```js
// docs: http://openweathermap.org/current#name
openweathermapFactory.getWeatherFromCitySearchByName({
Expand All @@ -46,7 +48,7 @@ openweathermapFactory.getWeatherFromCitySearchByName({
});
```

#### weather from city by id
#### current weather from city by id
```js
// docs: http://openweathermap.org/current#cityid
openweathermapFactory.getWeatherFromCityById({
Expand All @@ -61,7 +63,7 @@ openweathermapFactory.getWeatherFromCityById({
});
```

#### weather from group of cities by id
#### current weather from group of cities by id
```js
// docs: http://openweathermap.org/current#severalid
openweathermapFactory.getWeatherFromGroupOfCitiesById({
Expand All @@ -76,7 +78,7 @@ openweathermapFactory.getWeatherFromGroupOfCitiesById({
});
```

#### weather from location by coordinates
#### current weather from location by coordinates
```js
// docs: http://openweathermap.org/current#geo
openweathermapFactory.getWeatherFromLocationByCoordinates({
Expand All @@ -92,7 +94,7 @@ openweathermapFactory.getWeatherFromLocationByCoordinates({
});
```

#### weather from location by zipcode
#### current weather from location by zipcode
```js
// docs: http://openweathermap.org/current#zip
openweathermapFactory.getWeatherFromLocationByCoordinates({
Expand All @@ -107,6 +109,56 @@ openweathermapFactory.getWeatherFromLocationByCoordinates({
});
```

### 5-day-forecast

#### 5-day-forecast from city by name
```js
// docs: http://openweathermap.org/forecast5#name5
openweathermapFactory.cityForecast5SearchByName({
q:"<CITY_NAME>,<COUNTRY_CODE>", //city name and country code divided by comma, use ISO 3166 country codes eg "London,uk"
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
type:"<TYPE>", // (optional) 'like' = close result, 'accurate' = accurate result
appid:"<APP_ID>"
}).then(function(_data){
//on success
}).catch(function (_data) {
//on error
});
```

#### 5-day-forecast from city by id
```js
// docs: http://openweathermap.org/forecast5#cityid5
openweathermapFactory.getForecast5FromCityById({
id:"<CITY_ID>", //List of city ID can be downloaded here http://bulk.openweathermap.org/sample/city.list.json.gz
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
appid:"<APP_ID>"
}).then(function(_data){
//on success
}).catch(function (_data) {
//on error
});
```

#### 5-day-forecast from location by coordinates
```js
// docs: http://openweathermap.org/forecast5#geo5
openweathermapFactory.getForecast5FromLocationByCoordinates({
lat:"<LAT>",
lon:"<LONG>",
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
appid:"<APP_ID>"
}).then(function(_data){
//on success
}).catch(function (_data) {
//on error
});
```


## OpenWeatherMap JSON API
* docs: http://openweathermap.org/api

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-openweathermap-api-factory",
"description": "angularjs factory for openweathermap json rest api requests",
"version": "0.5.0",
"version": "0.6.0",
"main": "dist/angular-openweathermap-api-factory.js",
"authors": [
"Jonathan Hornung"
Expand Down
22 changes: 22 additions & 0 deletions demo/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,26 @@ app.controller('controller', ['$scope', 'openweathermapFactory', function($scope
console.info("weather from location by zipcode", _data);
});

openweathermapFactory.getForecast5FromCitySearchByName({
q:"munich",
appid:_appid
}).then(function(_data){
console.info("5 day forecast from city by name", _data);
});

openweathermapFactory.getForecast5FromCityById({
id:"3220838",
appid:_appid
}).then(function(_data){
console.info("5 day forecast from city by id", _data);
});

openweathermapFactory.getForecast5FromLocationByCoordinates({
lat:"48.1",
lon:"11.63",
appid:_appid
}).then(function(_data){
console.info("5 day forecast from location by coordinates", _data);
});

}]);
52 changes: 50 additions & 2 deletions dist/angular-openweathermap-api-factory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@name: angular-openweathermap-api-factory
@version: 0.5.0 (25-02-2016)
@version: 0.6.0 (25-09-2016)
@author: Jonathan Hornung
@url: https://github.com/JohnnyTheTank/angular-openweathermap-api-factory#readme
@license: MIT
Expand Down Expand Up @@ -57,6 +57,33 @@ angular.module("jtt_openweathermap", [])
});
};

openweathermapFactory.getForecast5FromCitySearchByName = function (_params) {
var searchData = openweathermapSearchDataService.getNew("cityForecast5SearchByName", _params);
return $http({
method: 'GET',
url: searchData.url,
params: searchData.object,
});
};

openweathermapFactory.getForecast5FromCityById = function (_params) {
var searchData = openweathermapSearchDataService.getNew("cityForecast5ById", _params);
return $http({
method: 'GET',
url: searchData.url,
params: searchData.object,
});
};

openweathermapFactory.getForecast5FromLocationByCoordinates = function (_params) {
var searchData = openweathermapSearchDataService.getNew("locationForecast5ByCoordinates", _params);
return $http({
method: 'GET',
url: searchData.url,
params: searchData.object,
});
};

return openweathermapFactory;
}])
.service('openweathermapSearchDataService', function () {
Expand Down Expand Up @@ -117,7 +144,28 @@ angular.module("jtt_openweathermap", [])
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
break;

case "cityForecast5SearchByName":
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
'q', 'lang', 'type', "units",
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
break;

case "cityForecast5ById":
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
'id', 'lang', "units",
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
break;

case "locationForecast5ByCoordinates":
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
'lat', 'lon', 'lang', "units",
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
break;
}
return openweathermapSearchData;
};
});
});
4 changes: 2 additions & 2 deletions dist/angular-openweathermap-api-factory.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-openweathermap-api-factory",
"version": "0.5.0",
"version": "0.6.0",
"description": "angularjs factory for openweathermap json rest api requests",
"main": "dist/angular-openweathermap-api-factory.js",
"scripts": {
Expand Down
51 changes: 50 additions & 1 deletion src/angular-openweathermap-api-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ angular.module("jtt_openweathermap", [])
});
};

openweathermapFactory.getForecast5FromCitySearchByName = function (_params) {
var searchData = openweathermapSearchDataService.getNew("cityForecast5SearchByName", _params);
return $http({
method: 'GET',
url: searchData.url,
params: searchData.object,
});
};

openweathermapFactory.getForecast5FromCityById = function (_params) {
var searchData = openweathermapSearchDataService.getNew("cityForecast5ById", _params);
return $http({
method: 'GET',
url: searchData.url,
params: searchData.object,
});
};

openweathermapFactory.getForecast5FromLocationByCoordinates = function (_params) {
var searchData = openweathermapSearchDataService.getNew("locationForecast5ByCoordinates", _params);
return $http({
method: 'GET',
url: searchData.url,
params: searchData.object,
});
};

return openweathermapFactory;
}])
.service('openweathermapSearchDataService', function () {
Expand Down Expand Up @@ -110,7 +137,29 @@ angular.module("jtt_openweathermap", [])
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
break;

case "cityForecast5SearchByName":
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
'q', 'lang', 'type', "units",
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
break;

case "cityForecast5ById":
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
'id', 'lang', "units",
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
break;

case "locationForecast5ByCoordinates":
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
'lat', 'lon', 'lang', "units",
]);
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
break;

}
return openweathermapSearchData;
};
});
});

0 comments on commit 74be4ea

Please sign in to comment.