From 99339647cbc3fecc67ef03a8ea4f793319f7af55 Mon Sep 17 00:00:00 2001 From: PiplaniVinay Date: Wed, 10 Jul 2024 13:11:23 +0530 Subject: [PATCH 1/2] Used Alpha Version Used Alpha Version --- AlfrescoAuth/AlfrescoAuth.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AlfrescoAuth/AlfrescoAuth.podspec b/AlfrescoAuth/AlfrescoAuth.podspec index fa994bb..d8058dc 100644 --- a/AlfrescoAuth/AlfrescoAuth.podspec +++ b/AlfrescoAuth/AlfrescoAuth.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'AlfrescoAuth' -s.version = '0.2.0' +s.version = '0.2.0-A1' s.summary = 'Alfresco Auth iOS Swift API' s.homepage = 'https://github.com/Alfresco/alfresco-ios-swift-api' s.author = {'Alfresco' => 'mobile.alfresco@alfresco.com' } From 02569ad8bd3664da6a697250941928096ca5b666 Mon Sep 17 00:00:00 2001 From: PiplaniVinay Date: Mon, 23 Sep 2024 16:11:24 +0530 Subject: [PATCH 2/2] ADST-583 * Implemented the configuration JSON API integration. * Added the model for parsing the JSON data. * Defined the MenuId enum for handling menu actions. * Updated the version number. --- AlfrescoContent/AlfrescoContent.podspec | 2 +- .../Classes/Swaggers/MobileConfigApi.swift | 36 +++++++++++++ .../Classes/Swaggers/MobileConfigData.swift | 53 +++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigApi.swift create mode 100644 AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigData.swift diff --git a/AlfrescoContent/AlfrescoContent.podspec b/AlfrescoContent/AlfrescoContent.podspec index 65bf275..cb1571e 100644 --- a/AlfrescoContent/AlfrescoContent.podspec +++ b/AlfrescoContent/AlfrescoContent.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.14' s.tvos.deployment_target = '12.0' s.swift_version = '5.0' - s.version = '0.2.66' + s.version = '0.2.67' s.source = {:git => 'https://github.com/Alfresco/alfresco-ios-swift-api.git', :tag => 'content/'+s.version.to_s} s.authors = {'Alfresco' => 'mobile.alfresco@alfresco.com'} s.license = {:type => 'Apache License Version 2.0', :file => 'AlfrescoContent/LICENSE.md'} diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigApi.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigApi.swift new file mode 100644 index 0000000..0ddf1da --- /dev/null +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigApi.swift @@ -0,0 +1,36 @@ +// +// MobileConfigApi.swift +// AlfrescoContent +// +// Created by Vinay Piplani on 11/09/24. +// + +import Foundation + +open class MobileConfigApi: NSObject { + + open class func getMobileConfig(appConfig: String,withCallback completion: @escaping ((_ data: MobileConfigData?,_ error: Error?) -> Void)) { + self.mobileConfig(appConfig: appConfig).execute { response, error in + completion(response?.body, error) + } + } + + /** + - GET Config Json + This API is used to fetch list of menu. This is GET request + */ + class func mobileConfig(appConfig: String) -> RequestBuilder { + let URLString = AlfrescoContentAPI.hostname + appConfig + let parameters: [String:Any]? = nil + let requestBuilder: RequestBuilder.Type = AlfrescoContentAPI.requestBuilderFactory.getBuilder() + // Create the request and set the appropriate headers + let urlRequest = requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false) + + // Set cache-control headers to force fetching the fresh data + urlRequest.addHeader(name: "Cache-Control", value: "no-cache, no-store, must-revalidate") + urlRequest.addHeader(name: "Pragma", value: "no-cache") + urlRequest.addHeader(name: "Expires", value: "0") + + return urlRequest + } +} diff --git a/AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigData.swift b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigData.swift new file mode 100644 index 0000000..32263ef --- /dev/null +++ b/AlfrescoContent/AlfrescoContent/Classes/Swaggers/MobileConfigData.swift @@ -0,0 +1,53 @@ +// +// MobileConfigData.swift +// AlfrescoContent +// +// Created by Vinay Piplani on 11/09/24. +// + +import Foundation + +// Enum for menu IDs +public enum MenuId: String, Codable { + case addFavorite = "app.menu.addFavourite" + case removeFavorite = "app.menu.removeFavourite" + case rename = "app.menu.rename" + case move = "app.menu.move" + case openWith = "app.menu.openWith" + case download = "app.menu.download" + case trash = "app.menu.trash" + case addOffline = "app.menu.addOffline" + case removeOffline = "app.menu.removeOffline" + case restore = "app.menu.restore" + case permanentlyDelete = "app.menu.permanentlyDelete" + case startProcess = "app.menu.startProcess" + + // Fallback for unknown values + case unknown + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let rawValue = try container.decode(String.self) + self = MenuId(rawValue: rawValue) ?? .unknown + } +} + +// MARK: - AppConfig +public struct MobileConfigData: Codable { + public let featuresMobile: Features + + public enum CodingKeys: String, CodingKey { + case featuresMobile = "features_mobile" + } +} + +// MARK: - Features +public struct Features: Codable { + public let menu: [Menu] +} + +// MARK: - DynamicMenu +public struct Menu: Codable { + public let id: MenuId + public let enabled: Bool +}