Skip to content

Commit

Permalink
[Api] Added 'Network' and 'Endpoints' dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
LiarPrincess committed Feb 1, 2022
1 parent c380129 commit a41c650
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 31 deletions.
30 changes: 25 additions & 5 deletions Wroclive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
9093AE1724EA92C20094B1CC /* ExtraLightVisualEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9093AE1624EA92C20094B1CC /* ExtraLightVisualEffectView.swift */; };
909B7BA3251399AF00D8A8E0 /* ApiVehicleLocationsResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 909B7BA2251399AF00D8A8E0 /* ApiVehicleLocationsResponseTests.swift */; };
909B7BA92513A3A600D8A8E0 /* ApiLinesResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 909B7BA82513A3A600D8A8E0 /* ApiLinesResponseTests.swift */; };
909EF1B527A921E9000F4BAB /* NetworkType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 909EF1B427A921E9000F4BAB /* NetworkType.swift */; };
90A6262424FAB415005F5C31 /* LineSelectorTestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90A6262324FAB415005F5C31 /* LineSelectorTestData.swift */; };
90C5BAEE2514CB1900D41508 /* AppStoreScreenshots.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C5BAED2514CB1900D41508 /* AppStoreScreenshots.swift */; };
90CDCFCD24D60A0F00595D89 /* NSAttributedString+Replacements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90CDCFB824D60A0E00595D89 /* NSAttributedString+Replacements.swift */; };
Expand Down Expand Up @@ -348,6 +349,7 @@
909B7BA2251399AF00D8A8E0 /* ApiVehicleLocationsResponseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiVehicleLocationsResponseTests.swift; sourceTree = "<group>"; };
909B7BA625139B9700D8A8E0 /* ApiTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiTestCase.swift; sourceTree = "<group>"; };
909B7BA82513A3A600D8A8E0 /* ApiLinesResponseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiLinesResponseTests.swift; sourceTree = "<group>"; };
909EF1B427A921E9000F4BAB /* NetworkType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkType.swift; sourceTree = "<group>"; };
90A6262324FAB415005F5C31 /* LineSelectorTestData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineSelectorTestData.swift; sourceTree = "<group>"; };
90C5BAED2514CB1900D41508 /* AppStoreScreenshots.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreScreenshots.swift; sourceTree = "<group>"; };
90C7938E2510CC3C00279CF9 /* CardSnapshots.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardSnapshots.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -500,15 +502,12 @@
900EA10524D46F140054C03F /* Api */ = {
isa = PBXGroup;
children = (
909EF1B327A921B3000F4BAB /* Network */,
909EF1B227A92199000F4BAB /* Endpoints */,
900EA10624D46F140054C03F /* Api.swift */,
90F72F2D24E31A8600D20EB2 /* ApiType.swift */,
90F72F2F24E31AA400D20EB2 /* ApiError.swift */,
907FD0B824D8A2DC00B6896C /* OfflineApi.swift */,
900EA10724D46F140054C03F /* LinesEndpoint.swift */,
900EA10824D46F140054C03F /* VehicleLocationsEndpoint.swift */,
900EA10924D46F140054C03F /* Endpoint.swift */,
900EA11024D473E70054C03F /* Network.swift */,
900DCC1C24E7FEF7004F000D /* ReachabilityStatus.swift */,
902C018624F83BD7008F87B1 /* HTTPHeaders+init.swift */,
);
path = Api;
Expand Down Expand Up @@ -791,6 +790,26 @@
path = WrocliveTestsShared;
sourceTree = "<group>";
};
909EF1B227A92199000F4BAB /* Endpoints */ = {
isa = PBXGroup;
children = (
900EA10924D46F140054C03F /* Endpoint.swift */,
900EA10724D46F140054C03F /* LinesEndpoint.swift */,
900EA10824D46F140054C03F /* VehicleLocationsEndpoint.swift */,
);
path = Endpoints;
sourceTree = "<group>";
};
909EF1B327A921B3000F4BAB /* Network */ = {
isa = PBXGroup;
children = (
900EA11024D473E70054C03F /* Network.swift */,
909EF1B427A921E9000F4BAB /* NetworkType.swift */,
900DCC1C24E7FEF7004F000D /* ReachabilityStatus.swift */,
);
path = Network;
sourceTree = "<group>";
};
90A5FA6A24D588DA00EC24D6 /* Extensions */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1266,6 +1285,7 @@
90DE39EA24D8570900ADE4B9 /* MapViewController.swift in Sources */,
902C2FCE24FCF5C20010B019 /* UserDefaultsManager.swift in Sources */,
9013FAC924D721410006D1B9 /* Assets.swift in Sources */,
909EF1B527A921E9000F4BAB /* NetworkType.swift in Sources */,
9047996B24D575C500111F2C /* LoggingMiddleware.swift in Sources */,
907FD0BD24D99C3C00B6896C /* DispatchStoreUpdatesFromAppleFrameworks.swift in Sources */,
9076BD5924DDD26C00467075 /* LineTypeSegmentedControl.swift in Sources */,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,6 @@ import Foundation
import Alamofire
import PromiseKit

// MARK: - NetworkType

public protocol NetworkType {

/// Send network request.
func request(url: URLConvertible,
method: HTTPMethod,
parameters: Parameters?,
encoding: ParameterEncoding,
headers: HTTPHeaders?) -> Promise<Data>

/// Determine the status of a system's current network configuration and the
/// reachability of a target host.
///
/// A remote host is considered reachable when a data packet, sent by an
/// application into the network stack, can leave the local device.
/// Reachability does not guarantee that the data packet will actually be
/// received by the host.
func getReachabilityStatus() -> ReachabilityStatus

/// Show/hide network activity indicator (little circle in the upper left corner).
func setNetworkActivityIndicatorVisibility(isVisible: Bool)
}

// MARK: - Network

public final class Network: NetworkType {

private let session: Session
Expand Down
29 changes: 29 additions & 0 deletions WrocliveFramework/Api/Network/NetworkType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import Foundation
import Alamofire
import PromiseKit

public protocol NetworkType {

/// Send network request.
func request(url: URLConvertible,
method: HTTPMethod,
parameters: Parameters?,
encoding: ParameterEncoding,
headers: HTTPHeaders?) -> Promise<Data>

/// Determine the status of a system's current network configuration and the
/// reachability of a target host.
///
/// A remote host is considered reachable when a data packet, sent by an
/// application into the network stack, can leave the local device.
/// Reachability does not guarantee that the data packet will actually be
/// received by the host.
func getReachabilityStatus() -> ReachabilityStatus

/// Show/hide network activity indicator (little circle in the upper left corner).
func setNetworkActivityIndicatorVisibility(isVisible: Bool)
}

0 comments on commit a41c650

Please sign in to comment.