Jupiter 0.0.2

Jupiter 0.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Comyar Zaheri.



Jupiter 0.0.2

  • By
  • Comyar Zaheri

Usage

Supported Weather APIs:

Dark Sky

Forecast Request

A default Request.send function is provided that simply uses the shared URLSession in your app:

import Jupiter

let api = DarkSkyAPI(key: "<API_KEY>")
api.forecast(latitude: 47.6062, longitude: -122.3321).send { result -> Void in
  switch result {
  case .success(let response):
    // The response here is queryable for any key available in the docs except for "flags"
    print(response)
  case .error(let error):
    print(error)
  }
}

However if you’d like to use your own networking stack, you can simply create a DarkSkyForecastRequest and use the generated URL directly:

import Jupiter

let api = DarkSkyAPI(key: "<API_KEY>")
let request = api.forecast(latitude: 47.6062, longitude: -122.3321)

/// Creating without the convenience API also works:
/// let request = DarkSkyForecastRequest(key: "<API_KEY>", latitude: 47.6062, longitude: -122.3321)

/// Configure the request
request.excludes = [.minutely, .hourly]
request.lang = .russian
request.units = .si

/// Get the URL
let url: URL = request.url!

/// Pass URL to networking layer 

/// Get raw data from networking layer
let data: Data = ...

/// Parse data and bind to response object
let response = request.toResponse(data: data)

License

Jupiter is released under the MIT license. See LICENSE for details.