-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the parsing of Profile responses (#95)
* Add include to listBundleIds request - Adds a test for this * Add .DS_Store to .gitignore * Set a default value for Certificate type * Add ProfileRelationship and fix ProfileResponse * Add additional test Models * Improve APIProvider's error reporting To make it easier to debug decoding failures * Fix ProfilesResponse property types * Expose jsonDecoder so it is usable in tests The custom date decoding is useful for testing * Add support for json fixture loading * Add Profiles fixtures to test response decoding * Add tests for decoding profiles and relationships * Remove debugging code * Fix lint issues Co-authored-by: Antoine van der Lee <[email protected]>
- Loading branch information
Showing
19 changed files
with
885 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// ProfileRelationship.swift | ||
// AppStoreConnect-Swift-SDK | ||
// | ||
// Created by Oliver Jones on 17/4/20. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum ProfileRelationship: Codable { | ||
case bundleId(BundleId) | ||
case certificate(Certificate) | ||
case device(Device) | ||
|
||
enum TypeKeys: String, CodingKey { | ||
case type | ||
} | ||
enum CodingKeys: String, Decodable, CodingKey { | ||
case bundleIds, certificates, devices | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let type = try decoder.container(keyedBy: TypeKeys.self).decode(CodingKeys.self, forKey: .type) | ||
switch type { | ||
case .bundleIds: | ||
self = try .bundleId(BundleId(from: decoder)) | ||
case .certificates: | ||
self = try .certificate(Certificate(from: decoder)) | ||
case .devices: | ||
self = try .device(Device(from: decoder)) | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
switch self { | ||
case .bundleId(let value): | ||
try value.encode(to: encoder) | ||
case .certificate(let value): | ||
try value.encode(to: encoder) | ||
case .device(let value): | ||
try value.encode(to: encoder) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Bundle+Tests.swift | ||
// AppStoreConnect-Swift-SDK | ||
// | ||
// Created by Oliver Jones on 17/4/20. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Bundle { | ||
static let tests = Bundle(for: BundleTag.self) | ||
} | ||
|
||
private final class BundleTag {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Fixture.swift | ||
// AppStoreConnect-Swift-SDK | ||
// | ||
// Created by Oliver Jones on 17/4/20. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Fixture { | ||
var data: Data | ||
|
||
init(named: String, in bundle: Bundle = .tests) throws { | ||
|
||
guard let url = bundle.url(forResource: named, withExtension: "json", subdirectory: "Fixtures.bundle") else { | ||
fatalError("Unable to find fixture named: \(named)") | ||
} | ||
try data = Data(contentsOf: url) | ||
} | ||
} |
Oops, something went wrong.