Skip to content

Commit

Permalink
Merge pull request #103 from Infomaniak/response-status
Browse files Browse the repository at this point in the history
feat(ValidServerResponse): Response status
  • Loading branch information
PhilippeWeidmann committed Feb 27, 2024
2 parents 5e65d5c + e5b350d commit 5dd38a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension ApiFetcher: RequestDispatchable {
parameters: nil)
}

return try await perform(request: request).data
return try await perform(request: request)
}

func dispatchNSURLSession<Result: Decodable>(_ requestable: Requestable) async throws -> Result {
Expand Down
10 changes: 7 additions & 3 deletions Sources/InfomaniakCore/Networking/ApiFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ open class ApiFetcher {
itemsPerPage: apiResponse.itemsPerPage,
responseAt: apiResponse.responseAt
)
return ValidServerResponse(responseHeaders: serverResponse.headers, validApiResponse: validApiResponse)
return ValidServerResponse(
statusCode: serverResponse.statusCode,
responseHeaders: serverResponse.headers,
validApiResponse: validApiResponse
)
} else if let apiError = apiResponse.error {
throw InfomaniakError.apiError(apiError)
} else {
Expand All @@ -189,11 +193,11 @@ open class ApiFetcher {
}

public func userOrganisations() async throws -> [OrganisationAccount] {
try await perform(request: authenticatedRequest(.organisationAccounts)).data
try await perform(request: authenticatedRequest(.organisationAccounts))
}

public func userProfile() async throws -> UserProfile {
try await perform(request: authenticatedRequest(.profile)).data
try await perform(request: authenticatedRequest(.profile))
}
}

Expand Down
1 change: 1 addition & 0 deletions Sources/InfomaniakCore/Networking/ValidApiResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Alamofire

public struct ValidServerResponse<ValidApiResponseContent> {
public let statusCode: Int
public let responseHeaders: HTTPHeaders
public let validApiResponse: ValidApiResponse<ValidApiResponseContent>
}
Expand Down

0 comments on commit 5dd38a7

Please sign in to comment.