Skip to content

Commit 3f5c6eb

Browse files
authored
Merge pull request #3 from adborbas/adborbas/no_throws
Remove throws from API
2 parents 7724ef4 + e76e15b commit 3f5c6eb

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Sources/AlphaSwiftage/Public/AlphaVantageService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ public class AlphaVantageService {
1414
self.session = session
1515
}
1616

17-
public func quote(for symbol: String) async throws -> Result<Quote, AlphaVantageError> {
17+
public func quote(for symbol: String) async -> Result<Quote, AlphaVantageError> {
1818
let request = AlphaVantageAPI.globalQuote(symbol: symbol, apiKey: apiKey)
1919

2020
return await session.request(request)
2121
.serializingAlphaVantageWrappedResponse(QuoteResponse.self) { $0.quote }
2222
}
2323

24-
public func currencyExchangeRate(from base: String, to target: String) async throws -> Result<CurrencyExchangeRate, AlphaVantageError> {
24+
public func currencyExchangeRate(from base: String, to target: String) async -> Result<CurrencyExchangeRate, AlphaVantageError> {
2525
let request = AlphaVantageAPI.currencyExchangeRate(from: base, to: target, apiKey: apiKey)
2626

2727
return await session.request(request)
2828
.serializingAlphaVantageWrappedResponse(CurrencyExchangeRateResponse.self) { $0.exchangeRate }
2929
}
3030

31-
public func symbolSearch(keywords: String) async throws -> Result<[Symbol], AlphaVantageError> {
31+
public func symbolSearch(keywords: String) async -> Result<[Symbol], AlphaVantageError> {
3232
let request = AlphaVantageAPI.symbolSearch(keywords: keywords, apiKey: apiKey)
3333
return await session.request(request)
3434
.serializingAlphaVantageWrappedResponse(SearchSymbolResponse.self) { $0.matches }

Tests/AlphaVantageServiceTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Mocker
77
final class AlphaVantageServiceTests: XCTestCase {
88
private let apiKey = "whatever"
99

10-
func testQuote() async throws {
10+
func testQuote() async {
1111
// Given
1212
let service = givenService()
1313
let symbol = "VWCE.DEX"
@@ -24,13 +24,13 @@ final class AlphaVantageServiceTests: XCTestCase {
2424
given(response: .quote, for: "https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=\(symbol)&apikey=\(apiKey)")
2525

2626
// When
27-
let result = try await service.quote(for: symbol)
27+
let result = await service.quote(for: symbol)
2828

2929
// Then
3030
assertSuccess(result, expectedValue: expectedQuote)
3131
}
3232

33-
func testCurrencyExchangeRate() async throws {
33+
func testCurrencyExchangeRate() async {
3434
// Given
3535
let service = givenService()
3636
let base = "EUR"
@@ -47,13 +47,13 @@ final class AlphaVantageServiceTests: XCTestCase {
4747
given(response: .currencyExchangeRate, for: "https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=\(base)&to_currency=\(target)&apikey=\(apiKey)")
4848

4949
// When
50-
let result = try await service.currencyExchangeRate(from: base, to: target)
50+
let result = await service.currencyExchangeRate(from: base, to: target)
5151

5252
// Then
5353
assertSuccess(result, expectedValue: expectedRate)
5454
}
5555

56-
func testSymbolSearchSuccess() async throws {
56+
func testSymbolSearchSuccess() async {
5757
// Given
5858
let keyword = "vwce"
5959
let expectedSymbol = Symbol(symbol: "VWCE.DEX",
@@ -69,21 +69,21 @@ final class AlphaVantageServiceTests: XCTestCase {
6969
given(response: .symbolSearchSuccess, for: "https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords=\(keyword)&apikey=\(apiKey)")
7070

7171
// When
72-
let result = try await service.symbolSearch(keywords: keyword)
72+
let result = await service.symbolSearch(keywords: keyword)
7373

7474
// Then
7575
assertSuccess(result, expectedValue: [expectedSymbol])
7676
}
7777

78-
func testSymbolSearchFailure() async throws {
78+
func testSymbolSearchFailure() async {
7979
// Given
8080
let expectedError = AlphaVantageAPIError(message: "Invalid API call.")
8181
let keyword = "whatever"
8282
let service = givenService()
8383
given(response: .symbolSearchFailure, for: "https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords=\(keyword)&apikey=\(apiKey)")
8484

8585
// When
86-
let result = try await service.symbolSearch(keywords: keyword)
86+
let result = await service.symbolSearch(keywords: keyword)
8787

8888
// Then
8989
switch result {

0 commit comments

Comments
 (0)