mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
### Purpose: This is a prerequisite for #2288. The new grace period means that if we didn't update the date from the cached responses, entitlements would become stale and expired after 3 days. ### Changes: - Added `HTTPResponseBody.copy(with newRequestDate:)` to be able to modify responses from the header request date - `CustomerInfo` implements this method to modify its request date - Added `HTTPResponse.requestDate` to be able to keep track of the request date from the server - Added `VerificationResult.from(cache:response:)` to determine the most restrictive verification result based on what's cached or checked from a response - Added `HTTPResponse.copy(with:)` to modify the verification result of a response using the previous method - `HTTPClient` now uses the most restrictive verification result - `HTTPClient` updates request date from server responses or cached responses (unless verification failed). This was the missing piece for #2288. ### Tests: - Verify that `ETagManager` does not use an ETag if verification was previously not enabled - Verify that `ETagManager` returns the request date from the server when returning a cached response - Verify that `HTTPClient` updates the request date from the server or from a cached response - Verify that `HTTPClient` does not update request date if verification failed - Tests for `HTTPResponse` request date parsing - Test for `CustomerInfoResponseHandler` updating request date - Tests for `CustomerInfo.copy(with newRequestDate:)` ### Other smaller changes: - Moved `CustomerInfo.asData()` into `Encodable.asJSONEncodedData()` - Renamed `requestTime` to `requestDate` everywhere for consistency