Skip to content

Commit

Permalink
Release version 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed May 31, 2023
1 parent 6b7a512 commit 656a229
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 31 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
25 changes: 18 additions & 7 deletions Documentation/source/Getting started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,25 @@ If you want to use a transparent proxy with your own authentication you can spec

```swift
let apiLib = GiniBankAPI.Builder(customApiDomain: "api.custom.net",
alternativeTokenSource: MyAlternativeTokenSource)
alternativeTokenSource: MyAlternativeTokenSource)
.build()
```
The token your provide will be added as a bearer token to all api.custom.net requests.
The token you provide will be added as a bearer token to all `api.custom.net` requests.

You can also specify a custom path segment, if your proxy url requires it:

```swift
let giniBankAPI = GiniBankAPI
.Builder(client: client,
api: .custom(domain: "api.custom.net",
path: "/custom/path",
tokenSource: MyAlternativeTokenSource))
.build()
```

## Public Key Pinning

If you want to use _Certificate pinning_, provide metadata for the upload process, you can pass both your public key pinning configuration (see [TrustKit repo](https://github.com/datatheorem/TrustKit) for more information), the metadata information (the [Gini Bank API](https://developer.gini.net/gini-api/html/index.html) is used by default) as follows:
If you want to use _Certificate pinning_, then pass your public key pinning configuration (see [TrustKit repo](https://github.com/datatheorem/TrustKit) for more information) as follows:

```swift
let yourPublicPinningConfig = [
Expand Down Expand Up @@ -66,14 +77,12 @@ For customizing an API domain please, use the following snippet:
.Builder(client: Client(id: "your-id",
secret: "your-secret",
domain: "your-domain"),
api: .custom(domain: "custom-api.net"),
api: .custom(domain: "custom-api.net",
path:"/custom/path"),
pinningConfig: yourPublicPinningConfig)
.build()
```

> ⚠️ **Important**
> - The document metadata for the upload process is intended to be used for reporting.
## Extract Hash From gini.net

The current Gini Bank API public key SHA256 hash digest in Base64 encoding can be extracted with the following openssl commands:
Expand Down Expand Up @@ -126,6 +135,8 @@ documentService.createDocument(fileName: "myFirstDocument.jpg",
}
}
```
> ⚠️ **Important**
> - The document metadata for the upload process is intended to be used for reporting. You can find out more about it in the [Gini Bank API](https://pay-api.gini.net/documentation) documentation.
Each page of a document needs to uploaded as a partial document. In addition documents consisting of one page also should be uploaded as a partial document.

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

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

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
7 changes: 3 additions & 4 deletions Sources/GiniBankAPILibrary/Documents/APIResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public enum APIDomain {
case custom(domain: String, path: String? = nil, tokenSource: AlternativeTokenSource?)

var domainString: String {

switch self {
case .default: return "pay-api.gini.net"
case .gym: return "gym.gini.net"
Expand All @@ -26,9 +25,8 @@ public enum APIDomain {

var path: String {
switch self {
case .default: return ""
case .gym: return ""
case .custom(_, let path, _): return path ?? ""
default: return ""
}
}
}
Expand Down Expand Up @@ -72,7 +70,8 @@ struct APIResource<T: Decodable>: Resource {
URLQueryItem(name: "doctype", itemValue: docType?.rawValue)
]
case .paymentRequests(let limit, let offset):
return [URLQueryItem(name: "offset", itemValue: offset),URLQueryItem(name: "limit", itemValue: limit)]
return [URLQueryItem(name: "offset", itemValue: offset),
URLQueryItem(name: "limit", itemValue: limit)]
default: return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public enum UserDomain {
case custom(domain: String, path: String? = nil)

var domainString: String {

switch self {
case .default: return "user.gini.net"
case .custom(let domain, _): return domain
Expand All @@ -23,8 +22,8 @@ public enum UserDomain {

var path: String {
switch self {
case .default: return ""
case .custom(_, let path): return path ?? ""
default: return ""
}
}
}
Expand All @@ -46,8 +45,8 @@ struct UserResource<T: Decodable>: Resource {
var path: String {
return "\(domain.path)\(methodPath)"
}
private var methodPath: String {

var methodPath: String {
switch method {
case .token:
return "/oauth/token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ extension GiniBankAPI {
case .custom(_, _, let tokenSource):
var sessionManager : SessionManager
if let tokenSource = tokenSource {
sessionManager = SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate)
sessionManager = SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate)
} else {
sessionManager = SessionManager(userDomain: userApi, sessionDelegate: self.sessionDelegate)
}
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
27 changes: 27 additions & 0 deletions Sources/GiniBankAPILibrary/Documents/Payments/Payment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,33 @@ import Foundation
Struct for payment response
*/
public struct Payment {
/**
An initializer for a `Payment` structure

- parameter paidAt: ISO 8601 date string defining point in time when the payment request was resolved.
- parameter recipient: the recipient of the payment.
- parameter iban: the iban (international bank account number) of the payment recipient.
- parameter bic: the bic (bank identifier code) for the payment.
- parameter purpose: the purpose of the payment, e.g. the invoice or customer identifier.
- parameter links: object with links to other resources e.g. document and paymentRequest.
*/

public init(paidAt: String,
recipient: String,
iban: String,
bic: String? = nil,
amount: String,
purpose: String,
links: PaymentLinks? = nil) {
self.paidAt = paidAt
self.recipient = recipient
self.iban = iban
self.bic = bic
self.amount = amount
self.purpose = purpose
self.links = links
}

public var paidAt, recipient, iban: String
public var bic: String?
public var amount, purpose: String
Expand Down
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.6.0"
public let GiniBankAPILibraryVersion = "3.1.0"
1 change: 0 additions & 1 deletion Tests/GiniBankAPILibraryTests/APIResourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,4 @@ final class APIResourceTests: XCTestCase {
let urlString = resource.url.absoluteString
XCTAssertEqual(urlString, "https://custom.domain.com/custom/path/documents/", "path should match")
}

}
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.6.0",
apiLibVersion: "3.1.0",
description: "Error logging test",
documentId: "1234",
originalRequestId: "5678")
Expand Down
1 change: 0 additions & 1 deletion Tests/GiniBankAPILibraryTests/UserResourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ class UserResourceTests: XCTestCase {
let urlString = resource.url.absoluteString
XCTAssertEqual(urlString, "https://custom.domain.com/custom/path/api/users")
}

}

0 comments on commit 656a229

Please sign in to comment.