diff --git a/Changelog.md b/Changelog.md index 5dcf092..ee1ee6c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.3] - 2021-02-16 +### Fixed +- API error response parsing + ## [2.0.2] - 2020-11-19 ### Added - Swift Package Support diff --git a/MailchimpSDK.podspec b/MailchimpSDK.podspec index e8acbc1..4ba8d90 100644 --- a/MailchimpSDK.podspec +++ b/MailchimpSDK.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'MailchimpSDK' - s.version = '2.0.2' + s.version = '2.0.3' s.summary = 'Mailchimp SDK for iOS' s.description = <<-DESC diff --git a/Sources/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj b/Sources/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj index 770a127..7833c3c 100644 --- a/Sources/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj +++ b/Sources/MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj @@ -512,7 +512,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.3; PRODUCT_BUNDLE_IDENTIFIER = com.theRocketScienceGroup.MailchimpSDK; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -541,7 +541,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.3; PRODUCT_BUNDLE_IDENTIFIER = com.theRocketScienceGroup.MailchimpSDK; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -561,7 +561,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.3; PRODUCT_BUNDLE_IDENTIFIER = "com.theRocketScienceGroup.Mailchimp-SDKTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -580,7 +580,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.3; PRODUCT_BUNDLE_IDENTIFIER = "com.theRocketScienceGroup.Mailchimp-SDKTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/APIErrorResponse.swift b/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/APIErrorResponse.swift index ef518ad..0163e1e 100755 --- a/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/APIErrorResponse.swift +++ b/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/APIErrorResponse.swift @@ -19,7 +19,8 @@ import Foundation /// Basic struct to parse any possible API error responses public struct APIErrorResponse: Codable { + public let title: String? public let status: Int - public let type: String - public let detail: String + public let type: String? + public let detail: String? } diff --git a/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift b/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift index f601ab2..53e277e 100755 --- a/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift +++ b/Sources/MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift @@ -159,7 +159,10 @@ struct AnzeeAPI: API { } else if let jsonData = data, let errorResponse = try? JSONDecoder().decode(APIErrorResponse.self, from: jsonData) { completionBlock(.failure(.apiError(response: errorResponse))) } else if let httpResponse = response as? HTTPURLResponse, !(200..<300).contains(httpResponse.statusCode) { - completionBlock(.failure(.apiError(response: APIErrorResponse(status: 0, type: "Unexpected response", detail: "")))) + completionBlock(.failure(.apiError(response: APIErrorResponse(title: nil, + status: httpResponse.statusCode, + type: "Unexpected response", + detail: nil)))) } else if let jsonData = data { completionBlock(.success(jsonData)) } else {