Weather

Weather

Weather

Asset Version: 1.0.0
  • Version 1.0.0
Last Published: Apr 25, 2017 By: Kony Team
102 1 0 21
Weather is a Mobile Fabric Application with collection of the top 6 most used Weather sources as integration services. Get current weather for a specific location based on your current geolocation, zip code, city, state or country. Retrieve a weather forecast, show weather alerts and weather related maps and images easily with the help of this preconfigured ready to use services.

Requirements

  • MobileFabric
 

Features

  • Ready-to-use backend service for weather mobile apps
  • Predefined services to obtain weather information from AccuWeather, Dark Sky, NOAA Weather, OpenWeatherMap, WUnderground, World Weather, Yahoo Weather
  • Flexible to create new services to map with any weather web service provider
  • Easy to make API calls and view responses

Prerequisites

  • Kony Fabric v8

WeatherApp is a MobileFabric application that provides back end services to the users. The app contains a set of weather APIs. Using the APIs, users can obtain the weather information of any location in the world.

Use Case:

Consider a case that you want to develop an app that uses weather information. In this app, you want to develop a feature that helps users to plan daily activities based on the forecast of the weather conditions. Using the pre-configured services in the WeatherApp, you can obtain the required weather information.

You can import WeatherApp into your Kony cloud account and access the services provided in WeatherApp. You can configure the services and achieve the desired results.

The following sections help you use WeatherApp.

Prerequisites

Before you start using the WeatherApp component, ensure the following:

  1. Kony account
  2. Kony Visualizer Enterprise 7.3
  3. Kony MobileFabric 7.3

Importing the WeatherApp

The WeatherApp contains a set of integration services and orchestration services by default. These services fetch the required information using the Weather APIs. Using the MobileFabric console, you can view and modify these services.

To import the WeatherApp, do the following:

  1. Log on to your Kony account. The Dashboard page appears by default.
  2. In the left pane, click Appsmenu . The Custom Apps page appears.
  3. Click IMPORT. The Import App dialog appears.
  4. Click Browse.
  5. Select the WeatherApp zip file located in your system and click Open.
  6. In the Import App dialog, click IMPORT.

 

To associate your app with the WeatherApp, do the following:

  1. In Kony Visualizer, open your app to which you have added the component.
  2. On the Projects tab, click MobileFabric. The Bind MobileFabric Application dialog appears.
  3. Click Use Existing. The MobileFabic Applications dialog appears with a list of existing apps.
  4. Find the app, and click the Associate button against the app.
Note:

You can find the app by typing the app's name in the Search box.

After you associate your app with the WeatherApp, you can view the integration services, and orchestration services, which are created by default. You can modify these services to fit your use case.

Integration Services

The WeatherApp MobileFabric app contains a set of integration services. The integration services are configured by default to connect your app to the Weather APIs. The integration service is responsible to fetch search results from the respective service provider.

To view the WeatherApp integration services, do the following:

  1. Log on to your Kony account. the Dashboard page appears by default.
  2. In the left pane, click the Apps menu. The Custom Apps page appears.
  3. Find and click the WeatherApp app. The WeatherApp page appears along with the Configure Services tab and the Identity sub-tab opened by default.
    Note:

    You can find the app by typing the app's name in the Search box.

  4. Click the Integration sub-tab. The Integration tab displays a list of integration services.

    weatherapp_integration.png

  5. Click on the required integration service. The Service Definition tab of the selected integration service opens by default.

You can edit the required integration service as you require. For more information, refer Integration Service.

The WeatherApp contains the following Integration Services:

 

accuWeather

The accuWeather integration service fetches the weather information of any location in the world using the AccuWeather APIs. You need Location Key to use the integration service. Use the AccuWeatherService if you do not have the Location Key.

The accuWeather integration service contains getForecast operation.

  • The getForecast operation contains the following input parameters:
    • locationKey: Obtains the location key. By default, the VALUE of the locationKey is set to session. Change the value to request.
      weatherapp_value.png
    • key: Specifies the API key. To generate the key, visit http://developer.accuweather.com/

    The output of the operation depends on the service provider. For more information, refer http://apidev.accuweather.com/developers/forecasts

The following procedure explains how to execute the getForecast operation and view the response:

  1. Click the Integration sub-tab. The Integration tab displays a list of integration services.
  2. Click accuWeather. The Service Definition tab of the selected integration service opens by default.
  3. Click Operations List tab. The Operations List tab opens.
  4. In the Configured Operations section, click getForecast. The getForecast tab opens with the Request Input sub-tab and Body section opened by default.

    weatherapp_operation.png

  5. Click Fetch Response. The Backend Response dialog appears with the response.

    weatherapp_backend.png

Note:

You can follow the above procedure to execute operations of other integration services.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

//Code to invoke parent integration service should be present to use below code.

serviceName = "accuWeather";
integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName);

operationName = "getForecast";
data= {"locationKey":"<Location Key>","key":"<API KEY>"};
headers= {};
integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);
function operationSuccess(res){
	//code for success call back
}
function operationFailure(res){
	//code for failure call back
} 

darksky

The darksky integration service fetches the weather information of any location in the world using the Dark Sky APIs.

