Skip to content

Commit

Permalink
Merge pull request #178 from Alfresco/ADST-583
Browse files Browse the repository at this point in the history
Adst 583
  • Loading branch information
PiplaniVinay authored Sep 23, 2024
2 parents 7f23928 + 02569ad commit 6a64e4b
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion AlfrescoContent/AlfrescoContent.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]'}
s.license = {:type => 'Apache License Version 2.0', :file => 'AlfrescoContent/LICENSE.md'}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MobileConfigData> {
let URLString = AlfrescoContentAPI.hostname + appConfig
let parameters: [String:Any]? = nil
let requestBuilder: RequestBuilder<MobileConfigData>.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
}
}
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 6a64e4b

Please sign in to comment.