This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Gets details of withdrawal with the given ID - Get a list of withdrawals
- Loading branch information
1 parent
91ee53e
commit d13e62b
Showing
4 changed files
with
217 additions
and
2 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
73 changes: 73 additions & 0 deletions
73
Tests/ImmutableXCoreTests/Mocks/API/WithdrawalsAPIMock.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,73 @@ | ||
import Foundation | ||
@testable import ImmutableXCore | ||
|
||
final class WithdrawalsAPIMock: WithdrawalsAPI { | ||
class GetWithdrawalCompanion { | ||
var throwableError: Error? | ||
var callsCount = 0 | ||
var returnValue: Withdrawal! | ||
} | ||
|
||
class ListWithdrawalsCompanion { | ||
var throwableError: Error? | ||
var callsCount = 0 | ||
var returnValue: ListWithdrawalsResponse! | ||
} | ||
|
||
static var getWithdrawalCompanion: GetWithdrawalCompanion? | ||
static var listWithdrawalsCompanion: ListWithdrawalsCompanion? | ||
|
||
static func mock(_ companion: GetWithdrawalCompanion) { | ||
getWithdrawalCompanion = companion | ||
} | ||
|
||
static func mock(_ companion: ListWithdrawalsCompanion) { | ||
listWithdrawalsCompanion = companion | ||
} | ||
|
||
static func resetMock() { | ||
getWithdrawalCompanion = nil | ||
listWithdrawalsCompanion = nil | ||
} | ||
|
||
override class func getWithdrawal(id: String) async throws -> Withdrawal { | ||
let companion = getWithdrawalCompanion! | ||
companion.callsCount += 1 | ||
|
||
if let error = companion.throwableError { | ||
throw error | ||
} | ||
|
||
return companion.returnValue | ||
} | ||
|
||
override class func listWithdrawals( | ||
withdrawnToWallet: Bool? = nil, | ||
rollupStatus: String? = nil, | ||
pageSize: Int? = nil, | ||
cursor: String? = nil, | ||
orderBy: String? = nil, | ||
direction: String? = nil, | ||
user: String? = nil, | ||
status: String? = nil, | ||
minTimestamp: String? = nil, | ||
maxTimestamp: String? = nil, | ||
tokenType: String? = nil, | ||
tokenId: String? = nil, | ||
assetId: String? = nil, | ||
tokenAddress: String? = nil, | ||
tokenName: String? = nil, | ||
minQuantity: String? = nil, | ||
maxQuantity: String? = nil, | ||
metadata: String? = nil | ||
) async throws -> ListWithdrawalsResponse { | ||
let companion = listWithdrawalsCompanion! | ||
companion.callsCount += 1 | ||
|
||
if let error = companion.throwableError { | ||
throw error | ||
} | ||
|
||
return companion.returnValue | ||
} | ||
} |
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