twigs-ios/Twigs/Transaction/TransactionRepository.swift

52 lines
1.6 KiB
Swift
Raw Permalink Normal View History

//
// TransactionRepository.swift
// Budget
//
// Created by Billy Brawner on 9/25/19.
// Copyright © 2019 William Brawner. All rights reserved.
//
import Foundation
import Combine
2022-01-03 17:56:43 +00:00
import TwigsCore
#if DEBUG
2022-01-03 17:56:43 +00:00
class MockTransactionRepository: TransactionRepository {
static let transaction: Transaction = Transaction(
2021-09-10 04:47:57 +00:00
id: "2",
title: "Test Transaction",
description: "A mock transaction used for testing",
date: Date(),
amount: 10000,
2021-09-10 04:47:57 +00:00
categoryId: MockCategoryRepository.category.id,
expense: true,
createdBy: MockUserRepository.currentUser.id,
2021-09-10 04:47:57 +00:00
budgetId: MockBudgetRepository.budget.id
)
2022-01-03 17:56:43 +00:00
func getTransactions(budgetIds: [String], categoryIds: [String]?, from: Date?, to: Date?, count: Int?, page: Int?) async throws -> [Transaction] {
return [MockTransactionRepository.transaction]
}
2022-01-03 17:56:43 +00:00
func getTransaction(_ transactionId: String) async throws -> Transaction {
return MockTransactionRepository.transaction
}
2022-01-03 17:56:43 +00:00
func createTransaction(_ transaction: Transaction) async throws -> Transaction {
return MockTransactionRepository.transaction
}
2022-01-03 17:56:43 +00:00
func updateTransaction(_ transaction: Transaction) async throws -> Transaction {
return MockTransactionRepository.transaction
}
2022-01-03 17:56:43 +00:00
func deleteTransaction(_ transactionId: String) async throws {
// Do nothing
}
2021-09-21 01:59:13 +00:00
2022-01-03 17:56:43 +00:00
func sumTransactions(budgetId: String?, categoryId: String?, from: Date?, to: Date?) async throws -> BalanceResponse {
return BalanceResponse(balance: 1000)
2021-09-21 01:59:13 +00:00
}
}
#endif