From 8d5e7d56f53f5644875e06fbd15f259ac8404d5a Mon Sep 17 00:00:00 2001 From: winebarrel Date: Sat, 14 Dec 2024 21:13:06 +0900 Subject: [PATCH] chore: Fix PD API URL path --- PagerCall/PagerDutyAPI.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PagerCall/PagerDutyAPI.swift b/PagerCall/PagerDutyAPI.swift index e39b159..4759245 100644 --- a/PagerCall/PagerDutyAPI.swift +++ b/PagerCall/PagerDutyAPI.swift @@ -36,7 +36,7 @@ struct PagerDutyAPI { } func isOnCall(_ apiKey: String) async throws -> Bool { - let data = try await get(apiKey, "/oncalls", ["user_ids[]": userID]) + let data = try await get(apiKey, "oncalls", ["user_ids[]": userID]) let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase let resp = try decoder.decode(OncallsResp.self, from: data) @@ -49,7 +49,7 @@ struct PagerDutyAPI { } func getIncidents(_ apiKey: String) async throws -> Incidents { - let data = try await get(apiKey, "/incidents", ["user_ids[]": userID]) + let data = try await get(apiKey, "incidents", ["user_ids[]": userID]) let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase decoder.dateDecodingStrategy = .iso8601 @@ -59,7 +59,7 @@ struct PagerDutyAPI { } private func get(_ apiKey: String, _ path: String, _ query: [String: String] = [:]) async throws -> Data { - var url = endpoint.appendingPathComponent(path) + var url = endpoint.appending(component: path, directoryHint: .notDirectory) url.append(queryItems: query.map { key, val in URLQueryItem(name: key, value: val) }) var req = URLRequest(url: url)