Skip to content

Commit

Permalink
Merge pull request #4 from AvdLee/master
Browse files Browse the repository at this point in the history
Add additional certficate types (AvdLee#105)
  • Loading branch information
DechengMa authored Jun 11, 2020
2 parents e3a5e2b + 5a6ea3b commit 65d95d0
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AppStoreConnect-Swift-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AppStoreConnect-Swift-SDK'
s.version = '1.1.1'
s.version = '1.1.2'
s.summary = 'The Swift SDK to work with the App Store Connect API from Apple.'

s.description = <<-DESC
Expand Down
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### 1.1.2
- Return Response instead of Void for "Sales and Finance Reports" endpoints ([#100](https://github.com/AvdLee/appstoreconnect-swift-sdk/issues/100)) via [@DechengMa](https://github.com/DechengMa)
- Add public init to CapabilitySetting and CapabilityOption ([#106](https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/106)) via [@DechengMa](https://github.com/DechengMa)
- Add paging to listProfiles endpoint ([#107](https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/107)) via [@DechengMa](https://github.com/DechengMa)
- List/Read Certificates fails to parse response. ([#104](https://github.com/AvdLee/appstoreconnect-swift-sdk/issues/104)) via [@orj](https://github.com/orj)
- Merge release 1.1.1 into master ([#99](https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/99)) via [@SwiftLeeBot](https://github.com/SwiftLeeBot)

### 1.1.1
- Fix Prerelease Versions filter ([#98](https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/98)) via [@orj](https://github.com/orj)
- Merge release 1.1.0 into master ([#97](https://github.com/AvdLee/appstoreconnect-swift-sdk/pull/97)) via [@SwiftLeeBot](https://github.com/SwiftLeeBot)
Expand Down
4 changes: 4 additions & 0 deletions Sources/APIProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ private extension APIProvider {
return .failure(Error.requestFailure(response.statusCode, response.data))
}

if let data = data as? T {
return .success(data)
}

do {
let decodedValue = try Self.jsonDecoder.decode(T.self, from: data)
return .success(decodedValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ extension APIEndpoint where T == ProfilesResponse {
filter: [Profiles.Filter]? = nil,
include: [Profiles.Include]? = nil,
sort: [Profiles.Sort]? = nil,
limit: [Profiles.Limit]? = nil) -> APIEndpoint {
limit: [Profiles.Limit]? = nil,
next: PagedDocumentLinks? = nil) -> APIEndpoint {

var parameters = [String: Any]()
if let fields = fields { parameters.add(fields) }
if let filter = filter { parameters.add(filter) }
if let include = include { parameters.add(include) }
if let sort = sort { parameters.add(sort) }
if let limit = limit { parameters.add(limit) }
if let nextCursor = next?.nextCursor { parameters["cursor"] = nextCursor }

return APIEndpoint(
path: "profiles",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// Created by Pascal Edmond on 30/11/2018.
//

extension APIEndpoint where T == Void {
import Foundation

extension APIEndpoint where T == Data {

/// Download finance reports filtered by your specified criteria.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// Created by Pascal Edmond on 30/11/2018.
//

extension APIEndpoint where T == Void {
import Foundation

extension APIEndpoint where T == Data {

/// Download sales and trends reports filtered by your specified criteria.
///
Expand Down
16 changes: 16 additions & 0 deletions Sources/Models/CapabilityOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@ public struct CapabilityOption: Codable {
public let key: CapabilityOptionKey?
public let name: String?
public let supportsWildcard: Bool?

public init(
description: String? = nil,
enabled: Bool? = nil,
enabledByDefault: Bool? = nil,
key: CapabilityOptionKey? = nil,
name: String? = nil,
supportsWildcard: Bool? = nil
) {
self.description = description
self.enabled = enabled
self.enabledByDefault = enabledByDefault
self.key = key
self.name = name
self.supportsWildcard = supportsWildcard
}
}
20 changes: 20 additions & 0 deletions Sources/Models/CapabilitySetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,24 @@ public struct CapabilitySetting: Codable {
public let options: [CapabilityOption]?
public let visible: Bool?
public let minInstances: Int?

public init(
allowedInstances: CapabilitySettingAllowedInstances? = nil,
description: String? = nil,
enabledByDefault: Bool? = nil,
key: CapabilitySettingKey? = nil,
name: String? = nil,
options: [CapabilityOption]? = nil,
visible: Bool? = nil,
minInstances: Int? = nil
) {
self.allowedInstances = allowedInstances
self.description = description
self.enabledByDefault = enabledByDefault
self.key = key
self.name = name
self.options = options
self.visible = visible
self.minInstances = minInstances
}
}
2 changes: 2 additions & 0 deletions Sources/Models/CertificateType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

public enum CertificateType: String, Codable {
case development = "DEVELOPMENT" // undocumented
case distribution = "DISTRIBUTION" // undocumented
case iOSDevelopment = "IOS_DEVELOPMENT"
case iOSDistribution = "IOS_DISTRIBUTION"
case macAppDistribution = "MAC_APP_DISTRIBUTION"
Expand Down
14 changes: 14 additions & 0 deletions Tests/APIProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,18 @@ final class APIProviderTests: XCTestCase {
XCTAssertTrue(result.isFailure)
}
}

func testRequestWithDataResultSuccess() {
let response = Response(statusCode: 200, data: Data(base64Encoded: ""))
let mockRequestExecutor = MockRequestExecutor(expectedResponse: Result.success(response))

let apiProvider = APIProvider(configuration: configuration, requestExecutor: mockRequestExecutor)
let resourceLink = ResourceLinks<Data>(self: URL(string: "https://api.appstoreconnect.com?cursor=FIRST")!)
apiProvider.request(resourceLink) { result in
// using the mock request executor the block is called sync
XCTAssertTrue(result.isSuccess)
XCTAssertEqual(result.value!, Data(base64Encoded: ""))
XCTAssertNotEqual(result.value!, Data(base64Encoded: "foo"))
}
}
}

0 comments on commit 65d95d0

Please sign in to comment.