@@ -25,12 +25,12 @@ public struct AuthAdmin: Sendable {
25
25
/// - Warning: Never expose your `service_role` key on the client.
26
26
public func deleteUser( id: String , shouldSoftDelete: Bool = false ) async throws {
27
27
_ = try await api. execute (
28
- HTTPRequest (
29
- url: configuration. url. appendingPathComponent ( " admin/users/ \( id) " ) ,
28
+ for: HTTPRequest (
30
29
method: . delete,
31
- body: encoder. encode (
32
- DeleteUserRequest ( shouldSoftDelete: shouldSoftDelete)
33
- )
30
+ url: configuration. url. appendingPathComponent ( " admin/users/ \( id) " )
31
+ ) ,
32
+ from: encoder. encode (
33
+ DeleteUserRequest ( shouldSoftDelete: shouldSoftDelete)
34
34
)
35
35
)
36
36
}
@@ -46,27 +46,29 @@ public struct AuthAdmin: Sendable {
46
46
let aud : String
47
47
}
48
48
49
- let httpResponse = try await api. execute (
50
- HTTPRequest (
51
- url: configuration. url. appendingPathComponent ( " admin/users " ) ,
49
+ let ( data, response) = try await api. execute (
50
+ for: HTTPRequest (
52
51
method: . get,
53
- query: [
54
- URLQueryItem ( name: " page " , value: params? . page? . description ?? " " ) ,
55
- URLQueryItem ( name: " per_page " , value: params? . perPage? . description ?? " " ) ,
56
- ]
57
- )
52
+ url: configuration. url
53
+ . appendingPathComponent ( " admin/users " )
54
+ . appendingQueryItems ( [
55
+ URLQueryItem ( name: " page " , value: params? . page? . description ?? " " ) ,
56
+ URLQueryItem ( name: " per_page " , value: params? . perPage? . description ?? " " ) ,
57
+ ] )
58
+ ) ,
59
+ from: nil
58
60
)
59
61
60
- let response = try httpResponse . decoded ( as : Response . self, decoder : configuration . decoder )
62
+ let responseData = try configuration . decoder . decode ( Response . self, from : data )
61
63
62
64
var pagination = ListUsersPaginatedResponse (
63
- users: response . users,
64
- aud: response . aud,
65
+ users: responseData . users,
66
+ aud: responseData . aud,
65
67
lastPage: 0 ,
66
- total: httpResponse . headers [ . xTotalCount] . flatMap ( Int . init) ?? 0
68
+ total: response . headerFields [ . xTotalCount] . flatMap ( Int . init) ?? 0
67
69
)
68
70
69
- let links = httpResponse . headers [ . link] ? . components ( separatedBy: " , " ) ?? [ ]
71
+ let links = response . headerFields [ . link] ? . components ( separatedBy: " , " ) ?? [ ]
70
72
if !links. isEmpty {
71
73
for link in links {
72
74
let page = link. components ( separatedBy: " ; " ) [ 0 ] . components ( separatedBy: " = " ) [ 1 ] . prefix ( while: \. isNumber)
0 commit comments