Skip to content

Commit

Permalink
Release version 3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed Nov 8, 2023
1 parent 01c7f93 commit 384ea40
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Documentation/source/Getting started.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ documentService
}
```

### Sending feedback
### Sending transfer summary

Depending on your use case your app probably presents the extractions to the user and gives them the opportunity to correct them. By sending us feedback for the extractions we are able to continuously improve the extraction quality.
Depending on your use case your app probably presents the extractions to the user and gives them the opportunity to correct them. By sending us transfer summary for the extractions we are able to continuously improve the extraction quality.

We provide a sample test case [here](https://github.com/gini/gini-mobile-ios/blob/main/BankAPILibrary/GiniBankAPILibraryExample/GiniBankAPILibraryExampleTests/ExtractionFeedbackIntegrationTest.swift) to verify that extraction feedback sending works. You may use it along with the example pdf and json files as a starting point to write your own test case.
We provide a sample test case [here](https://github.com/gini/gini-mobile-ios/blob/main/BankAPILibrary/GiniBankAPILibraryExample/GiniBankAPILibraryExampleTests/TransferSummaryIntegrationTest.swift) to verify that extraction transfer summary sending works. You may use it along with the example pdf and json files as a starting point to write your own test case.

The sample test case is based on the Bank API documentation's [recommended steps](https://pay-api.gini.net/documentation/#test-example) for testing extraction feedback sending.

Your app should send feedback only for the extractions the user has seen and accepted. Feedback should be sent for corrected extractions and for correct extractions. The code example below shows how to correct extractions and send feedback.
Your app should send transfer summary only for the extractions the user has seen and accepted. Transfer summary should be sent for corrected extractions and for correct extractions. The code example below shows how to correct extractions and send transfer summary.

```swift
guard let document = document else { return }
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("3.1.1"))
.package(url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.1.2"))
]
```

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("3.1.1"))
.package(url: "https://github.com/gini/bank-api-library-pinning-ios.git", .exact("3.1.2"))
]
```

Expand Down
4 changes: 2 additions & 2 deletions Sources/GiniBankAPILibrary/Documents/Core/Auth/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ extension Token: Decodable {
let container = try decoder.container(keyedBy: Keys.self)
let expiresIn = try container.decode(Double.self, forKey: .expiresIn) // seconds
let expiration = Date(timeInterval: expiresIn, since: Date())
let scope = try container.decode(String.self, forKey: .scope)
let type = try container.decode(String.self, forKey: .type)
let scope = try container.decodeIfPresent(String.self, forKey: .scope)
let type = try container.decodeIfPresent(String.self, forKey: .type)
let accessToken = try container.decode(String.self, forKey: .accessToken)

self.init(expiration: expiration,
Expand Down
6 changes: 0 additions & 6 deletions Sources/GiniBankAPILibrary/Documents/Extraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ import Foundation

}

// MARK: - Decodable

//extension Extraction: Decodable {}
//extension Extraction.Box: Decodable {}
//extension Extraction.Candidate: Decodable {}

// MARK: - isEqual

extension Extraction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension PartialDocumentInfo: Codable {

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
document = try container.decode(URL.self, forKey: .document)
document = try container.decodeIfPresent(URL.self, forKey: .document)
rotationDelta = try container.decodeIfPresent(Int.self, forKey: .rotationDelta) ?? 0
}
}
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 = "3.1.1"
public let GiniBankAPILibraryVersion = "3.1.2"
119 changes: 108 additions & 11 deletions Tests/GiniBankAPILibraryTests/AccessTokenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,123 @@ import XCTest
@testable import GiniBankAPILibrary

final class AccessTokenTests: XCTestCase {

let token = try? JSONDecoder().decode(Token.self,
from: ("{\"access_token\":\"1eb7ca49-d99f-40cb-b86d-8dd689ca2345\"," +
"\"token_type\":\"bearer\",\"expires_in\":43199,\"scope\":\"read\"}").data(using: .utf8)!)

func testValue() {
XCTAssertEqual(token?.accessToken, "1eb7ca49-d99f-40cb-b86d-8dd689ca2345")
func testAccessToken() {
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"expires_in": 43199,
"scope": "read"
}
"""
XCTAssertNotNil(token(from: jsonReponse)?.accessToken, "Expected a `accessToken`, but found nil.")
XCTAssertEqual(token(from: jsonReponse)?.accessToken, "1eb7ca49-d99f-40cb-b86d-8dd689ca2345")
}

func testType() {
XCTAssertEqual(token?.type, "bearer")
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"expires_in": 43199,
"scope": "read"
}
"""
XCTAssertEqual(token(from: jsonReponse)?.type, "bearer")
}

func testTypeOptionl() {
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"expires_in": 43199,
"scope": "read"
}
"""
let type = token(from: jsonReponse)?.type
XCTAssertNil(type, "Expected nil, but found \(String(describing: type)).")
}


func testExpirationDate() {
XCTAssertTrue(token!.expiration < Date(timeInterval: 43199, since: Date()))
XCTAssertTrue(token!.expiration > Date())
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"expires_in": 43199,
"scope": "read"
}
"""
XCTAssertNotNil(token(from: jsonReponse)?.expiration, "Expected a `expires_in`, but found nil.")
XCTAssertTrue(token(from: jsonReponse)!.expiration < Date(timeInterval: 43199, since: Date()))
XCTAssertTrue(token(from: jsonReponse)!.expiration > Date())
}

func testScope() {
XCTAssertEqual(token?.scope, "read")
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"expires_in": 43199,
"scope": "read"
}
"""
XCTAssertEqual(token(from: jsonReponse)?.scope, "read")
}

func testScopeOptionl() {
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"expires_in": 43199
}
"""
let scope = token(from: jsonReponse)?.scope
XCTAssertNil(scope, "Expected nil, but found \(String(describing: scope)).")
}

func testTokenCorrectDecoding() {
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"expires_in": 43199,
"scope": "read"
}
"""
guard let token = token(from: jsonReponse) else {
XCTFail("Failed to decode Token response data")
fatalError()
}

XCTAssertNotNil(token, "Expected a `token`, but found nil.")
}

func testTokenMissingOptionalFieldsDecoding() {
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"expires_in": 43199
}
"""
guard let token = token(from: jsonReponse) else {
XCTFail("Failed to decode Token response data")
fatalError()
}

XCTAssertNotNil(token, "Expected a `token`, but found nil.")
}

func testTokenMissingRequiredFieldsDecoding() {
let jsonReponse = """
{"access_token": "1eb7ca49-d99f-40cb-b86d-8dd689ca2345",
"token_type": "bearer",
"scope": "read"
}
"""
guard let token = token(from: jsonReponse) else {
XCTAssertNil(token(from: jsonReponse),"Failed to decode Token response data")
return
}

XCTAssertNotNil(token, "Expected a `token`, but found nil.")
}

private func token(from mockRespose: String) -> Token? {
return try? JSONDecoder().decode(Token.self, from: (mockRespose).data(using: .utf8)!)
}

}
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: "3.1.1",
apiLibVersion: "3.1.2",
description: "Error logging test",
documentId: "1234",
originalRequestId: "5678")
Expand Down

0 comments on commit 384ea40

Please sign in to comment.