-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Team Mobile Schorsch
committed
Jun 14, 2024
1 parent
afa94da
commit f5a7ceb
Showing
31 changed files
with
680 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
Sources/GiniHealthAPILibrary/Documents/Payments/Payment.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// | ||
// Payment.swift | ||
// | ||
// Copyright © 2024 Gini GmbH. All rights reserved. | ||
// | ||
|
||
|
||
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 | ||
var links: PaymentLinks? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case paidAt, recipient, iban, bic, amount, purpose | ||
case links = "_links" | ||
} | ||
|
||
} | ||
|
||
/** | ||
Struct for links in payment response | ||
*/ | ||
public struct PaymentLinks: Codable { | ||
var paymentRequest, sourceDocumentLocation, linksSelf: String? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case paymentRequest, sourceDocumentLocation | ||
case linksSelf = "self" | ||
} | ||
} | ||
|
||
// MARK: - Decodable | ||
|
||
extension Payment: Decodable { | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.paidAt = try container.decode(String.self, forKey: .paidAt) | ||
self.recipient = try container.decode(String.self, forKey: .recipient) | ||
self.iban = try container.decode(String.self, forKey: .iban) | ||
|
||
if container.contains(.bic) { | ||
self.bic = try container.decodeIfPresent(String.self, forKey: .bic) | ||
} else { | ||
self.bic = nil | ||
} | ||
|
||
self.amount = try container.decode(String.self, forKey: .amount) | ||
self.purpose = try container.decode(String.self, forKey: .purpose) | ||
self.links = try container.decode(PaymentLinks.self, forKey: .links) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.