Skip to content

Commit

Permalink
Merge pull request #77 from winebarrel/chore/fix_url_path
Browse files Browse the repository at this point in the history
chore: Fix PD API URL path
  • Loading branch information
winebarrel authored Dec 14, 2024
2 parents 32fa563 + 8d5e7d5 commit 58cd357
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions PagerCall/PagerDutyAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 58cd357

Please sign in to comment.