Skip to content

Commit

Permalink
Merge pull request #138 from DimensionSrl/feature/updates
Browse files Browse the repository at this point in the history
Updates v1/EventShort and v1/Article APIs
  • Loading branch information
dulvui authored Jan 26, 2024
2 parents 69a92d2 + 31dd465 commit 803194f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ final class NewsListViewModel {

var articlesListPublisher = articlesClient.list(
Date(),
"noi-communityapp",
pageSize,
pageNumber
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class EventsViewModel {
startDate: startDate,
endDate: endDate,
eventLocation: .noi,
onlyActive: true,
publishedon: "noi-communityapp",
rawFilter: activeFilters.toQuery(),
removeNullValues: true,
optimizeDates: true
Expand Down Expand Up @@ -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:))
)
Expand Down
4 changes: 2 additions & 2 deletions NOICommunityLib/Sources/ArticlesClient/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import Combine

public struct ArticlesClient {

public var list: (Date, Int?, Int?) -> AnyPublisher<ArticleListResponse, Error>
public var list: (Date, String?, Int?, Int?) -> AnyPublisher<ArticleListResponse, Error>

public typealias ArticleId = String
public var detail: (String) -> AnyPublisher<Article, Error>

public init(
list: @escaping (Date, Int?, Int?) -> AnyPublisher<ArticleListResponse, Error>,
list: @escaping (Date, String?, Int?, Int?) -> AnyPublisher<ArticleListResponse, Error>,
detail: @escaping (String) -> AnyPublisher<Article, Error>
) {
self.list = list
Expand Down
15 changes: 9 additions & 6 deletions NOICommunityLib/Sources/ArticlesClientLive/Endpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension Endpoint {

static func articleList(
startDate: Date,
publishedon: String?,
pageSize: Int?,
pageNumber: Int?
) -> Endpoint {
Expand All @@ -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",
Expand All @@ -48,11 +56,6 @@ extension Endpoint {
)
}

URLQueryItem(
name: "onlyActive",
value: "true"
)

URLQueryItem(
name: "removeNullValues",
value: "true"
Expand Down
5 changes: 3 additions & 2 deletions NOICommunityLib/Sources/ArticlesClientLive/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions NOICommunityLib/Sources/EventShortClient/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]?
Expand All @@ -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?
Expand All @@ -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,
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions NOICommunityLib/Sources/EventShortClientLive/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 803194f

Please sign in to comment.