-
Notifications
You must be signed in to change notification settings - Fork 4
Create a New Provider
johnluetke edited this page Mar 27, 2013
·
3 revisions
Creating a new provider is very straight-forward. These steps presume you have already forked the repository.
-
Create a new package (Java) or Namespace (.NET) for your provider in the
WeatherAPI.Providersparent namespace. For example, if you are creating a provider for the Awesome Weather Service, the new namespace would be namedWeatherAPI.Providers.AwesomeWeather. The class name inside this package does not matter. We will useAwesomeWeatherProviderin this example. -
Ensure that the
AwesomeWeatherProviderclass inherits fromWeatherProviderand implementsIWeather. -
Start by implementing the abstract methods inherited from
WeatherProvider:
-
IsAvailable: returns true or false depending on whether or not the service that the provider uses is available to some code using this library. For example, if the service requires and API Key, this method should make sure that the API key have been specified in configuration. It should not go out and ping the service to make sure that it is responsive. -
Supports: Weather data can be requested for a number of different "types" of locations, such as an airport code, a postal code, latitude / longitude, etc. One of these types will be passed to this method, and it should return true or false based on weather or nor the service can support retrieving data for that type of location. See theLocationTypeenumeration for the possibilities. -
Update: Is the big kahuna. This method is what goes out to the service and fetches data.
- Next, implement the methods specified by the
IWeatherinterface. These methods return details about the weather retrieved from the service, such as the current temperature, humidity, conditions, cloud cover, etc.