diff --git a/Changelog.md b/Changelog.md index a7856124..e22157fa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,5 @@ ## Changelog ### Next -- Updated CI to make sure PR requests are reviewed using Danger. \ No newline at end of file +- Updated CI to make sure PR requests are reviewed using Danger. +- Implemented endpoints to modify and remove Bundle IDs. diff --git a/Sources/Endpoints/Provisioning/Bundle IDs/ModifyBundleID.swift b/Sources/Endpoints/Provisioning/Bundle IDs/ModifyBundleID.swift new file mode 100644 index 00000000..7b1d6325 --- /dev/null +++ b/Sources/Endpoints/Provisioning/Bundle IDs/ModifyBundleID.swift @@ -0,0 +1,29 @@ +// +// ModifyBundleID.swift +// AppStoreConnect-Swift-SDK +// +// Created by Rui Costa on 30/12/2019. +// + +import Foundation + +extension APIEndpoint where T == BundleIdResponse { + + /// Update a specific bundle ID’s name + /// - Parameter id: the bundle ID's id + /// - Parameter name: the bundle ID's name + public static func modify( + bundleIdWithId id: String, + name: String) -> APIEndpoint { + + let request = BundleIdUpdateRequest(data: .init( + id: id, + attributes: .init(name: name))) + + return APIEndpoint( + path: "bundleIds/\(id)", + method: .patch, + parameters: nil, + body: try? JSONEncoder().encode(request)) + } +} diff --git a/Sources/Endpoints/Provisioning/Bundle IDs/RemoveBundleID.swift b/Sources/Endpoints/Provisioning/Bundle IDs/RemoveBundleID.swift new file mode 100644 index 00000000..693bff40 --- /dev/null +++ b/Sources/Endpoints/Provisioning/Bundle IDs/RemoveBundleID.swift @@ -0,0 +1,20 @@ +// +// RemoveBundleID.swift +// AppStoreConnect-Swift-SDK +// +// Created by Rui Costa on 30/12/2019. +// + +import Foundation + +extension APIEndpoint where T == Void { + + /// Delete a bundle ID that is used for app development. + /// - Parameter id: the bundle ID's id + public static func remove(bundleIdWithId id: String) -> APIEndpoint { + return APIEndpoint( + path: "bundleIds/\(id)", + method: .delete, + parameters: nil) + } +} diff --git a/Sources/Models/BundleIdUpdateRequest.swift b/Sources/Models/BundleIdUpdateRequest.swift new file mode 100644 index 00000000..6bafd674 --- /dev/null +++ b/Sources/Models/BundleIdUpdateRequest.swift @@ -0,0 +1,29 @@ +// +// BundleIdUpdateRequest.swift +// AppStoreConnect-Swift-SDK +// +// Created by Rui Costa on 30/12/2019. +// + +import Foundation + +/// A request containing a single resource. +public struct BundleIdUpdateRequest: Encodable { + + public struct Data: Encodable { + public let id: String + public let attributes: Attributes + public let type: String = "bundleIds" + } + + /// The resource data. + public let data: Data +} + +// MARK: BundleIdUpdateRequest.Data +extension BundleIdUpdateRequest.Data { + + public struct Attributes: Encodable { + public let name: String + } +}