OpenWeatherAPI

1.0.0

A Swift package for the Open Weather One Call 3.0 API
mattboran/OpenWeatherAPI

What's New

v1.0.0

2023-03-01T05:31:56Z

What's Changed

  • Test and Fix issues with Swiftlint by @mattboran in #1
  • Add unit tests by @mattboran in #2
  • Update Readme by @mattboran in #3
  • Add docc doc by @mattboran in #4
  • Some miscellaneous fixes to the documentation generation and README were added directly in main

New Contributors

Full Changelog: https://github.com/mattboran/OpenWeatherAPI/commits/v1.0.0

OpenWeatherAPI

This Swift package provides a simple and easy-to-use interface to integrate your apps with the OpenWeather One Call 3.0 API.

Installation

To add this package to your Swift project, add the following line to the dependencies section in your Package.swift file:

.package(url: "https://github.com/mattboran/OpenWeatherAPI.git", from: "1.0.0")

Then add the package as a dependency for your target:

.target(
    name: "YourTarget",
    dependencies: [
        .product(name: "OpenWeatherAPI", package: "OpenWeatherAPI"),
    ]
)

Usage

To use the OpenWeatherAPI Swift package, first import the module, then create an instance of the Client class with your API key:

import OpenWeatherAPI

let apiKey = "your-api-key"
let client = Client(apiKey: apiKey)

You can then use the various methods provided by the Client class to query the OpenWeather One Call 3.0 API. For example, to get the current weather for a location, use the fetchWeather(latitude:longitude:completion:) method:

let latitude = 37.7749
let longitude = -122.4194

client.fetchWeather(latitude: latitude, longitude: longitude) { result in
    switch result {
    case .success(let weather):
        print("Current weather:", weather)
    case .failure(let error):
        print("Error getting current weather:", error)
    }
}

// For iOS 13+ and MacOS 10.15+, use the async version of the above method:
let result = try await client.fetchWeatherAsync(latitude: latitude, longitude: longitude)

See the full documentation for more information.

Contributing

If you find a bug or would like to contribute to this Swift package, please open an issue or submit a pull request on GitHub.

License

This Swift package is licensed under the Apache License, Version 2.0

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Sun Mar 05 2023 16:01:50 GMT-1000 (Hawaii-Aleutian Standard Time)