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

More App Store Version Localization APIs/models. #139

Merged
merged 9 commits into from
May 10, 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
224 changes: 214 additions & 10 deletions AppStoreConnect-Swift-SDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Foundation

public extension APIEndpoint where T == AppStoreVersionLocalizationResponse {
static func create(
appStoreVersionLocalizationForVersionWithId versionId: String,
locale: String,
description: String? = nil,
keywords: String? = nil,
marketingUrl: URL? = nil,
promotionalText: String? = nil,
supportUrl: URL? = nil,
whatsNew: String? = nil
) -> APIEndpoint {
let request = AppStoreVersionLocalizationCreateRequest(
appStoreVersionId: versionId,
locale: locale,
description: description,
keywords: keywords,
marketingUrl: marketingUrl,
promotionalText: promotionalText,
supportUrl: supportUrl,
whatsNew: whatsNew
)
return APIEndpoint(
path: "appStoreVersionLocalizations",
method: .post,
parameters: nil,
body: try? JSONEncoder().encode(request)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

public extension APIEndpoint where T == Void {
static func delete(appStoreVersionLocalizationWithId id: String) -> APIEndpoint {
return APIEndpoint(path: "appStoreVersionLocalizations/\(id)", method: .delete, parameters: nil)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import Foundation

public extension APIEndpoint where T == AppPreviewSetsResponse {
static func appPreviewSets(
forAppStoreVersionLocalization id: String,
fields: [ListAppPreviewSetsForAppStoreVersionLocalization.Field]? = nil,
includes: [ListAppPreviewSetsForAppStoreVersionLocalization.Include]? = nil,
limit: Int? = nil
) -> APIEndpoint {
var parameters = [String: Any]()
if let fields = fields { parameters.add(fields) }
if let includes = includes { parameters.add(includes) }
if let limit = limit { parameters["limit"] = limit }
return APIEndpoint(
path: "appStoreVersions/\(id)/appPreviewSets",
method: .get,
parameters: parameters
)
}
}

public enum ListAppPreviewSetsForAppStoreVersionLocalization {
public enum Field: NestableQueryParameter {
case appPreviewSets([AppPreviewSets])
case appPreviews([AppPreviews])
case appStoreVersionLocalizations([AppStoreVersionLocalizations])
case previewType([PreviewType])

static var key: String = "fields"
var pair: Pair {
switch self {
case let .appPreviewSets(value):
return (AppPreviewSets.key, value.map { $0.pair.value }.joinedByCommas())

case let .appPreviews(value):
return (AppPreviews.key, value.map { $0.pair.value }.joinedByCommas())

case let .appStoreVersionLocalizations(value):
return (AppStoreVersionLocalizations.key, value.map { $0.pair.value }.joinedByCommas())

case let .previewType(value):
return (PreviewType.key, value.map { $0.pair.value }.joinedByCommas())
}
}
}

public enum Include: String, CaseIterable, NestableQueryParameter {
case appPreviews, appStoreVersionLocalization

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

public extension ListAppPreviewSetsForAppStoreVersionLocalization.Field {
enum AppPreviewSets: String, CaseIterable, NestableQueryParameter {
case appPreviews, appStoreVersionLocalization, previewType

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

enum AppPreviews: String, CaseIterable, NestableQueryParameter {
case appPreviewSet, assetDeliveryState, fileName, fileSize, mimeType, previewFrameTimeCode, previewImage,
sourceFileChecksum, uploadOperations, uploaded, videoUrl

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

enum AppStoreVersionLocalizations: String, CaseIterable, NestableQueryParameter {
case appPreviewSets, appScreenshotSets, appStoreVersion, description, keywords, locale, marketingUrl,
promotionalText, supportUrl, whatsNew

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

enum PreviewType: String, CaseIterable, NestableQueryParameter {
case iPhone6Point5Inch = "IPHONE_65"
case iPhone5Point8Inch = "IPHONE_58"
case iPhone5Point5Inch = "IPHONE_55"
case iPhone4Point7Inch = "IPHONE_47"
case iPhone4Inch = "IPHONE_40"
case iPhone3Point5Inch = "IPHONE_35"
case iPadPro3rdGen12Point9Inch = "IPAD_PRO_3GEN_129"
case iPadPro3rdGen11Inch = "IPAD_PRO_3GEN_11"
case iPadPro12Point9Inch = "IPAD_PRO_129"
case iPadPro10Point5Inch = "IPAD_105"
case iPadPro9Point7Inch = "IPAD_97"
case mac = "DESKTOP"
case appleWatchSeries4 = "WATCH_SERIES_4"
case appleWatchSeries3 = "WATCH_SERIES_3"
case appleTV = "APPLE_TV"

static var key: String = "previewType"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import Foundation

public extension APIEndpoint where T == AppScreenshotSetsResponse {
static func appScreenshotSets(
forAppStoreVersionLocalization id: String,
fields: [ListAppScreenshotSetsForAppStoreVersionLocalization.Field]? = nil,
includes: [ListAppScreenshotSetsForAppStoreVersionLocalization.Include]? = nil,
limit: Int? = nil
) -> APIEndpoint {
var parameters = [String: Any]()
if let fields = fields { parameters.add(fields) }
if let includes = includes { parameters.add(includes) }
if let limit = limit { parameters["limit"] = limit }
return APIEndpoint(
path: "appStoreVersions/\(id)/appScreenshotSets",
method: .get,
parameters: parameters
)
}
}

public enum ListAppScreenshotSetsForAppStoreVersionLocalization {
public enum Field: NestableQueryParameter {
case appScreenshotSets([AppScreenshotSets])
case appScreenshots([AppScreenshots])
case appStoreVersionLocalizations([AppStoreVersionLocalizations])
case screenshotDisplayType([ScreenshotDisplayType])

static var key: String = "fields"
var pair: Pair {
switch self {
case let .appScreenshotSets(value):
return (AppScreenshotSets.key, value.map { $0.pair.value }.joinedByCommas())

case let .appScreenshots(value):
return (AppScreenshots.key, value.map { $0.pair.value }.joinedByCommas())

case let .appStoreVersionLocalizations(value):
return (AppStoreVersionLocalizations.key, value.map { $0.pair.value }.joinedByCommas())

case let .screenshotDisplayType(value):
return (ScreenshotDisplayType.key, value.map { $0.pair.value }.joinedByCommas())
}
}
}

public enum Include: String, CaseIterable, NestableQueryParameter {
case appScreenshots, appStoreVersionLocalization

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

public extension ListAppScreenshotSetsForAppStoreVersionLocalization.Field {
enum AppScreenshotSets: String, CaseIterable, NestableQueryParameter {
case appScreenshots, appStoreVersionLocalization, screenshotDisplayType

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

enum AppScreenshots: String, CaseIterable, NestableQueryParameter {
case appScreenshotSet, assetDeliveryState, assetToken, assetType, fileName, fileSize, imageAsset,
sourceFileChecksum, uploadOperations, uploaded

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

enum AppStoreVersionLocalizations: String, CaseIterable, NestableQueryParameter {
case appPreviewSets, appScreenshotSets, appStoreVersion, description, keywords, locale, marketingUrl,
promotionalText, supportUrl, whatsNew

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

enum ScreenshotDisplayType: String, CaseIterable, NestableQueryParameter {
case iPhone6Point5Inch = "APP_IPHONE_65"
case iPhone5Point8Inch = "APP_IPHONE_58"
case iPhone5Point5Inch = "APP_IPHONE_55"
case iPhone4Point7Inch = "APP_IPHONE_47"
case iPhone4Inch = "APP_IPHONE_40"
case iPhone3Point5Inch = "APP_IPHONE_35"
case iPadPro3rdGen12Point9Inch = "APP_IPAD_PRO_3GEN_129"
case iPadPro3rdGen11Inch = "APP_IPAD_PRO_3GEN_11"
case iPadPro12Point9Inch = "APP_IPAD_PRO_129"
case iPadPro10Point5Inch = "APP_IPAD_105"
case iPadPro9Point7Inch = "APP_IPAD_97"
case mac = "APP_DESKTOP"
case appleWatchSeries4 = "APP_WATCH_SERIES_4"
case appleWatchSeries3 = "APP_WATCH_SERIES_3"
case appleTV = "APP_APPLE_TV"
case iPhone6Point5InchMessaging = "IMESSAGE_APP_IPHONE_65"
case iPhone5Point8InchMessaging = "IMESSAGE_APP_IPHONE_58"
case iPhone5Point5InchMessaging = "IMESSAGE_APP_IPHONE_55"
case iPhone4Point7InchMessaging = "IMESSAGE_APP_IPHONE_47"
case iPhone4InchMessaging = "IMESSAGE_APP_IPHONE_40"
case iPadPro3rdGen12Point9InchMessaging = "IMESSAGE_APP_IPAD_PRO_3GEN_129"
case iPadPro3rdGen11InchMessaging = "IMESSAGE_APP_IPAD_PRO_3GEN_11"
case iPadPro12Point9InchMessaging = "IMESSAGE_APP_IPAD_PRO_129"
case iPadPro10Point5InchMessaging = "IMESSAGE_APP_IPAD_105"
case iPadPro9Point7InchMessaging = "IMESSAGE_APP_IPAD_97"

static var key: String = "screenshotDisplayType"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation

public extension APIEndpoint where T == AppStoreVersionLocalizationResponse {
static func modify(
appStoreVersionLocalizationWithId id: String,
description: String? = nil,
keywords: String? = nil,
marketingUrl: URL? = nil,
promotionalText: String? = nil,
supportUrl: URL? = nil,
whatsNew: String? = nil
) -> APIEndpoint {
let request = AppStoreVersionLocalizationUpdateRequest(
id: id,
description: description,
keywords: keywords,
marketingUrl: marketingUrl,
promotionalText: promotionalText,
supportUrl: supportUrl,
whatsNew: whatsNew
)
return APIEndpoint(
path: "appStoreVersionLocalizations/\(id)",
method: .patch,
parameters: nil,
body: try? JSONEncoder().encode(request)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import Foundation

public extension APIEndpoint where T == AppStoreVersionLocalization {
static func appStoreVersionLocalization(
withId id: String,
fields: [ReadAppStoreVersionLocalizationInformation.Field]? = nil,
include: [ReadAppStoreVersionLocalizationInformation.Include]? = nil,
limits: [ReadAppStoreVersionLocalizationInformation.Limit]? = nil
) -> APIEndpoint {
var parameters = [String: Any]()
if let fields = fields { parameters.add(fields) }
if let include = include { parameters.add(include) }
if let limits = limits { parameters.add(limits) }
return APIEndpoint(
path: "appStoreVersionLocalizations/\(id)",
method: .get,
parameters: parameters
)
}
}

public enum ReadAppStoreVersionLocalizationInformation {
public enum Field: NestableQueryParameter {
case appPreviewSets([Field.AppPreviewSet])
case appScreenshotSets([Field.AppScreenshotSet])
case appStoreVersionLocalizations([Field.AppStoreVersionLocalization])

static var key: String = "fields"
var pair: Pair {
switch self {
case let .appPreviewSets(value):
return (Field.AppPreviewSet.key, value.map { $0.pair.value }.joinedByCommas())
case let .appScreenshotSets(value):
return (Field.AppScreenshotSet.key, value.map { $0.pair.value }.joinedByCommas())
case let .appStoreVersionLocalizations(value):
return (Field.AppStoreVersionLocalization.key, value.map { $0.pair.value }.joinedByCommas())
}
}
}

public enum Include: String, CaseIterable, NestableQueryParameter {
case appPreviewSets
case appScreenshotSets
case appStoreVersion

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

public enum Limit: NestableQueryParameter {
/// Maximum: 50
case appPreviewSets(Int)

/// Maximum: 50
case appScreenshotSets(Int)

static var key: String = "limit"
var pair: Pair {
switch self {
case let .appPreviewSets(value):
return ("appPreviewSets", "\(value)")
case let .appScreenshotSets(value):
return ("appScreenshotSets", "\(value)")
}
}
}
}

public extension ReadAppStoreVersionLocalizationInformation.Field {
enum AppPreviewSet: String, CaseIterable, NestableQueryParameter {
case appPreviews, appStoreVersionLocalization, previewType

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

enum AppScreenshotSet: String, CaseIterable, NestableQueryParameter {
case appScreenshots, appStoreVersionLocalization, screenshotDisplayType

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

enum AppStoreVersionLocalization: String, CaseIterable, NestableQueryParameter {
case appPreviewSets, appScreenshotSets, appStoreVersion, description, keywords, locale, marketingUrl,
promotionalText, supportUrl, whatsNew

static var key: String = "appStoreVersionLocalizations"
var pair: NestableQueryParameter.Pair { return (nil, rawValue) }
}
}
7 changes: 7 additions & 0 deletions Sources/Models/AppMediaAssetState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

public struct AppMediaAssetState: Codable {
public let errors: [AppMediaStateError]?
public let state: String?
public let warnings: [AppMediaStateError]?
}
6 changes: 6 additions & 0 deletions Sources/Models/AppMediaStateError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public struct AppMediaStateError: Codable {
public let code: String?
public let description: String?
}
Loading