diff --git a/Papr/Services/CollectionService/CollectionService.swift b/Papr/Services/CollectionService/CollectionService.swift index bdd94dc..7f6d365 100644 --- a/Papr/Services/CollectionService/CollectionService.swift +++ b/Papr/Services/CollectionService/CollectionService.swift @@ -12,33 +12,33 @@ import Moya struct CollectionService: CollectionServiceType { - private var unsplash: MoyaProvider + private var unsplash: MoyaProvider - init(unsplash: MoyaProvider = MoyaProvider()) { + init(unsplash: MoyaProvider = MoyaProvider()) { self.unsplash = unsplash } func collection(withID id: Int) -> Observable { - return unsplash.rx.request(.collection(id: id)) + return unsplash.rx.request(MultiTarget(Unsplash.collection(id: id))) .map(PhotoCollection.self) .asObservable() } func collections(withUsername username: String) -> Observable<[PhotoCollection]> { return self.unsplash.rx - .request(.userCollections(username: username, page: 1, perPage: 20)) + .request(MultiTarget(Unsplash.userCollections(username: username, page: 1, perPage: 20))) .map([PhotoCollection].self) .asObservable() } func photos(fromCollectionId id: Int) -> Observable<[Photo]> { - return unsplash.rx.request(.collectionPhotos(id: id, page: 1, perPage: 10)) + return unsplash.rx.request(MultiTarget(Unsplash.collectionPhotos(id: id, page: 1, perPage: 10))) .map([Photo].self) .asObservable() } func addPhotoToCollection(withId id: Int, photoId: String) -> Observable> { - return unsplash.rx.request(.addPhotoToCollection(collectionID: id, photoID: photoId)) + return unsplash.rx.request(MultiTarget(Unsplash.addPhotoToCollection(collectionID: id, photoID: photoId))) .map(CollectionResponse.self) .map { $0.photo } .asObservable() @@ -48,7 +48,7 @@ struct CollectionService: CollectionServiceType { } func removePhotoFromCollection(withId id: Int, photoId: String) -> Observable> { - return unsplash.rx.request(.removePhotoFromCollection(collectionID: id, photoID: photoId)) + return unsplash.rx.request(MultiTarget(Unsplash.removePhotoFromCollection(collectionID: id, photoID: photoId))) .map(CollectionResponse.self) .map { $0.photo } .asObservable() @@ -63,10 +63,10 @@ struct CollectionService: CollectionServiceType { isPrivate: Bool ) -> Observable> { - return unsplash.rx.request(.createCollection( + return unsplash.rx.request(MultiTarget(Unsplash.createCollection( title: title, description: description, - isPrivate: isPrivate)) + isPrivate: isPrivate))) .map(PhotoCollection.self) .asObservable() .map (Result.success) diff --git a/Papr/Services/PhotoService/PhotoService.swift b/Papr/Services/PhotoService/PhotoService.swift index d03ce8d..ff7ef33 100644 --- a/Papr/Services/PhotoService/PhotoService.swift +++ b/Papr/Services/PhotoService/PhotoService.swift @@ -12,16 +12,16 @@ import Moya struct PhotoService: PhotoServiceType { - private var unsplash: MoyaProvider + private var unsplash: MoyaProvider //plugins: [NetworkLoggerPlugin(verbose: false)]) - init(unsplash: MoyaProvider = MoyaProvider()) { + init(unsplash: MoyaProvider = MoyaProvider()) { self.unsplash = unsplash } func like(photo: Photo) -> Observable> { return unsplash.rx - .request(.likePhoto(id: photo.id ?? "")) + .request(MultiTarget(Unsplash.likePhoto(id: photo.id ?? ""))) .map(LikeUnlike.self) .map { $0.photo } .asObservable() @@ -38,7 +38,7 @@ struct PhotoService: PhotoServiceType { func unlike(photo: Photo) -> Observable> { return unsplash.rx - .request(.unlikePhoto(id: photo.id ?? "")) + .request(MultiTarget(Unsplash.unlikePhoto(id: photo.id ?? ""))) .map(LikeUnlike.self) .asObservable() .map { $0.photo } @@ -55,7 +55,7 @@ struct PhotoService: PhotoServiceType { func photo(withId id: String) -> Observable { return unsplash.rx - .request(.photo(id: id, width: nil, height: nil, rect: nil)) + .request(MultiTarget(Unsplash.photo(id: id, width: nil, height: nil, rect: nil))) .map(Photo.self) .asObservable() } @@ -69,12 +69,12 @@ struct PhotoService: PhotoServiceType { if curated { return unsplash.rx - .request(.curatedPhotos( + .request(MultiTarget(Unsplash.curatedPhotos( page: pageNumber, perPage: Constants.photosPerPage, orderBy: orderBy ) - ) + )) .map([Photo].self) .asObservable() .map(Result.success) @@ -84,12 +84,12 @@ struct PhotoService: PhotoServiceType { } return unsplash.rx - .request(.photos( + .request(MultiTarget(Unsplash.photos( page: pageNumber, perPage: Constants.photosPerPage, orderBy: orderBy ) - ) + )) .map([Photo].self) .asObservable() .map(Result.success) @@ -100,18 +100,18 @@ struct PhotoService: PhotoServiceType { func statistics(of photo: Photo) -> Observable { return unsplash.rx - .request(.photoStatistics( + .request(MultiTarget(Unsplash.photoStatistics( id: photo.id ?? "", resolution: .days, quantity: 30) - ) + )) .map(PhotoStatistics.self) .asObservable() } func photoDownloadLink(withId id: String) -> Observable> { return unsplash.rx - .request(.photoDownloadLink(id: id)) + .request(MultiTarget(Unsplash.photoDownloadLink(id: id))) .map(Link.self) .map { $0.url } .asObservable() diff --git a/Papr/Services/SearchService/SearchService.swift b/Papr/Services/SearchService/SearchService.swift index f9b928f..50b0481 100644 --- a/Papr/Services/SearchService/SearchService.swift +++ b/Papr/Services/SearchService/SearchService.swift @@ -11,40 +11,40 @@ import RxSwift import Moya struct SearchService: SearchServiceType { - private var unsplash: MoyaProvider + private var unsplash: MoyaProvider - init(unsplash: MoyaProvider = MoyaProvider()) { + init(unsplash: MoyaProvider = MoyaProvider()) { self.unsplash = unsplash } func searchPhotos(with query: String, pageNumber: Int) -> Observable { - return unsplash.rx.request(.searchPhotos( + return unsplash.rx.request(MultiTarget(Unsplash.searchPhotos( query: query, page: pageNumber, perPage: Constants.photosPerPage, collections: nil, orientation: nil) - ) + )) .map(PhotosResult.self) .asObservable() } func searchCollections(with query: String, pageNumber: Int) -> Observable { - return unsplash.rx.request(.searchCollections( + return unsplash.rx.request(MultiTarget(Unsplash.searchCollections( query: query, page: pageNumber, perPage: 10) - ) + )) .map(PhotoCollectionsResult.self) .asObservable() } func searchUsers(with query: String, pageNumber: Int) -> Observable { - return unsplash.rx.request(.searchUsers( + return unsplash.rx.request(MultiTarget(Unsplash.searchUsers( query: query, page: pageNumber, perPage: 10) - ) + )) .map(UsersResult.self) .asObservable() } diff --git a/Papr/Services/UserService/UserService.swift b/Papr/Services/UserService/UserService.swift index 0822d9a..c23a4d2 100644 --- a/Papr/Services/UserService/UserService.swift +++ b/Papr/Services/UserService/UserService.swift @@ -12,15 +12,15 @@ import RxSwift struct UserService: UserServiceType { - private var unsplash: MoyaProvider + private var unsplash: MoyaProvider - init(unsplash: MoyaProvider = MoyaProvider()) { + init(unsplash: MoyaProvider = MoyaProvider()) { self.unsplash = unsplash } func getMe() -> Observable> { return unsplash.rx - .request(.getMe) + .request(MultiTarget(Unsplash.getMe)) .map(User.self) .map(Result.success) .catchError { error in diff --git a/Papr/Utils/Authentication/UnsplashAuthManager.swift b/Papr/Utils/Authentication/UnsplashAuthManager.swift index 3b34601..3d5c871 100644 --- a/Papr/Utils/Authentication/UnsplashAuthManager.swift +++ b/Papr/Utils/Authentication/UnsplashAuthManager.swift @@ -83,7 +83,7 @@ class UnsplashAuthManager { private let clientSecret: String private let redirectURL: URL private let scopes: [String] - private let unplash: MoyaProvider + private let unplash: MoyaProvider // MARK: Init init(clientID: String, clientSecret: String, scopes: [String] = [Scope.pub.string]) { @@ -92,7 +92,7 @@ class UnsplashAuthManager { self.redirectURL = URL(string: UnsplashSettings.redirectURL.string)! self.scopes = scopes - unplash = MoyaProvider() + unplash = MoyaProvider() } // MARK: Public @@ -103,7 +103,7 @@ class UnsplashAuthManager { } public func accessToken(with code: String, completion: @escaping (String?, Error?) -> Void) { - unplash.request(.accessToken(withCode: code)) { response in + unplash.request(MultiTarget(UnsplashAuthorization.accessToken(withCode: code))) { response in DispatchQueue.main.async { [unowned self] in switch response { case let .success(result):