Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measurement #12

Merged
merged 7 commits into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
env:
API_KEY: ${{ secrets.API_KEY }}
- name: Codecov
uses: codecov/codecov-action@v1.0.15
uses: codecov/codecov-action@v2
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Test HPOpenWeather",
"program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest",
"args": [
".build/debug/HPOpenWeatherPackageTests.xctest"
],
"cwd": "${workspaceFolder:HPOpenWeather}",
"preLaunchTask": "swift: Build All"
}
]
}
18 changes: 9 additions & 9 deletions HPOpenWeather.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "HPOpenWeather"
s.version = "4.1.5"
s.version = "5.0.0"
s.summary = "Cross-platform framework to communicate with the OpenWeatherMap JSON API"

s.license = { :type => "MIT", :file => "LICENSE.md" }
Expand All @@ -10,23 +10,23 @@ Pod::Spec.new do |s|
s.author = { "henrik-dmg" => "henrik@panhans.dev" }
s.social_media_url = "https://twitter.com/henrik_dmg"

s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.11"
s.watchos.deployment_target = "3.0"
s.tvos.deployment_target = "9.0"
s.ios.deployment_target = "13.0"
s.watchos.deployment_target = "7.0"
s.tvos.deployment_target = "13.0"
s.osx.deployment_target = "10.15"

s.source = { :git => 'https://github.com/henrik-dmg/HPOpenWeather.git', :tag => s.version }

s.source_files = "Sources/**/*.swift"

s.framework = "Foundation"
s.ios.framework = "UIKit"
s.watchos.framework = "UIKit"
s.tvos.framework = "UIKit"
s.osx.framework = "AppKit"

s.swift_version = "5.1"
s.swift_version = "5.5"
s.requires_arc = true
s.dependency "HPNetwork"
s.dependency "HPNetwork", "~> 3.1.1"
s.dependency "HPURLBuilder", "~> 1.0.0"

end
13 changes: 11 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
"repositoryURL": "https://github.com/henrik-dmg/HPNetwork",
"state": {
"branch": null,
"revision": "7e888cdaabf7cb6e8c6640db57cb4325099f79b2",
"version": "2.0.2"
"revision": "2bdaaa3f1c9d52a30e5afb8f737c3b72f5afba0c",
"version": "3.1.1"
}
},
{
"package": "HPURLBuilder",
"repositoryURL": "https://github.com/henrik-dmg/HPURLBuilder",
"state": {
"branch": null,
"revision": "49ad1fb6f10914e7134dc9f8e5c21f48a52e3d37",
"version": "1.1.0"
}
}
]
Expand Down
9 changes: 5 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version:5.1
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "HPOpenWeather",
platforms: [
.iOS(.v9), .macOS(.v10_11), .tvOS(.v9), .watchOS(.v3)
.iOS(.v13), .tvOS(.v13), .watchOS(.v7), .macOS(.v10_15)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
Expand All @@ -17,14 +17,15 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/henrik-dmg/HPNetwork", from: "2.0.0")
.package(url: "https://github.com/henrik-dmg/HPNetwork", from: "3.0.0"),
.package(url: "https://github.com/henrik-dmg/HPURLBuilder", from: "1.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "HPOpenWeather",
dependencies: ["HPNetwork"]
dependencies: ["HPNetwork", "HPURLBuilder"]
),
.testTarget(
name: "HPOpenWeatherTests",
Expand Down
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<p align="center">
<img src="https://imgur.com/download/EQ5Zj06" alt="Storage" />
</p>
# HPOpenWeather

<a href="https://www.codefactor.io/repository/github/henrik-dmg/hpopenweather"><img src="https://www.codefactor.io/repository/github/henrik-dmg/hpopenweather/badge" alt="CodeFactor" /></a>
<a href="https://img.shields.io/badge/Swift-5.0-orange"><img src="https://img.shields.io/badge/Swift-5.0-orange.svg"/></a>
<a href="https://github.com/henrik-dmg/HPOpenWeather/blob/master/.github/workflows/swift.yml"><img src="https://github.com/henrik-dmg/HPOpenWeather/workflows/Swift/badge.svg" alt="Github Actions"/></a>
[![GitHub license](https://img.shields.io/github/license/henrik-dmg/HPOpenWeather)](https://github.com/henrik-dmg/HPOpenWeather/blob/master/LICENSE.md)

HPOpenWeather is a cross-platform Swift framework to communicate with the OpenWeather One-Call API. See their [documentation](https://openweathermap.org/api/one-call-api) for further details.

## Installation

HPOpenWeather supports iOS 9.0+, watchOS 3.0+, tvOS 9.0+ and macOS 10.10+.
HPOpenWeather supports iOS 13.0+, watchOS 7.0+, tvOS 13.0+ and macOS 10.15+.

#### SPM
### SPM

Add `.package(url: "https://github.com/henrik-dmg/HPOpenWeather", from: "4.0.0")` to your `Package.swift` file
Add `.package(url: "https://github.com/henrik-dmg/HPOpenWeather", from: "5.0.0")` to your `Package.swift` file

#### CocoaPods
### CocoaPods

Add `pod 'HPOpenWeather'` to your `Podfile` and run `pod install`

## Usage

To get started, you need an API key from [OpenWeather](https://openweathermap.org). Put this API key in the initialiser, additionally you can also specify a custom temperature format and/or language used in the responses (see list for available languages and units below).

```swift
import HPOpenWeather

Expand All @@ -35,9 +35,10 @@ OpenWeather.shared.units = .metric
let settings = OpenWeather.Settings(apiKey: "yourAPIKey", language: .german, units: .metric)
OpenWeather.shared.apply(settings)
```

You can also customise the response data units and language by accessing the `language` and `units` propertis.

## Making a request
### Making a request

To make a request, initialize a new request object like this

Expand All @@ -53,22 +54,26 @@ let timemachineRequest = WeatherRequest(coordinate: .init(latitude: 40, longitud

**Note:** the date has to be at least 6 hours in the past

To post a request, call `sendWeatherRequest` on `OpenWeather`:
To post a request, call `sendWeatherRequest` on `OpenWeather`:

```swift
OpenWeather.shared.performWeatherRequest(request) { result in
// Classic completion handler approach
OpenWeather.shared.schedule(request) { result in
switch result {
case .success(let response):
// do something with weather data here
case .failure(let error):
// handle error
}
}

// Or using the new concurrency features
let response = try await OpenWeather.shared.weatherResponse(request)
```

**The following response languages are available**
### Available languages (default in bold)

- English (default)
- **English**
- Russian
- Italian
- Spanish
Expand All @@ -88,8 +93,8 @@ OpenWeather.shared.performWeatherRequest(request) { result in
- Croatian
- Catalan

**The following temperature units are available**
### Available units (default in bold)

- Celsius (default)
- Kelvin
- Fahrenheit
- **Metric** (wind speed in m/s, temperature in Celsius)
- Imperial (wind speed in mph, temperature in Fahrenheit)
- Standard (wind speed in m/s, temperature in Kelvin)
25 changes: 0 additions & 25 deletions Sources/HPOpenWeather/DataTypes/Alert.swift

This file was deleted.

75 changes: 0 additions & 75 deletions Sources/HPOpenWeather/DataTypes/Forecasts/CurrentWeather.swift

This file was deleted.

70 changes: 0 additions & 70 deletions Sources/HPOpenWeather/DataTypes/Forecasts/DailyForecast.swift

This file was deleted.

Loading