Skip to content

Commit

Permalink
Release version 3.0.0-beta05
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed Mar 1, 2023
1 parent 1ac38f2 commit 9850809
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Documentation/sections/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Further documentation with information about how install and integrate it can be

## Requirements

- iOS 11+
- iOS 12+
- Xcode 12+

## Author
Expand Down
4 changes: 2 additions & 2 deletions Documentation/source/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Once you have your Swift package set up, adding `GiniBankAPILibrary` as a depend

```swift
dependencies: [
.package(url: "https://github.com/gini/bank-api-library-ios.git", .exact("1.5.0"))
.package(url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.0.0-beta05"))
]
```

In case that you want to use the certificate pinning in the library, add `GiniBankAPILibraryPinning`:
```swift
dependencies: [
.package(url: "https://github.com/gini/bank-api-library-pinning-ios.git", .exact("1.5.0"))
.package(url: "https://github.com/gini/bank-api-library-pinning-ios.git", .exact("3.0.0-beta05"))
]
```

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "GiniBankAPILibrary",
platforms: [.iOS(.v11)],
platforms: [.iOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Further documentation with information about how install and integrate it can be

## Requirements

- iOS 11+
- iOS 12+
- Xcode 12+

## Author
Expand Down
29 changes: 23 additions & 6 deletions Sources/GiniBankAPILibrary/Documents/Core/GiniError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,37 @@

import Foundation

/**
Protocol representing errors that can occur while interacting with the Gini API.

The protocol defines three properties:
- message: A message describing the error.
- response: The HTTPURLResponse received in the error, if any.
- data: The data received in the error, if any.
*/

public protocol GiniErrorProtocol {
var message: String { get }
var response: HTTPURLResponse? { get }
var data: Data? { get }
}

/**
Enum representing different types of errors that can occur while interacting with the Gini API.

- badRequest: Error indicating that the request was invalid.
- notAcceptable: Error indicating that the request was not acceptable.
- notFound: Error indicating that the requested resource was not found.
- noResponse: Error indicating that no response was received.
- parseError: Error indicating that there was an error parsing the response.
- requestCancelled: Error indicating that the request was cancelled.
- tooManyRequests: Error indicating that too many requests have been made.
- unauthorized: Error indicating that the request was unauthorized.
- unknown: An unknown error occurred.
*/

public enum GiniError: Error, GiniErrorProtocol, Equatable {
case badRequest(response: HTTPURLResponse? = nil, data: Data? = nil)
case invalidCredentials
case keychainError
case notAcceptable(response: HTTPURLResponse? = nil, data: Data? = nil)
case notFound(response: HTTPURLResponse? = nil, data: Data? = nil)
case noResponse
Expand All @@ -30,10 +51,6 @@ public enum GiniError: Error, GiniErrorProtocol, Equatable {
switch self {
case .badRequest:
return "Bad request"
case .invalidCredentials:
return "Invalid credentials"
case .keychainError:
return "Keychain error"
case .notAcceptable:
return "Not acceptable"
case .notFound:
Expand Down
12 changes: 2 additions & 10 deletions Sources/GiniBankAPILibrary/Documents/ExtractionResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ import Foundation
// Return reasons from which users can pick one when deselecting line items.
public var returnReasons: [ReturnReason]?

/// The extraction candidates.
public let candidates: [String: [Extraction.Candidate]]

public init(extractions: [Extraction],
lineItems: [[Extraction]]?,
returnReasons: [ReturnReason]?,
candidates: [String: [Extraction.Candidate]]) {
public init(extractions: [Extraction], lineItems: [[Extraction]]?, returnReasons: [ReturnReason]?) {
self.extractions = extractions
self.lineItems = lineItems
self.returnReasons = returnReasons
self.candidates = candidates

super.init()
}
Expand All @@ -40,7 +33,6 @@ import Foundation

self.init(extractions: extractionsContainer.extractions,
lineItems: extractionsContainer.compoundExtractions?["lineItems"],
returnReasons: extractionsContainer.returnReasons,
candidates: extractionsContainer.candidates)
returnReasons: extractionsContainer.returnReasons)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
struct ExtractionsContainer {
let extractions: [Extraction]
let compoundExtractions: [String : [[Extraction]]]?
let candidates: [String: [Extraction.Candidate]]
let candidates: [Extraction.Candidate]
let returnReasons: [ReturnReason]?

enum CodingKeys: String, CodingKey {
Expand All @@ -32,10 +32,8 @@ extension ExtractionsContainer: Decodable {
forKey: .extractions)
let decodedCompoundExtractions = try container.decodeIfPresent([String : [[String : Extraction]]].self,
forKey: .compoundExtractions)

self.candidates = try container.decodeIfPresent([String: [Extraction.Candidate]].self,
let decodedCandidates = try container.decodeIfPresent([String : [Extraction.Candidate]].self,
forKey: .candidates) ?? [:]


extractions = decodedExtractions.map { (key, value) in
let extraction = value
Expand All @@ -56,6 +54,8 @@ extension ExtractionsContainer: Decodable {
}
}

candidates = decodedCandidates.flatMap { $0.value }

returnReasons = try container.decodeIfPresent([ReturnReason].self, forKey: .returnReasons)
}
}
2 changes: 1 addition & 1 deletion Sources/GiniBankAPILibrary/GiniBankAPILibraryVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Created by Nadya Karaban on 28.10.21.
//

public let GiniBankAPILibraryVersion = "1.5.0"
public let GiniBankAPILibraryVersion = "3.0.0-beta05"
2 changes: 1 addition & 1 deletion Tests/GiniBankAPILibraryTests/DocumentServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ final class DocumentServicesTests: XCTestCase {
osName: UIDevice.current.systemName,
osVersion: UIDevice.current.systemVersion,
captureSdkVersion: "Not available",
apiLibVersion: "1.5.0",
apiLibVersion: "3.0.0-beta05",
description: "Error logging test",
documentId: "1234",
originalRequestId: "5678")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class ExtractionsContainerTest: XCTestCase {
value: "123.93:EUR")

XCTAssertEqual(container.candidates.count, 2)
XCTAssertEqual(container.candidates["amounts"]!.first, candidate)
XCTAssertTrue(container.candidates.contains(candidate))

let returnReason = ReturnReason(id: "r1", localizedLabels: ["de" : "Anderes Aussehen als angeboten"])

Expand Down

0 comments on commit 9850809

Please sign in to comment.