Skip to content

Commit

Permalink
feat: No avatar default queryItem added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambrdctr committed Apr 4, 2024
1 parent c9879d2 commit 3b37688
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Sources/InfomaniakCore/Networking/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public struct Endpoint {
self.path = path
self.queryItems = queryItems
}

public init(host: String,
path: String,
queryItems: [URLQueryItem]? = nil) {
Expand All @@ -81,6 +81,10 @@ public struct Endpoint {
public func appending(path: String, queryItems: [URLQueryItem]? = nil) -> Endpoint {
return Endpoint(host: host, path: self.path + path, queryItems: queryItems)
}

public static func noAvatarDefault(_ value: Bool = true) -> URLQueryItem {
return URLQueryItem(name: "no_avatar_default", value: value ? "1" : "0")
}
}

// MARK: - Endpoints
Expand All @@ -100,11 +104,11 @@ public extension Endpoint {
URLQueryItem(name: "order_by", value: "name")
])
}

static func profile(ignoreDefaultAvatar: Bool) -> Endpoint {
return .baseV2.appending(path: "/profile", queryItems: [
URLQueryItem(name: "no_avatar_default", value: ignoreDefaultAvatar ? "1" : "0"),
URLQueryItem(name: "with", value: "emails,phones")
])
}
return .baseV2.appending(path: "/profile", queryItems: [
noAvatarDefault(ignoreDefaultAvatar),
URLQueryItem(name: "with", value: "emails,phones")
])
}
}

0 comments on commit 3b37688

Please sign in to comment.