Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Update the recipient property on Transfer to be DetailProperty (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
pitiphong-p authored Jun 18, 2019
1 parent 99aca35 commit 3e03a82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions OmiseSwift/Transfer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct Transfer: OmiseResourceObject, Equatable {

public let currency: Currency

public let recipientID: String
public let recipient: DetailProperty<Recipient>
public let transactions: [Transaction<Transfer>]

public let metadata: JSONDictionary
Expand All @@ -75,7 +75,7 @@ public struct Transfer: OmiseResourceObject, Equatable {
case net
case totalFee = "total_fee"
case currency
case recipientID = "recipient"
case recipient
case transactions
case failureCode = "failure_code"
case failureMessage = "failure_message"
Expand Down Expand Up @@ -110,7 +110,7 @@ public struct Transfer: OmiseResourceObject, Equatable {
feeVat = try container.decode(Int64.self, forKey: .feeVat)
net = try container.decode(Int64.self, forKey: .net)
totalFee = try container.decode(Int64.self, forKey: .totalFee)
recipientID = try container.decode(String.self, forKey: .recipientID)
recipient = try container.decode(DetailProperty<Recipient>.self, forKey: .recipient)
transactions = try container.decode(Array<Transaction<Transfer>>.self, forKey: .transactions)

let failureCode = try container.decodeIfPresent(TransferFailure.Code.self, forKey: .failureCode)
Expand Down Expand Up @@ -154,7 +154,7 @@ public struct Transfer: OmiseResourceObject, Equatable {
try container.encode(totalFee, forKey: .totalFee)
try container.encode(currency, forKey: .currency)

try container.encode(recipientID, forKey: .recipientID)
try container.encode(recipient, forKey: .recipient)
try container.encode(transactions, forKey: .transactions)
try container.encode(metadata, forKey: .metadata)

Expand Down
1 change: 1 addition & 0 deletions OmiseSwiftTests/TransferOperationFixtureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TransferOperationFixtureTests: FixtureTestCase {
XCTAssertEqual(transfer.sentDate, dateFormatter.date(from: "2019-05-22T06:47:57Z"))
XCTAssertEqual(transfer.paidDate, dateFormatter.date(from: "2019-05-22T06:47:59Z"))
XCTAssertFalse(transfer.shouldFailFast)
XCTAssertEqual(transfer.recipient.dataID, "recp_test_5fofl6ivu23gypjeqt8")
case let .failure(error):
XCTFail("\(error)")
}
Expand Down

0 comments on commit 3e03a82

Please sign in to comment.