From 31dd465161ef897941592008b9f5b915769dfb4f Mon Sep 17 00:00:00 2001 From: Matteo Matassoni <4108197+matax87@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:27:52 +0100 Subject: [PATCH] Updates v1/EventShort and v1/Article APIs --- .../View Models/NewsListViewModel.swift | 1 + .../View Models/EventsViewModel.swift | 4 ++-- .../Sources/ArticlesClient/Interface.swift | 4 ++-- .../Sources/ArticlesClientLive/Endpoints.swift | 15 +++++++++------ .../Sources/ArticlesClientLive/Live.swift | 5 +++-- .../Sources/EventShortClient/Models.swift | 8 ++++---- .../Sources/EventShortClientLive/Live.swift | 6 +++--- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/NOICommunity/NewsFeature/View Models/NewsListViewModel.swift b/NOICommunity/NewsFeature/View Models/NewsListViewModel.swift index 2de8f8e..f63b395 100644 --- a/NOICommunity/NewsFeature/View Models/NewsListViewModel.swift +++ b/NOICommunity/NewsFeature/View Models/NewsListViewModel.swift @@ -76,6 +76,7 @@ final class NewsListViewModel { var articlesListPublisher = articlesClient.list( Date(), + "noi-communityapp", pageSize, pageNumber ) diff --git a/NOICommunity/TodayFeature/EventsFeature/View Models/EventsViewModel.swift b/NOICommunity/TodayFeature/EventsFeature/View Models/EventsViewModel.swift index b6638a1..360c8e6 100644 --- a/NOICommunity/TodayFeature/EventsFeature/View Models/EventsViewModel.swift +++ b/NOICommunity/TodayFeature/EventsFeature/View Models/EventsViewModel.swift @@ -70,7 +70,7 @@ class EventsViewModel { startDate: startDate, endDate: endDate, eventLocation: .noi, - onlyActive: true, + publishedon: "noi-communityapp", rawFilter: activeFilters.toQuery(), removeNullValues: true, optimizeDates: true @@ -225,7 +225,7 @@ private extension Event { organizer: !eventShort.display5.isNilOrEmpty ? eventShort.display5 : eventShort.companyName, - technologyFields: eventShort.technologyFields ?? [], + technologyFields: eventShort.technologyFields?.compactMap { $0 } ?? [], mapURL: mapURL, signupURL: eventShort.webAddress.flatMap(URL.init(string:)) ) diff --git a/NOICommunityLib/Sources/ArticlesClient/Interface.swift b/NOICommunityLib/Sources/ArticlesClient/Interface.swift index e7d0ade..a6ee8fc 100644 --- a/NOICommunityLib/Sources/ArticlesClient/Interface.swift +++ b/NOICommunityLib/Sources/ArticlesClient/Interface.swift @@ -14,13 +14,13 @@ import Combine public struct ArticlesClient { - public var list: (Date, Int?, Int?) -> AnyPublisher + public var list: (Date, String?, Int?, Int?) -> AnyPublisher public typealias ArticleId = String public var detail: (String) -> AnyPublisher public init( - list: @escaping (Date, Int?, Int?) -> AnyPublisher, + list: @escaping (Date, String?, Int?, Int?) -> AnyPublisher, detail: @escaping (String) -> AnyPublisher ) { self.list = list diff --git a/NOICommunityLib/Sources/ArticlesClientLive/Endpoints.swift b/NOICommunityLib/Sources/ArticlesClientLive/Endpoints.swift index 7100d1b..018848a 100644 --- a/NOICommunityLib/Sources/ArticlesClientLive/Endpoints.swift +++ b/NOICommunityLib/Sources/ArticlesClientLive/Endpoints.swift @@ -25,6 +25,7 @@ extension Endpoint { static func articleList( startDate: Date, + publishedon: String?, pageSize: Int?, pageNumber: Int? ) -> Endpoint { @@ -33,7 +34,14 @@ extension Endpoint { name: "startDate", value: dateFormatter.string(from: startDate) ) - + + if let publishedon = publishedon { + URLQueryItem( + name: "publishedon", + value: publishedon + ) + } + if let pageSize = pageSize { URLQueryItem( name: "pagesize", @@ -48,11 +56,6 @@ extension Endpoint { ) } - URLQueryItem( - name: "onlyActive", - value: "true" - ) - URLQueryItem( name: "removeNullValues", value: "true" diff --git a/NOICommunityLib/Sources/ArticlesClientLive/Live.swift b/NOICommunityLib/Sources/ArticlesClientLive/Live.swift index b3375a5..0f3bf39 100644 --- a/NOICommunityLib/Sources/ArticlesClientLive/Live.swift +++ b/NOICommunityLib/Sources/ArticlesClientLive/Live.swift @@ -65,9 +65,10 @@ extension ArticlesClient { public static func live(urlSession: URLSession = .shared) -> Self { Self( - list: { startDate, pageSize, pageNumber in + list: { startDate, publishedon, pageSize, pageNumber in let urlRequest = Endpoint.articleList( - startDate: startDate, + startDate: startDate, + publishedon: publishedon, pageSize: pageSize, pageNumber: pageNumber ).makeRequest(withBaseURL: baseURL) diff --git a/NOICommunityLib/Sources/EventShortClient/Models.swift b/NOICommunityLib/Sources/EventShortClient/Models.swift index 03ba8e4..c1dc920 100644 --- a/NOICommunityLib/Sources/EventShortClient/Models.swift +++ b/NOICommunityLib/Sources/EventShortClient/Models.swift @@ -83,7 +83,7 @@ public struct EventShort: Decodable, Equatable { public let eventTextDE: String? public let eventTextIT: String? public let eventTextEN: String? - public let technologyFields: [String]? + public let technologyFields: [String?]? public let customTagging: [String]? public let soldOut: Bool? public let eventDocument: [DocumentPDF]? @@ -102,7 +102,7 @@ public struct EventShortListRequest { public let endDate: Date? public let source: Source? public let eventLocation: EventLocation? - public let onlyActive: Bool? + public let publishedon: String? public let eventIds: [String]? public let webAddress: String? public let sortOrder: Order? @@ -124,7 +124,7 @@ public struct EventShortListRequest { endDate: Date? = nil, source: Source? = nil, eventLocation: EventLocation? = nil, - onlyActive: Bool? = nil, + publishedon: String? = nil, eventIds: [String]? = nil, webAddress: String? = nil, sortOrder: Order? = nil, @@ -145,7 +145,7 @@ public struct EventShortListRequest { self.endDate = endDate self.source = source self.eventLocation = eventLocation - self.onlyActive = onlyActive + self.publishedon = publishedon self.eventIds = eventIds self.webAddress = webAddress self.sortOrder = sortOrder diff --git a/NOICommunityLib/Sources/EventShortClientLive/Live.swift b/NOICommunityLib/Sources/EventShortClientLive/Live.swift index c5e7241..a38e54a 100644 --- a/NOICommunityLib/Sources/EventShortClientLive/Live.swift +++ b/NOICommunityLib/Sources/EventShortClientLive/Live.swift @@ -150,10 +150,10 @@ private extension EventShortListRequest { name: "eventlocation", value: eventLocation.rawValue)) } - if let onlyActive = onlyActive { + if let publishedon = publishedon { result.append(URLQueryItem( - name: "onlyactive", - value: onlyActive ? "true" : "false")) + name: "publishedon", + value: publishedon)) } if let eventIds = eventIds { result.append(URLQueryItem(