The darksky integration service contains getForecast operation.

  • The getForecast operation contains the following input parameters:

    • key: Specifies the API key. To generate the key, visit https://darksky.net/dev/
    • lat: Obtains the latitude of the location
    • long: Obtains the longitude of the location

    The output of the operation depends on the service provider. For more information, refer https://darksky.net/dev/docs/forecast

To execute the getForecast operation and view the response, follow the steps provided in the accuWeather integration service.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

 //Code to invoke parent integration service should be present to use below code.

serviceName = "darksky";
integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName);

operationName = "getForecast";
data= {“key”:”<API KEY>”,"lat": "<Latitude>","long": "<Longitude>"};
headers= {};
integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);
function operationSuccess(res){
	//code for success call back
}
function operationFailure(res){
	//code for failure call back
} 

noaaWeather

The noaaWeather integration service fetches the weather information of any location in the United States of America using the NOAA National Weather Service APIs.

The Accuweather integration service contains getForecast operation.

  • The getForecast operation contains the following input parameters:

    • lat: Obtains the latitude of the location
    • long: Obtains the longitude of the location

    The output of the operation depends on the service provider. For more information, refer https://forecast-v3.weather.gov/documentation

To execute the getForecast operation and view the response, follow the steps provided in the accuWeather integration service.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

//Code to invoke parent integration service should be present to use below code.
serviceName = "noaaWeather";
integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName);

operationName = "getForecast";
data= {"lat": "<Latitude>","long": "<Longitude>"};
headers= {};
integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);
function operationSuccess(res){
	//code for success call back
}
function operationFailure(res){
	//code for failure call back

}

openWeatherMap

The openWeatherMap integration service fetches the weather information of any location in the world using the OpenWeatherMap APIs.

The openWeatherMap integration service contains getForecast operation.

  • The getForecast operation contains the following input parameters:

    • key: Specifies the API key. To generate the key, visit https://openweathermap.org/api
    • lat: Obtains the latitude of the location
    • long: Obtains the longitude of the location

    The output of the operation depends on the service provider. For more information, refer https://openweathermap.org/current

To execute the getForecast operation and view the response, follow the steps provided in the accuWeather integration service.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

//Code to invoke parent integration service should be present to use below code.
serviceName = "openWeatherMap"; integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName); operationName = "getForecast"; data= {“key”:”<API KEY>”,"lat": "<Latitude>","long": "<Longitude>"}; headers= {}; integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure); function operationSuccess(res){ //code for success call back } function operationFailure(res){ //code for failure call back }

wunderground

The wunderground integration service fetches the weather information of any location in the world using the Wunderground APIs.

The wunderground integration service contains getForecast operation.

To execute the getForecast operation and view the response, follow the steps provided in the accuWeather integration service.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

//Code to invoke parent integration service should be present to use below code.
serviceName = "wunderground"; integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName); operationName = "getForecast"; data= {“key”:”<API KEY>”,"lat": "<Latitude>","long": "<Longitude>"}; headers= {}; integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure); function operationSuccess(res){ //code for success call back } function operationFailure(res){ //code for failure call back }

worldweather

The worldweather integration service fetches the weather information of any location in the world using the World Weather Online APIs.

The worldweather integration service contains getForecast operation.

To execute the getForecast operation and view the response, follow the steps provided in the accuWeather integration service.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

//Code to invoke parent integration service should be present to use below code.
serviceName = "worldweather"; integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName); operationName = "getForecast"; data= {“key”:”<API KEY>”,"lat": "<Latitude>","long": "<Longitude>"}; headers= {}; integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure); function operationSuccess(res){ //code for success call back } function operationFailure(res){ //code for failure call back }

yahoo

The yahoo integration service fetches the weather information of any location in the world using the Yahoo Weather APIs.

The yahoo integration service contains getForecast operation.

  • The getForecast operation contains the following input parameters:

    • lat: Obtains the latitude of the location
    • long: Obtains the longitude of the location

    The output of the operation depends on the service provider. For more information, refer https://developer.yahoo.com/weather/

To execute the getForecast operation and view the response, follow the steps provided in the accuWeather integration service.

Sample Code:

You can generate the sample code for an integration service from MobileFabric. Then use that code in the mobile app to invoke the integration service instance.

//Code to invoke parent integration service should be present to use below code.
serviceName = "yahoo"; integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName); operationName = "getForecast"; data= {"lat": "<Latitude>","long": "<Longitude>"}; headers= {}; integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure); function operationSuccess(res){ //code for success call back } function operationFailure(res){ //code for failure call back }

Orchestration Services

Service orchestration is the coordination or integration of several services and exposing them as a single service. The mix of services supports the automation of business processes. For more information, refer orchestration service.

The WeatherApp contains the following orchestration Service.

AccuWeatherService

The AccuWeatherService fetches the weather information of any location in the world using the Accuweather APIs.

The service contains getForecast operation.

 

Sample Code:

You can generate the sample code for an orchestration service from MobileFabric. Then use that code in the mobile app to invoke the orchestration service instance.

//Code to invoke parent integration service should be present to use below code.

serviceName = "AccuWeatherService";
integrationObj = kony.sdk.getCurrentInstance().getIntegrationService(serviceName);

operationName = "getForecast";
data= {“key”:”<API KEY>”,"lat": "<Latitude>","long": "<Longitude>"};
headers= {};
integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);
function operationSuccess(res){
	//code for success call back
}
function operationFailure(res){
	//code for failure call back
}