Skip to content

Commit

Permalink
Update to newly built Swift Client from GH Run 154
Browse files Browse the repository at this point in the history
  • Loading branch information
openapi-bot committed Sep 12, 2022
1 parent b93366f commit 320aae9
Show file tree
Hide file tree
Showing 39 changed files with 647 additions and 668 deletions.
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

## Working with Xcode

The Swift Package can be opened directly in Xcode: Double click the package description file and Xcode will open the package.
The Swift Package can be opened directly in Xcode. As an alternative, the Package can be also converted into a Xcode project. Open the CumulocityCoreLibrary root directory in your terminal and run the following command:

To include the Swift Package in your project use the Swift Package Manager. Just simply add this package to your Xcode project using:
```groovy
swift package generate-xcodeproj
```

or run the shell script located in the root directory:

`Xcode` > `File` > `Swift Packages` > `Add Package Dependency` > `Select your project` > `enter the URL of this repository and choose a branch`
```console
sh xcodeproj.sh
```
## Usage

Use the public factory to access `API` classes. The factory is available as a singleton and groups `API` classes by category.
Expand Down Expand Up @@ -100,10 +106,9 @@ Error handling can be simplified by calling one of the following extension metho
```swift
sink(receiveCompletion: { completion in
/// access the error message
let error = completion.error()
/// error?.response(): HTTPURLResponse for advanced error processing
/// error?.statusCode(): HTTP status code
/// error?.reason(): Codable reason sent by the server
let error = try? completion.error()
/// error?.statusCode = HTTP status code
/// error?.reason = Codable reason sent by the server
})
```

Expand All @@ -118,15 +123,3 @@ builder.add(header: "Authorization", value: "")
// or pass userName and password explicitly
builder.set(authorization: "userName", password: "password")
```

## Contribution

If you've spotted something that doesn't work as you'd expect, or if you have a new feature you'd like to add, we're happy to accept contributions and bug reports.

For bug reports, please raise an issue directly in this repository by selecting the `issues` tab and then clicking the `new issue` button. Please ensure that your bug report is as detailed as possible and allows us to reproduce your issue easily.

In the case of new contributions, please create a new branch from the latest version of `main`. When your feature is complete and ready to evaluate, raise a new pull request.

---

These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
48 changes: 24 additions & 24 deletions Sources/CumulocityCoreLibrary/Api/AlarmsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -191,17 +191,17 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 403 else {
throw Errors.badResponseError(response: httpResponse, reason: "Not authorized to perform this operation.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Not authorized to perform this operation.")
}
guard httpResponse.statusCode != 422 else {
throw Errors.badResponseError(response: httpResponse, reason: "Unprocessable Entity – invalid payload.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Unprocessable Entity – invalid payload.")
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -270,17 +270,17 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 403 else {
throw Errors.badResponseError(response: httpResponse, reason: "Not authorized to perform this operation.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Not authorized to perform this operation.")
}
guard httpResponse.statusCode != 422 else {
throw Errors.badResponseError(response: httpResponse, reason: "Unprocessable Entity – invalid payload.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Unprocessable Entity – invalid payload.")
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -353,14 +353,14 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 403 else {
throw Errors.badResponseError(response: httpResponse, reason: "Not authorized to perform this operation.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Not authorized to perform this operation.")
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -399,19 +399,19 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 403 else {
throw Errors.badResponseError(response: httpResponse, reason: "Not authorized to perform this operation.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Not authorized to perform this operation.")
}
guard httpResponse.statusCode != 404 else {
let decoder = JSONDecoder()
let error404 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error404)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error404)
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -468,22 +468,22 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 403 else {
throw Errors.badResponseError(response: httpResponse, reason: "Not authorized to perform this operation.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Not authorized to perform this operation.")
}
guard httpResponse.statusCode != 404 else {
let decoder = JSONDecoder()
let error404 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error404)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error404)
}
guard httpResponse.statusCode != 422 else {
throw Errors.badResponseError(response: httpResponse, reason: "Unprocessable Entity – invalid payload.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Unprocessable Entity – invalid payload.")
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -545,11 +545,11 @@ public class AlarmsApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down
20 changes: 10 additions & 10 deletions Sources/CumulocityCoreLibrary/Api/ApplicationBinariesApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ public class ApplicationBinariesApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 404 else {
let decoder = JSONDecoder()
let error404 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error404)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error404)
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -103,11 +103,11 @@ public class ApplicationBinariesApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -145,11 +145,11 @@ public class ApplicationBinariesApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down Expand Up @@ -189,14 +189,14 @@ public class ApplicationBinariesApi: AdaptableApi {
guard httpResponse.statusCode != 401 else {
let decoder = JSONDecoder()
let error401 = try decoder.decode(C8yError.self, from: element.data)
throw Errors.badResponseError(response: httpResponse, reason: error401)
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: error401)
}
guard httpResponse.statusCode != 403 else {
throw Errors.badResponseError(response: httpResponse, reason: "Not authorized to perform this operation.")
throw Errors.badResponseError(statusCode: httpResponse.statusCode, reason: "Not authorized to perform this operation.")
}
// generic error fallback
guard (200..<300) ~= httpResponse.statusCode else {
throw Errors.undescribedError(response: httpResponse)
throw Errors.undescribedError(statusCode: httpResponse.statusCode, response: httpResponse)
}

return element.data
Expand Down
Loading

0 comments on commit 320aae9

Please sign in to comment.