fix(sdk): normalize API path convention — all SDK components now include /api prefix in paths
This commit is contained in:
parent
10e252617b
commit
78b942a105
@ -106,7 +106,7 @@ public final class BLAuthClient {
|
|||||||
"password": password,
|
"password": password,
|
||||||
"productId": config.productId,
|
"productId": config.productId,
|
||||||
]
|
]
|
||||||
let (data, _) = try await client.rawRequest(path: "/auth/login", method: "POST", body: body)
|
let (data, _) = try await client.rawRequest(path: "/api/auth/login", method: "POST", body: body)
|
||||||
let result = try JSONDecoder().decode(TokenResponse.self, from: data)
|
let result = try JSONDecoder().decode(TokenResponse.self, from: data)
|
||||||
saveTokens(access: result.accessToken, refresh: result.refreshToken)
|
saveTokens(access: result.accessToken, refresh: result.refreshToken)
|
||||||
startRefreshTimer()
|
startRefreshTimer()
|
||||||
@ -121,7 +121,7 @@ public final class BLAuthClient {
|
|||||||
"password": password,
|
"password": password,
|
||||||
"productId": config.productId,
|
"productId": config.productId,
|
||||||
]
|
]
|
||||||
let (data, _) = try await client.rawRequest(path: "/auth/register", method: "POST", body: body)
|
let (data, _) = try await client.rawRequest(path: "/api/auth/register", method: "POST", body: body)
|
||||||
let result = try JSONDecoder().decode(TokenResponse.self, from: data)
|
let result = try JSONDecoder().decode(TokenResponse.self, from: data)
|
||||||
saveTokens(access: result.accessToken, refresh: result.refreshToken)
|
saveTokens(access: result.accessToken, refresh: result.refreshToken)
|
||||||
startRefreshTimer()
|
startRefreshTimer()
|
||||||
@ -130,7 +130,7 @@ public final class BLAuthClient {
|
|||||||
|
|
||||||
/// Fetch current user profile.
|
/// Fetch current user profile.
|
||||||
public func getMe() async throws -> BLAuthUser {
|
public func getMe() async throws -> BLAuthUser {
|
||||||
return try await client.request(path: "/auth/me", responseType: BLAuthUser.self)
|
return try await client.request(path: "/api/auth/me", responseType: BLAuthUser.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refresh the access token using the stored refresh token.
|
/// Refresh the access token using the stored refresh token.
|
||||||
@ -140,7 +140,7 @@ public final class BLAuthClient {
|
|||||||
let body = ["refreshToken": rt]
|
let body = ["refreshToken": rt]
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let (data, _) = try await client.rawRequest(path: "/auth/refresh", method: "POST", body: body)
|
let (data, _) = try await client.rawRequest(path: "/api/auth/refresh", method: "POST", body: body)
|
||||||
let result = try JSONDecoder().decode(RefreshResponse.self, from: data)
|
let result = try JSONDecoder().decode(RefreshResponse.self, from: data)
|
||||||
saveTokens(access: result.accessToken, refresh: result.refreshToken)
|
saveTokens(access: result.accessToken, refresh: result.refreshToken)
|
||||||
return true
|
return true
|
||||||
@ -155,37 +155,37 @@ public final class BLAuthClient {
|
|||||||
/// Request password reset email.
|
/// Request password reset email.
|
||||||
public func forgotPassword(email: String) async throws {
|
public func forgotPassword(email: String) async throws {
|
||||||
let body = ["email": email, "productId": config.productId]
|
let body = ["email": email, "productId": config.productId]
|
||||||
_ = try await client.rawRequest(path: "/auth/forgot-password", method: "POST", body: body)
|
_ = try await client.rawRequest(path: "/api/auth/forgot-password", method: "POST", body: body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reset password with token.
|
/// Reset password with token.
|
||||||
public func resetPassword(token: String, newPassword: String) async throws {
|
public func resetPassword(token: String, newPassword: String) async throws {
|
||||||
let body = ["token": token, "newPassword": newPassword]
|
let body = ["token": token, "newPassword": newPassword]
|
||||||
_ = try await client.rawRequest(path: "/auth/reset-password", method: "POST", body: body)
|
_ = try await client.rawRequest(path: "/api/auth/reset-password", method: "POST", body: body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Change password (authenticated).
|
/// Change password (authenticated).
|
||||||
public func changePassword(currentPassword: String, newPassword: String) async throws {
|
public func changePassword(currentPassword: String, newPassword: String) async throws {
|
||||||
let body = ["currentPassword": currentPassword, "newPassword": newPassword]
|
let body = ["currentPassword": currentPassword, "newPassword": newPassword]
|
||||||
_ = try await client.rawRequest(path: "/auth/change-password", method: "POST", body: body)
|
_ = try await client.rawRequest(path: "/api/auth/change-password", method: "POST", body: body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify email with token.
|
/// Verify email with token.
|
||||||
public func verifyEmail(token: String) async throws {
|
public func verifyEmail(token: String) async throws {
|
||||||
let body = ["token": token]
|
let body = ["token": token]
|
||||||
_ = try await client.rawRequest(path: "/auth/verify-email", method: "POST", body: body)
|
_ = try await client.rawRequest(path: "/api/auth/verify-email", method: "POST", body: body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resend verification email.
|
/// Resend verification email.
|
||||||
public func resendVerification(email: String) async throws {
|
public func resendVerification(email: String) async throws {
|
||||||
let body = ["email": email, "productId": config.productId]
|
let body = ["email": email, "productId": config.productId]
|
||||||
_ = try await client.rawRequest(path: "/auth/resend-verification", method: "POST", body: body)
|
_ = try await client.rawRequest(path: "/api/auth/resend-verification", method: "POST", body: body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete account (requires password confirmation).
|
/// Delete account (requires password confirmation).
|
||||||
public func deleteAccount(password: String) async throws {
|
public func deleteAccount(password: String) async throws {
|
||||||
let body = ["password": password]
|
let body = ["password": password]
|
||||||
_ = try await client.rawRequest(path: "/auth/account", method: "DELETE", body: body)
|
_ = try await client.rawRequest(path: "/api/auth/account", method: "DELETE", body: body)
|
||||||
logout()
|
logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -209,6 +209,6 @@ public final class BLTelemetryClient {
|
|||||||
]
|
]
|
||||||
|
|
||||||
guard let jsonData = try? JSONSerialization.data(withJSONObject: body) else { return }
|
guard let jsonData = try? JSONSerialization.data(withJSONObject: body) else { return }
|
||||||
client.fireAndForget(path: "/telemetry/events", body: jsonData)
|
client.fireAndForget(path: "/api/telemetry/events", body: jsonData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user