Files
purchases-ios/Sources/Networking/Responses/PostOfferResponse.swift
T
NachoSoto 438e74e6cf PostOfferForSigningOperation: changed response parsing to using Decodable (#1573)
## 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!
2022-05-26 13:45:31 -07:00

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 {}