Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Read Beta Group Information and update to match Apple's docs #142

Merged
merged 7 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,30 @@ public enum ReadBetaGroupInformation {
extension ReadBetaGroupInformation.Field {

public enum App: String, CaseIterable, NestableQueryParameter {
case betaAppLocalizations, betaAppReviewDetail, betaGroups, betaLicenseAgreement, betaTesters, builds, bundleId, name, preReleaseVersions, primaryLocale, sku
case appInfos, appStoreVersions, availableInNewTerritories, availableTerritories, betaAppLocalizations, betaAppReviewDetail, betaGroups, betaLicenseAgreement, betaTesters, builds, bundleId, contentRightsDeclaration, endUserLicenseAgreement, gameCenterEnabledVersions, inAppPurchases, isOrEverWasMadeForKids, name, perfPowerMetrics, preOrder, preReleaseVersions, prices, primaryLocale, sku

static var key: String = "app"
static var key: String = "apps"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}

public enum BetaGroup: String, CaseIterable, NestableQueryParameter {
case app, betaTesters, builds, createdDate, isInternalGroup, name, publicLink, publicLinkEnabled, publicLinkId, publicLinkLimit, publicLinkLimitEnabled
case app, betaTesters, builds, createdDate, feedbackEnabled, isInternalGroup, name, publicLink, publicLinkEnabled, publicLinkId, publicLinkLimit, publicLinkLimitEnabled

static var key: String = "betaGroup"
static var key: String = "betaGroups"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}

public enum BetaTester: String, CaseIterable, NestableQueryParameter {
case apps, betaGroups, builds, email, firstName, inviteType, lastName

static var key: String = "betaTester"
static var key: String = "betaTesters"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}

public enum Build: String, CaseIterable, NestableQueryParameter {
case app, appEncryptionDeclaration, betaAppReviewSubmission, betaBuildLocalizations, betaGroups, buildBetaDetail, expirationDate, expired, iconAssetToken, individualTesters, minOsVersion, preReleaseVersion, processingState, uploadedDate, usesNonExemptEncryption, version
case app, appEncryptionDeclaration, appStoreVersion, betaAppReviewSubmission, betaBuildLocalizations, betaGroups, buildBetaDetail, diagnosticSignatures, expirationDate, expired, iconAssetToken, icons, individualTesters, minOsVersion, perfPowerMetrics, preReleaseVersion, processingState, uploadedDate, usesNonExemptEncryption, version

static var key: String = "build"
static var key: String = "builds"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,132 @@ import XCTest
@testable import AppStoreConnect_Swift_SDK

final class ReadBetaGroupInformationTests: XCTestCase {

func testURLRequest() {

// MARK: - Fields

func test_fields_apps() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: [.apps(ReadBetaGroupInformation.Field.App.allCases)],
include: nil,
limit: nil)

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?fields%5Bapps%5D=appInfos%2CappStoreVersions%2CavailableInNewTerritories%2CavailableTerritories%2CbetaAppLocalizations%2CbetaAppReviewDetail%2CbetaGroups%2CbetaLicenseAgreement%2CbetaTesters%2Cbuilds%2CbundleId%2CcontentRightsDeclaration%2CendUserLicenseAgreement%2CgameCenterEnabledVersions%2CinAppPurchases%2CisOrEverWasMadeForKids%2Cname%2CperfPowerMetrics%2CpreOrder%2CpreReleaseVersions%2Cprices%2CprimaryLocale%2Csku"
XCTAssertEqual(absoluteString, expected)
}

func test_fields_betaGroups() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: [.apps(ReadBetaGroupInformation.Field.App.allCases),
.betaGroups(ReadBetaGroupInformation.Field.BetaGroup.allCases),
.betaTesters(ReadBetaGroupInformation.Field.BetaTester.allCases),
.builds(ReadBetaGroupInformation.Field.Build.allCases)],
fields: [.betaGroups(ReadBetaGroupInformation.Field.BetaGroup.allCases)],
include: nil,
limit: nil)

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?fields%5BbetaGroups%5D=app%2CbetaTesters%2Cbuilds%2CcreatedDate%2CfeedbackEnabled%2CisInternalGroup%2Cname%2CpublicLink%2CpublicLinkEnabled%2CpublicLinkId%2CpublicLinkLimit%2CpublicLinkLimitEnabled"
XCTAssertEqual(absoluteString, expected)
}

func test_fields_betaTesters() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: [.betaTesters(ReadBetaGroupInformation.Field.BetaTester.allCases)],
include: nil,
limit: nil)

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?fields%5BbetaTesters%5D=apps%2CbetaGroups%2Cbuilds%2Cemail%2CfirstName%2CinviteType%2ClastName"
XCTAssertEqual(absoluteString, expected)
}

