Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ValidServerResponse): Response status #103

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading