Latest 0.0.2
Homepage https://github.com/jolucama/OpenWeatherMapAPIConsumer
License MIT
Platforms ios 10.2
Authors

Open Weather Map API Consumer fully Unit Tested, being able to get current weather and 3-hourly forecast 5 days for your city. Helpful stats, temperature, clouds, pressure, wind around your location… This API is a consumer of Open Weather Map and the description of the api may be found here

Note: In the consumer has been implemented just the free version of the API. In order to start using it, please register and get the API Key Sign up

[![CI Status](http://img.shields.io/travis/Jose Luis Cardosa/OpenWeatherMapAPIConsumer.svg?style=flat)](https://travis-ci.org/Jose Luis Cardosa/OpenWeatherMapAPIConsumer)
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

OpenWeatherMapAPIConsumerOpenWeatherMapAPIConsumer

Basically, the example makes use of the CLLocationManager to obtain the current coordenates, and then make a request to our API to get all the displayed information. All the code is located in View Controller

Requirements

  • iOS 10.2
  • Swift 3
  • Xcode 8

Installation

OpenWeatherMapAPIConsumer is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "OpenWeatherMapAPIConsumer"

Usage

Import the pod in your file

import OpenWeatherMapAPIConsumer

Setup the api key


// Type by default OpenWeatherMapType.Current
let weatherAPI = OpenWeatherMapAPI(apiKey: "YOUR_API_KEY")

// Type forecast
let weatherAPI = OpenWeatherMapAPI(apiKey: "YOUR_API_KEY", forType: OpenWeatherMapType.Forecast)

Set the location using


public func weather(byLatitude latitude : Double, andLongitude longitude : Double)

public func weather(byCityName cityName : String)

public func weather(byCityName cityName : String, andCountryCode countryCode: String)

// List of city ids may be found here: http://bulk.openweathermap.org/sample/
public func weather(byCityId cityId : Int)

API Options

public func setSearchAccuracy(searchAccuracy : SearchAccuracyType)

public func setLimitationOfResult(in limitation : Int)

public func setTemperatureUnit(unit : TemperatureFormat)

public func setMultilingualSupport(language : Language)

Perform request

public func performWeatherRequest(completionHandler: @escaping (Data?, URLResponse?, Error?) -> Swift.Void)

//Example
weatherAPI.performWeatherRequest(completionHandler:{(data: Data?, urlResponse: URLResponse?, error: Error?) in
    if (error != nil) {
        //Handling error
    } else {
        do {
            let responseWeatherApi = try CurrentResponseOpenWeatherMap(data: data!)
        } catch let error as Error {
            //Handling error
        }
    }
})

Response classes

The response classes are parsers, that give you a better use of the api response

  • CurrentResponseOpenWeatherMap(data : Data)
  • ForecastResponseOpenWeatherMap(data : Data)

func getCoord() -> CLLocationCoordinate2D

func getTemperature() -> Float

func getPressure() -> Float

func getHumidity() -> Float

func getTempMax() -> Float

func getTempMin() -> Float

func getCityName() -> String

func getIconList() -> IconList

func getDescription() -> String

func getWindSpeed() -> Float

func getDate() -> Date

Author

Jose Luis Cardosa, [email protected]

License

OpenWeatherMapAPIConsumer is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "OpenWeatherMapAPIConsumer",
    "version": "0.0.2",
    "summary": "Get current weather and 3-hourly forecast 5 days for your city. Helpful stats, temperature, clouds, pressure, wind around your location.",
    "description": "Access current weather data for any location on Earth including over 200,000 cities! Current weather is frequently updated based on global models and data from more than 40,000 weather stations. Also 5 day forecast is available at any location or city. It includes weather data every 3 hours. Data is available in JSON Format.",
    "homepage": "https://github.com/jolucama/OpenWeatherMapAPIConsumer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jose Luis Cardosa": "[email protected]"
    },
    "source": {
        "git": "https://github.com/jolucama/OpenWeatherMapAPIConsumer.git",
        "tag": "0.0.2"
    },
    "platforms": {
        "ios": "10.2"
    },
    "source_files": "OpenWeatherMapAPIConsumer/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This