//
//  GetManualUrl.swift
//  Sailassist
//
//  Created by 三浦薫巳 on 2023/12/22.
//

import Foundation

class GetManualUrl {
    var sessionGetManualUrl = SessionGetManualUrl()

    func start() {
        print(debug: "called")
        sessionGetManualUrl.getManualUrl { response in
            switch response {
            case .success(let resultData):
                print(debug: String(data: resultData, encoding: .utf8) as Any)
                let serverSession = ServerSession()
                let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResGetManualUrl].self)
                if var res = resjson {
                    for index in res.indices {
                        let convert = res[index].path.replacingOccurrences(of: " ", with: "%20")
                        res[index].path = convert
                    }
                    SharingData.my.manualUrls = res
                }
            case .failure(let errorCode):
                print(debug: errorCode)
                break
            }
        }
    }
}
