Skip to content

Commit 8296935

Browse files
committed
Migrate to new pickup line API
1 parent 784ce11 commit 8296935

File tree

5 files changed

+7
-29
lines changed

5 files changed

+7
-29
lines changed

Diff for: Sources/D2Commands/Fun/PickupLineCommand.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ public class PickupLineCommand: StringCommand {
1111
public init() {}
1212

1313
public func invoke(with input: String, output: any CommandOutput, context: CommandContext) async {
14-
let queries: [PickupLineQuery] = [PebblePickupQuery(), PickupLineGenQuery()]
1514
do {
16-
let line = try await queries.randomElement()!.perform()
17-
await output.append(line.tweet)
15+
let line = try await PickupLineApiQuery().perform()
16+
await output.append(line.text)
1817
} catch {
1918
await output.append(error, errorText: "Could not fetch pickup line")
2019
}

Diff for: Sources/D2NetAPIs/Pickup/PickupLine.swift

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
public struct PickupLine: Sendable, Codable {
2-
public let username: String?
3-
public let tweet: String
4-
5-
public init(username: String? = nil, tweet: String) {
6-
self.username = username
7-
self.tweet = tweet
8-
}
2+
public let text: String
3+
public let category: String
4+
public let language: String
95
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Utils
22

3-
public struct PebblePickupQuery: PickupLineQuery {
3+
public struct PickupLineApiQuery: PickupLineQuery {
44
public init() {}
55

66
public func perform() async throws -> PickupLine {
7-
let request = try HTTPRequest(host: "pebble-pickup.herokuapp.com", path: "/tweets/random")
7+
let request = try HTTPRequest(host: "rizzapi.vercel.app", path: "/random")
88
return try await request.fetchJSON(as: PickupLine.self)
99
}
1010
}

Diff for: Sources/D2NetAPIs/Pickup/PickupLineGenError.swift

-5
This file was deleted.

Diff for: Sources/D2NetAPIs/Pickup/PickupLineGenQuery.swift

-12
This file was deleted.

0 commit comments

Comments
 (0)