Files
purchases-ios/Sources/Logging/Strings/BackendErrorStrings.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

48 lines
1.5 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
//
// BackendErrorStrings.swift
//
// Created by Joshua Liebowitz on 10/26/21.
import Foundation
// swiftlint:disable identifier_name
enum BackendErrorStrings {
// Backend tried to instantiate a CustomerInfo but for some reason it couldn't.
case customer_info_instantiation_error(response: [String: Any]?)
// getOfferings response contained no offerings.
case offerings_response_no_offerings
// Posting offerIdForSigning failed due to a signature problem.
case signature_error(signatureDataString: Any?)
}
extension BackendErrorStrings: CustomStringConvertible {
var description: String {
switch self {
case .customer_info_instantiation_error(let response):
var message = "Login failed, unable to instantiate \(CustomerInfo.self)"
if let response = response {
message += " from:\n \(response.debugDescription)"
}
return message
case .offerings_response_no_offerings:
return "Offerings response contained no offerings"
case .signature_error(let signatureDataString):
return "Missing 'signatureData' or its structure changed:\n\(String(describing: signatureDataString))"
}
}
}