Skip to content

Commit a42d39c

Browse files
authored
Merge pull request #18 from jennifer-starratt/master
Consider the status code when determining success/failure
2 parents 94fa42b + f7ed21e commit a42d39c

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.1.2] - 2020-02-17
8+
### Fixed
9+
- Decode errors within responses
10+
711
## [0.1.1] - 2020-01-31
812
### Fixed
913
- Module/class name collision which caused Failed to load module 'MailchimpSDK' error when integrating.

MailchimpSDK/MailchimpSDK.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428
GCC_WARN_UNUSED_FUNCTION = YES;
429429
GCC_WARN_UNUSED_VARIABLE = YES;
430430
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
431-
MARKETING_VERSION = 0.1.1;
431+
MARKETING_VERSION = 0.1.2;
432432
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
433433
MTL_FAST_MATH = YES;
434434
ONLY_ACTIVE_ARCH = YES;
@@ -488,7 +488,7 @@
488488
GCC_WARN_UNUSED_FUNCTION = YES;
489489
GCC_WARN_UNUSED_VARIABLE = YES;
490490
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
491-
MARKETING_VERSION = 0.1.1;
491+
MARKETING_VERSION = 0.1.2;
492492
MTL_ENABLE_DEBUG_INFO = NO;
493493
MTL_FAST_MATH = YES;
494494
SDKROOT = iphoneos;

MailchimpSDK/MailchimpSDK/Core/Networking/AnzeeAPI.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ struct AnzeeAPI: API {
156156
} else {
157157
completionBlock(.failure(.requestError(err: err)))
158158
}
159+
} else if let jsonData = data, let errorResponse = try? JSONDecoder().decode(APIErrorResponse.self, from: jsonData) {
160+
completionBlock(.failure(.apiError(response: errorResponse)))
161+
} else if let httpResponse = response as? HTTPURLResponse, !(200..<300).contains(httpResponse.statusCode) {
162+
completionBlock(.failure(.apiError(response: APIErrorResponse(status: 0, type: "Unexpected response", detail: ""))))
159163
} else if let jsonData = data {
160164
completionBlock(.success(jsonData))
161165
} else {

MailchimpSDK/MailchimpSDK/SDK/MailchimpSDK.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class MailchimpSDK: NSObject {
2929
public static var debugMode: Bool = false
3030

3131
/// Version of this SDK.
32-
public static let version: String = "0.1.1"
32+
public static let version: String = "0.1.2"
3333

3434
/// The API protocol conforming object that processes requests for this class.
3535
static var api: API?

0 commit comments

Comments
 (0)