feat: add independent common api client

这个提交包含在:
XuqmGroup 2026-05-08 09:27:38 +08:00
父节点 5df6d70065
当前提交 670ff74374
共有 3 个文件被更改,包括 34 次插入2 次删除

查看文件

@ -0,0 +1,32 @@
import Foundation
public enum CommonApiClient {
public static func postJSON(urlString: String, body: [String: Any]) async throws -> [String: Any] {
guard let url = URL(string: urlString) else {
throw URLError(.badURL)
}
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.httpBody = try JSONSerialization.data(withJSONObject: body)
let (data, response) = try await URLSession.shared.data(for: request)
guard let http = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
let json = try JSONSerialization.jsonObject(with: data) as? [String: Any] ?? [:]
guard (200..<300).contains(http.statusCode) else {
throw NSError(
domain: "CommonApiClient",
code: http.statusCode,
userInfo: [NSLocalizedDescriptionKey: json["message"] as? String ?? "HTTP \(http.statusCode)"]
)
}
return json
}
}

查看文件

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'XuqmSDK'
s.version = '0.1.0'
s.version = '0.1.1'
s.summary = 'XuqmGroup iOS SDK — IM, Push Notifications, Version Management'
s.homepage = 'https://xuqinmin.com/xuqinmin12/XuqmGroup-iOSSDK'
s.license = { :type => 'MIT' }

查看文件

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'XuqmWebViewSDK'
s.version = '0.1.0'
s.version = '0.1.1'
s.summary = 'XuqmGroup iOS SDK — WebView module'
s.homepage = 'https://xuqinmin.com/xuqinmin12/XuqmGroup-iOSSDK'
s.license = { :type => 'MIT' }