diff --git a/README.md b/README.md index a51adeb..95ff9a6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # UNSPLASHER SDK -![build](https://img.shields.io/badge/build-passing-green.svg) ![platform](https://img.shields.io/badge/platform-iOS%209.0%2B-lightgrey.svg) ![platform](https://img.shields.io/badge/xcode-9.0%2B-lightgrey.svg) ![swift version](https://img.shields.io/badge/swift-4.1-orange.svg) ![cocoapods](https://img.shields.io/badge/pod-v1.0.3-blue.svg) + +![build](https://img.shields.io/badge/build-passing-green.svg) +![platform](https://img.shields.io/badge/platform-iOS%209.0%2B-lightgrey.svg) +![platform](https://img.shields.io/badge/xcode-9.0%2B-lightgrey.svg) +![swift version](https://img.shields.io/badge/swift-4.1-orange.svg) +[![cocoapods](https://img.shields.io/cocoapods/v/UnsplasherSDK.svg?style=flat)](https://cocoapods.org/pods/UnsplasherSDK) +[![license](https://img.shields.io/cocoapods/l/KeyboardSwift.svg?style=flat)](https://cocoapods.org/pods/KeyboardSwift) An Unsplash API client written in Swift. It supports user authentication, likes, manage collections and every feature of the [official API](https://unsplash.com/documentation). diff --git a/Unsplasher/Info.plist b/Unsplasher/Info.plist index e234e4b..f0993d5 100644 --- a/Unsplasher/Info.plist +++ b/Unsplasher/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.3 + 1.0.4 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Unsplasher/Unsplash/Requests/Requests.swift b/Unsplasher/Unsplash/Requests/Requests.swift index 1f57175..aed8312 100644 --- a/Unsplasher/Unsplash/Requests/Requests.swift +++ b/Unsplasher/Unsplash/Requests/Requests.swift @@ -144,10 +144,6 @@ extension Unsplash { completion(.failure(UnsplashError.credentialsError)) return } - if let remaining = self.rateLimitRemaining, let limit = self.rateLimit, remaining <= 0 { - completion(.failure(UnsplashError.rateLimitError(limit))) - return - } Alamofire.request(url, method: method, parameters: parameters, encoding: URLEncoding.queryString, headers: includeHeaders ? headers(authenticationNeeded: isAuthenticated) : nil) .validate(statusCode: 200..<300) .responseJSON { (response) in @@ -155,6 +151,10 @@ extension Unsplash { let rateRemainingString = response.response?.allHeaderFields["x-ratelimit-remaining"] as? String { self.rateLimit = UInt32(rateString) self.rateLimitRemaining = UInt32(rateRemainingString) + if let remaining = self.rateLimitRemaining, let limit = self.rateLimit, remaining <= 0 { + completion(.failure(UnsplashError.rateLimitError(limit))) + return + } } if let linkString = response.response?.allHeaderFields["Link"] as? String { self.retrieveLinks(from: linkString)