Skip to content

Commit

Permalink
Remove curated collections endpoint and its related code
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisho committed Dec 13, 2019
1 parent 02482c7 commit 7c8b434
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Papr/Scenes/Collections/CollectionsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CollectionsViewModel: CollectionsViewModelType,
.flatMapLatest { isRefreshing -> Observable<[PhotoCollection]> in
guard isRefreshing else { return .empty() }
return service
.collections(byPageNumber: 1, curated: false)
.collections(byPageNumber: 1)
.flatMap { [unowned self] result -> Observable<[PhotoCollection]> in
switch result {
case let .success(photoCollections):
Expand All @@ -109,7 +109,7 @@ class CollectionsViewModel: CollectionsViewModelType,
guard isLoadingMore else { return .empty() }
currentPageNumber += 1
return service
.collections(byPageNumber: currentPageNumber, curated: false)
.collections(byPageNumber: currentPageNumber)
.flatMap { [unowned self] result -> Observable<[PhotoCollection]> in
switch result {
case let .success(photoCollections):
Expand Down
6 changes: 2 additions & 4 deletions Papr/Services/CollectionService/CollectionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ struct CollectionService: CollectionServiceType {
.asObservable()
}

func collections(byPageNumber page: Int, curated: Bool) -> Observable<Result<[PhotoCollection], String>> {
let collections: Unsplash = curated ?
.curatedCollections(page: page, perPage: 20) :
.featuredCollections(page: page, perPage: 20)
func collections(byPageNumber page: Int) -> Observable<Result<[PhotoCollection], String>> {
let collections: Unsplash = .featuredCollections(page: page, perPage: 20)

return unsplash.rx.request(resource: collections)
.map(to: [PhotoCollection].self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protocol CollectionServiceType {

func collections(withUsername username: String) -> Observable<[PhotoCollection]>

func collections(byPageNumber page: Int, curated: Bool) -> Observable<Result<[PhotoCollection], String>>
func collections(byPageNumber page: Int) -> Observable<Result<[PhotoCollection], String>>

func photos(fromCollectionId id: Int, pageNumber: Int) -> Observable<[Photo]>

Expand Down
24 changes: 1 addition & 23 deletions Papr/Utils/Enums/Unsplash/Unsplash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,9 @@ enum Unsplash {
page: Int?,
perPage: Int?)

/// Get a list of curated collections
case curatedCollections(
page: Int?,
perPage: Int?)

/// Retrieve a collection
case collection(id: Int)

/// Retrieve a curated collection
case curatedCollection(id: Int)

/// Retrieve a related collection
case relatedCollections(id: Int)

Expand All @@ -153,12 +145,6 @@ enum Unsplash {
page: Int?,
perPage: Int?)

/// Retrieve a curated collection’s photos
case curatedCollectionPhotos(
id: Int,
page: Int?,
perPage: Int?)

/// Create a new collection
case createCollection(
title: String,
Expand Down Expand Up @@ -243,16 +229,10 @@ extension Unsplash: Resource {
return .post(path: "/collections")
case .featuredCollections:
return .get(path: "/collections/featured")
case .curatedCollections:
return .get(path: "/collections/curated")
case let .collection(id):
return .get(path: "/collections/\(id)")
case let .curatedCollection(id):
return .get(path: "/collections/curated\(id)")
case let .collectionPhotos(params):
return .get(path: "/collections/\(params.id)/photos")
case let .curatedCollectionPhotos(params):
return .get(path: "/collections/curated/\(params.id)/photos")
case let .relatedCollections(id):
return .get(path: "/collections/\(id)/related")
case let .updateCollection(params):
Expand Down Expand Up @@ -352,9 +332,7 @@ extension Unsplash: Resource {
case let .userCollections(_, pageNumber, photosPerPage),
let .collections(pageNumber, photosPerPage),
let .featuredCollections(pageNumber, photosPerPage),
let .curatedCollections(pageNumber, photosPerPage),
let .collectionPhotos(_, pageNumber, photosPerPage),
let .curatedCollectionPhotos(_, pageNumber, photosPerPage):
let .collectionPhotos(_, pageNumber, photosPerPage):

var params: [String: Any] = [:]
params["page"] = pageNumber
Expand Down

0 comments on commit 7c8b434

Please sign in to comment.