Skip to content

Commit

Permalink
Merge pull request #2 from stealmh/1.1.0
Browse files Browse the repository at this point in the history
fix: 접근제어 수정
  • Loading branch information
stealmh authored Nov 30, 2023
2 parents 1eaa423 + 431d2f9 commit 46121c8
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Sources/CuteNetwork/Cute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import Foundation

class Cute<EndPoint: EndPointType>: NSObject, NetworkRouter, URLSessionDelegate {
open class Cute<EndPoint: EndPointType>: NSObject, NetworkRouter, URLSessionDelegate {
/// Properties
private var task: URLSessionTask?
/// petit(_ root: EndPoint, petitLogVisible: Bool) async throws -> Data 함수를 통해 받은 Data를 파싱해주는 함수입니다.
func petit<T: Decodable>(_ root: EndPoint, petitLogVisible: Bool = true) async throws -> T {
open func petit<T: Decodable>(_ root: EndPoint, petitLogVisible: Bool = true) async throws -> T {
do {
let result = try await petit(root, petitLogVisible: petitLogVisible)

Expand All @@ -28,7 +28,7 @@ class Cute<EndPoint: EndPointType>: NSObject, NetworkRouter, URLSessionDelegate
}
/// petit(_ route: EndPoint, logAccess: Bool, completion: @escaping NetworkRouterCompletion)를 받아
/// 에러, 데이터를 넘겨주는 함수, 정상일 경우 Data를 반환합니다.
func petit(_ root: EndPoint, petitLogVisible: Bool) async throws -> Data {
open func petit(_ root: EndPoint, petitLogVisible: Bool) async throws -> Data {
return try await withCheckedThrowingContinuation({ value in
petit(root, logAccess: petitLogVisible) { data, response, error in
if let error {
Expand All @@ -55,7 +55,7 @@ class Cute<EndPoint: EndPointType>: NSObject, NetworkRouter, URLSessionDelegate
})
}
/// dataTask를 걸친 데이터 까지 넘겨주는 역할
func petit(_ route: EndPoint, logAccess: Bool, completion: @escaping NetworkRouterCompletion) {
open func petit(_ route: EndPoint, logAccess: Bool, completion: @escaping NetworkRouterCompletion) {
guard Reachability.isConnectedToNetwork() else {
completion(nil, nil, NetworkError.noConnectionToInternet)
return
Expand All @@ -78,7 +78,7 @@ class Cute<EndPoint: EndPointType>: NSObject, NetworkRouter, URLSessionDelegate
self.task?.resume()
}

func cancel() {
open func cancel() {
self.task?.cancel()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CuteNetwork/Encodable+parameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

extension Encodable {
var toParameter: [String: Any]? {
public var toParameter: [String: Any]? {
guard let object = try? JSONEncoder().encode(self) else { return nil }
guard let dictionary = try? JSONSerialization.jsonObject(with: object, options: [])
as? [String: Any] else { return nil }
Expand Down
2 changes: 1 addition & 1 deletion Sources/CuteNetwork/EndPointType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
public typealias Parameters = [String: Any]
public typealias HTTPHeaders = [String: String]
/// EndPointType
protocol EndPointType {
public protocol EndPointType {
var baseURL: URL { get }
var path: String { get }
var httpMethod: HTTPMethod { get }
Expand Down
2 changes: 1 addition & 1 deletion Sources/CuteNetwork/NetworkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum NetworkError: Error {
case paging
case custom(message: String)

var errorMessage: String {
public var errorMessage: String {
switch self {
case .parametersNil:
return "파라미터가 nil 입니다."
Expand Down
3 changes: 1 addition & 2 deletions Sources/CuteNetwork/NetworkLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

class NetworkLogger {
open class NetworkLogger {

static func log(request: URLRequest) {

Expand All @@ -17,7 +17,6 @@ class NetworkLogger {
let method = request.httpMethod != nil ? "\(request.httpMethod ?? "")" : ""
let path = "\(urlComponents?.path ?? "")"
let query = "\(urlComponents?.query ?? "")"
let host = "\(urlComponents?.host ?? "")"

var bodyLog: String = ""

Expand Down
2 changes: 1 addition & 1 deletion Sources/CuteNetwork/ResponseHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

class ResponseHandler {
open class ResponseHandler {

enum NetworkResponse: String {
case success
Expand Down
1 change: 0 additions & 1 deletion Tests/CuteNetworkTests/CuteNetworkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ final class CuteNetworkTests: XCTestCase {

let cute = Cute<MockEndpoint>()
do {
let a = try await cute.petit(.test, petitLogVisible: false)
// XCTAssertNotEqual(a, Data())
} catch {
print("error: \(error)")
Expand Down

0 comments on commit 46121c8

Please sign in to comment.