Skip to content

Commit 00b82da

Browse files
committed
minor restructure and adjustments
- moved xivapi specific files to /xivapi/ - adjusted /sheet - adjusted /version
1 parent f724896 commit 00b82da

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

Sources/xivapi-swift/xivapi-swift.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public extension xivapiClient {
3838
return response?.rows
3939
}
4040

41-
struct MultiRows<T: Codable>: Codable {
42-
let schema: String
43-
let rows: [T]
44-
}
45-
4641
/// get the recipe(s) for an item from the local dictionary
4742
/// - Parameter itemId: itemId
4843
/// - Returns: the RecipeID(s) for the provided Item
@@ -70,14 +65,17 @@ public extension xivapiClient {
7065
return response
7166
}
7267

73-
func listVersions() async -> [String]? {
68+
func listVersions() async -> [String]? { await listVersionsFull()?.versionNames }
69+
func listSheets() async -> [String]? { await listSheetsFull()?.sheetNames }
70+
71+
func listVersionsFull() async -> VersionResponse? {
7472
let url = URLComponents(string: "\(baseUrl)/version")!.url!
75-
return await loadData(url) as [String]?
73+
return await loadData(url) as VersionResponse?
7674
}
7775

78-
func listSheets() async -> [String]? {
76+
func listSheetsFull() async -> SheetResponse? {
7977
let url = URLComponents(string: "\(baseUrl)/sheet")!.url!
80-
return await loadData(url) as [String]?
78+
return await loadData(url) as SheetResponse?
8179
}
8280
}
8381

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Foundation
2+
3+
struct MultiRows<T: Codable>: Codable {
4+
let schema: String
5+
let rows: [T]
6+
}
7+
8+
public struct SheetResponse: Codable {
9+
let sheets: [SheetEntry]
10+
11+
var sheetNames: [String] {
12+
sheets.map(\.name)
13+
}
14+
}
15+
16+
public struct SheetEntry: Codable {
17+
let name: String
18+
}
19+
20+
public struct VersionResponse: Codable {
21+
let versions: [VersionEntry]
22+
23+
var versionNames: [String] {
24+
versions.flatMap(\.names)
25+
}
26+
}
27+
28+
public struct VersionEntry: Codable {
29+
let names: [String]
30+
}

0 commit comments

Comments
 (0)