mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
## Changes: - Added `PostOfferResponse` - Added `PostOfferDecodingTests` tests - Using the automatic deserialization by `HTTPClient` by simply changing the callback to `HTTPResponse<PostOfferResponse>.Result` - All tests in `BackendPostOfferForSigningTests` (which are very exhaustive) pass with no changes!
58 lines
1.2 KiB
Swift
58 lines
1.2 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// PostOfferResponse.swift
|
|
//
|
|
// Created by Nacho Soto on 5/12/22.
|
|
|
|
import Foundation
|
|
|
|
// swiftlint:disable nesting
|
|
|
|
struct PostOfferResponse {
|
|
|
|
struct Offer {
|
|
|
|
struct SignatureData {
|
|
|
|
let nonce: UUID
|
|
let signature: String
|
|
let timestamp: Int
|
|
|
|
}
|
|
|
|
let keyIdentifier: String
|
|
let offerIdentifier: String
|
|
let productIdentifier: String
|
|
let signatureData: SignatureData?
|
|
let signatureError: ErrorResponse?
|
|
|
|
}
|
|
|
|
let offers: [Offer]
|
|
}
|
|
|
|
extension PostOfferResponse.Offer.SignatureData: Decodable {}
|
|
extension PostOfferResponse.Offer: Decodable {
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
|
case keyIdentifier = "keyId"
|
|
case offerIdentifier = "offerId"
|
|
case productIdentifier = "productId"
|
|
case signatureError
|
|
case signatureData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extension PostOfferResponse: Decodable {}
|
|
extension PostOfferResponse: HTTPResponseBody {}
|