func test_fields_builds() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: [.builds(ReadBetaGroupInformation.Field.Build.allCases)],
include: nil,
limit: nil)

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?fields%5Bbuilds%5D=app%2CappEncryptionDeclaration%2CappStoreVersion%2CbetaAppReviewSubmission%2CbetaBuildLocalizations%2CbetaGroups%2CbuildBetaDetail%2CdiagnosticSignatures%2CexpirationDate%2Cexpired%2CiconAssetToken%2Cicons%2CindividualTesters%2CminOsVersion%2CperfPowerMetrics%2CpreReleaseVersion%2CprocessingState%2CuploadedDate%2CusesNonExemptEncryption%2Cversion"
XCTAssertEqual(absoluteString, expected)
}

// MARK: - Include

func test_include_all() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: nil,
include: ReadBetaGroupInformation.Include.allCases,
limit: [.betaTesters(2),
.builds(1)])

limit: nil)

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?include=app%2CbetaTesters%2Cbuilds"
XCTAssertEqual(absoluteString, expected)
}

// MARK: - Limits

func test_limit_builds() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: nil,
include: nil,
limit: [.builds(5)])

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?limit%5Bbuilds%5D=5"
XCTAssertEqual(absoluteString, expected)
}

func test_limit_betaTesters() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: nil,
include: nil,
limit: [.betaTesters(5)])

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")


let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?limit%5BbetaTesters%5D=5"
XCTAssertEqual(absoluteString, expected)
}

// MARK: - Combined

func test_combined() {
let endpoint = APIEndpoint.betaGroup(
withId: "betaGroupId",
fields: [.betaGroups([.betaTesters])],
include: [.app],
limit: [.builds(2), .betaTesters(5)])

let request = try? endpoint.asURLRequest()
XCTAssertEqual(request?.httpMethod, "GET")

let absoluteString = request?.url?.absoluteString
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?fields%5Bapp%5D=betaAppLocalizations%2CbetaAppReviewDetail%2CbetaGroups%2CbetaLicenseAgreement%2CbetaTesters%2Cbuilds%2CbundleId%2Cname%2CpreReleaseVersions%2CprimaryLocale%2Csku&fields%5BbetaGroup%5D=app%2CbetaTesters%2Cbuilds%2CcreatedDate%2CisInternalGroup%2Cname%2CpublicLink%2CpublicLinkEnabled%2CpublicLinkId%2CpublicLinkLimit%2CpublicLinkLimitEnabled&fields%5BbetaTester%5D=apps%2CbetaGroups%2Cbuilds%2Cemail%2CfirstName%2CinviteType%2ClastName&fields%5Bbuild%5D=app%2CappEncryptionDeclaration%2CbetaAppReviewSubmission%2CbetaBuildLocalizations%2CbetaGroups%2CbuildBetaDetail%2CexpirationDate%2Cexpired%2CiconAssetToken%2CindividualTesters%2CminOsVersion%2CpreReleaseVersion%2CprocessingState%2CuploadedDate%2CusesNonExemptEncryption%2Cversion&include=app%2CbetaTesters%2Cbuilds&limit%5BbetaTesters%5D=2&limit%5Bbuilds%5D=1"
let expected = "https://api.appstoreconnect.apple.com/v1/betaGroups/betaGroupId?fields%5BbetaGroups%5D=betaTesters&include=app&limit%5BbetaTesters%5D=5&limit%5Bbuilds%5D=2"
XCTAssertEqual(absoluteString, expected)
}
}