Skip to content

Commit

Permalink
feat: Add isStaff property
Browse files Browse the repository at this point in the history
  • Loading branch information
flowbe authored and PhilippeWeidmann committed Jul 12, 2024
1 parent c8c7c35 commit 526c815
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/InfomaniakCore/Account/User/UserProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class UserProfile: Codable, InfomaniakUser {
public var preferences: UserPreferences
public var phones: [UserPhone]
public var emails: [UserEmail]
public var isStaff: Bool?

private enum OldCodingKeys: String, CodingKey {
case id
Expand Down Expand Up @@ -65,6 +66,7 @@ public class UserProfile: Codable, InfomaniakUser {
preferences = try container.decodeIfPresent(UserPreferences.self, forKey: .preferences) ?? UserPreferences()
phones = try container.decodeIfPresent([UserPhone].self, forKey: .phones) ?? []
emails = try container.decodeIfPresent([UserEmail].self, forKey: .emails) ?? []
isStaff = try container.decodeIfPresent(Bool.self, forKey: .isStaff)
} catch DecodingError.keyNotFound {
// Try old coding keys
let container = try decoder.container(keyedBy: OldCodingKeys.self)
Expand Down
2 changes: 2 additions & 0 deletions Sources/InfomaniakCore/Networking/ApiFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ open class ApiFetcher {
open func authenticatedRequest<Parameters: Encodable>(_ endpoint: Endpoint,
method: HTTPMethod = .get,
parameters: Parameters? = nil,
headers: HTTPHeaders? = nil,
requestModifier: RequestModifier? = nil) -> DataRequest {
return authenticatedSession
.request(
endpoint.url,
method: method,
parameters: parameters,
encoder: JSONParameterEncoder.convertToSnakeCase,
headers: headers,
requestModifier: requestModifier
)
}
Expand Down

0 comments on commit 526c815

Please sign in to comment.