Skip to content

Commit

Permalink
Merge pull request #15 from vespinola/8-create-packageview
Browse files Browse the repository at this point in the history
8 create packageview
  • Loading branch information
vespinola authored Jun 19, 2024
2 parents e99e4fb + bc1eaa0 commit 3d771a2
Show file tree
Hide file tree
Showing 22 changed files with 668 additions and 24 deletions.
56 changes: 56 additions & 0 deletions mobile-courier-app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
/* Begin PBXBuildFile section */
1B0557F62BE9074100367124 /* AuthEndpoints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0557F52BE9074100367124 /* AuthEndpoints.swift */; };
1B07BC8D2BFD677900D8B149 /* RippleSpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B07BC8C2BFD677900D8B149 /* RippleSpinnerView.swift */; };
1B2DDEF22C1E7C95003EC97C /* PackagesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEF12C1E7C95003EC97C /* PackagesView.swift */; };
1B2DDEF42C1E7DD4003EC97C /* PackagePlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEF32C1E7DD4003EC97C /* PackagePlaceholderView.swift */; };
1B2DDEF62C1E9202003EC97C /* PackagesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEF52C1E9202003EC97C /* PackagesViewModel.swift */; };
1B2DDEF82C1E93B6003EC97C /* PackagesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEF72C1E93B6003EC97C /* PackagesModel.swift */; };
1B2DDEFA2C1E951A003EC97C /* PackageEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEF92C1E951A003EC97C /* PackageEntity.swift */; };
1B2DDEFC2C1E956C003EC97C /* PackagesRepositoryProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEFB2C1E956C003EC97C /* PackagesRepositoryProtocol.swift */; };
1B2DDEFE2C1E95D3003EC97C /* PackagesRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEFD2C1E95D3003EC97C /* PackagesRepository.swift */; };
1B2DDF002C1E96B8003EC97C /* PackageEndpoints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDEFF2C1E96B8003EC97C /* PackageEndpoints.swift */; };
1B2DDF022C1E9AC8003EC97C /* PackagesViewModelMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDF012C1E9AC8003EC97C /* PackagesViewModelMock.swift */; };
1B2DDF042C1E9B12003EC97C /* PackagesRepositoryMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDF032C1E9B12003EC97C /* PackagesRepositoryMock.swift */; };
1B2DDF062C1E9F85003EC97C /* GroupedPackageRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2DDF052C1E9F85003EC97C /* GroupedPackageRowView.swift */; };
1B58EF772BE6BBE90066F447 /* MobileCourierApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B58EF762BE6BBE90066F447 /* MobileCourierApp.swift */; };
1B58EF792BE6BBE90066F447 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B58EF782BE6BBE90066F447 /* MainView.swift */; };
1B58EF7B2BE6BBEA0066F447 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B58EF7A2BE6BBEA0066F447 /* Assets.xcassets */; };
Expand All @@ -23,6 +34,7 @@
1B58EFAE2BE6C2BE0066F447 /* CourierTextFieldStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B58EFAD2BE6C2BE0066F447 /* CourierTextFieldStyle.swift */; };
1B58EFB92BE729D20066F447 /* Endpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B58EFB82BE729D20066F447 /* Endpoint.swift */; };
1B5EBFFE2C081DDA003BC2D9 /* AuthData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B5EBFFD2C081DDA003BC2D9 /* AuthData.swift */; };
1B6E3D892C211EEF002619C9 /* SinglePackageRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6E3D882C211EEF002619C9 /* SinglePackageRowView.swift */; };
1B821F192C1AA50600ED1795 /* CustomSessionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B821F182C1AA50600ED1795 /* CustomSessionDelegate.swift */; };
1B85000E2C10033D006E96A0 /* ToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B85000D2C10033D006E96A0 /* ToastView.swift */; };
1B8500102C1004D0006E96A0 /* ToastModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B85000F2C1004D0006E96A0 /* ToastModifier.swift */; };
Expand Down Expand Up @@ -75,6 +87,17 @@
/* Begin PBXFileReference section */
1B0557F52BE9074100367124 /* AuthEndpoints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthEndpoints.swift; sourceTree = "<group>"; };
1B07BC8C2BFD677900D8B149 /* RippleSpinnerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RippleSpinnerView.swift; sourceTree = "<group>"; };
1B2DDEF12C1E7C95003EC97C /* PackagesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesView.swift; sourceTree = "<group>"; };
1B2DDEF32C1E7DD4003EC97C /* PackagePlaceholderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagePlaceholderView.swift; sourceTree = "<group>"; };
1B2DDEF52C1E9202003EC97C /* PackagesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesViewModel.swift; sourceTree = "<group>"; };
1B2DDEF72C1E93B6003EC97C /* PackagesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesModel.swift; sourceTree = "<group>"; };
1B2DDEF92C1E951A003EC97C /* PackageEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageEntity.swift; sourceTree = "<group>"; };
1B2DDEFB2C1E956C003EC97C /* PackagesRepositoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesRepositoryProtocol.swift; sourceTree = "<group>"; };
1B2DDEFD2C1E95D3003EC97C /* PackagesRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesRepository.swift; sourceTree = "<group>"; };
1B2DDEFF2C1E96B8003EC97C /* PackageEndpoints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageEndpoints.swift; sourceTree = "<group>"; };
1B2DDF012C1E9AC8003EC97C /* PackagesViewModelMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesViewModelMock.swift; sourceTree = "<group>"; };
1B2DDF032C1E9B12003EC97C /* PackagesRepositoryMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackagesRepositoryMock.swift; sourceTree = "<group>"; };
1B2DDF052C1E9F85003EC97C /* GroupedPackageRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupedPackageRowView.swift; sourceTree = "<group>"; };
1B58EF732BE6BBE90066F447 /* mobile-courier-app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "mobile-courier-app.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1B58EF762BE6BBE90066F447 /* MobileCourierApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileCourierApp.swift; sourceTree = "<group>"; };
1B58EF782BE6BBE90066F447 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
Expand All @@ -93,6 +116,7 @@
1B58EFAD2BE6C2BE0066F447 /* CourierTextFieldStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourierTextFieldStyle.swift; sourceTree = "<group>"; };
1B58EFB82BE729D20066F447 /* Endpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Endpoint.swift; sourceTree = "<group>"; };
1B5EBFFD2C081DDA003BC2D9 /* AuthData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthData.swift; sourceTree = "<group>"; };
1B6E3D882C211EEF002619C9 /* SinglePackageRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SinglePackageRowView.swift; sourceTree = "<group>"; };
1B821F182C1AA50600ED1795 /* CustomSessionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSessionDelegate.swift; sourceTree = "<group>"; };
1B85000D2C10033D006E96A0 /* ToastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastView.swift; sourceTree = "<group>"; };
1B85000F2C1004D0006E96A0 /* ToastModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastModifier.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,10 +181,22 @@
1B07BC8C2BFD677900D8B149 /* RippleSpinnerView.swift */,
1B85000D2C10033D006E96A0 /* ToastView.swift */,
1B8B0A432C1BDDE600D1A7AC /* HeaderView.swift */,
1B2DDEF32C1E7DD4003EC97C /* PackagePlaceholderView.swift */,
);
path = Helpers;
sourceTree = "<group>";
};
1B2DDEF02C1E652A003EC97C /* Package */ = {
isa = PBXGroup;
children = (
1B2DDEF12C1E7C95003EC97C /* PackagesView.swift */,
1B2DDEF52C1E9202003EC97C /* PackagesViewModel.swift */,
1B2DDF052C1E9F85003EC97C /* GroupedPackageRowView.swift */,
1B6E3D882C211EEF002619C9 /* SinglePackageRowView.swift */,
);
path = Package;
sourceTree = "<group>";
};
1B58EF6A2BE6BBE90066F447 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -291,6 +327,7 @@
children = (
1BE63F6E2BE972A60016A26E /* AuthRepositoryProtocol.swift */,
1B9274D12C115E53008F4FA3 /* AddressRepositoryProtocol.swift */,
1B2DDEFB2C1E956C003EC97C /* PackagesRepositoryProtocol.swift */,
);
path = Repositories;
sourceTree = "<group>";
Expand All @@ -300,6 +337,7 @@
children = (
1B85E8E12BFC4DAE003040CC /* LoginModel.swift */,
1B9274CF2C115AF1008F4FA3 /* AddressesModel.swift */,
1B2DDEF72C1E93B6003EC97C /* PackagesModel.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -328,6 +366,7 @@
children = (
1B85E8E62BFC4E24003040CC /* LoginEntity.swift */,
1B9274D32C115EA4008F4FA3 /* AddressesEntity.swift */,
1B2DDEF92C1E951A003EC97C /* PackageEntity.swift */,
);
path = Entities;
sourceTree = "<group>";
Expand All @@ -337,13 +376,15 @@
children = (
1B85E8E92BFC4E85003040CC /* AuthRepository.swift */,
1B99600E2C12992F00976BBC /* AddressRespository.swift */,
1B2DDEFD2C1E95D3003EC97C /* PackagesRepository.swift */,
);
path = ConcreteRepositories;
sourceTree = "<group>";
};
1B85E8EB2BFC4EAB003040CC /* Presentation */ = {
isa = PBXGroup;
children = (
1B2DDEF02C1E652A003EC97C /* Package */,
1B8500132C100DE2006E96A0 /* Profile */,
1BD17E612C0EB42B009B6C67 /* Navigation */,
1BE58CB12C0585B400C7DF63 /* Home */,
Expand All @@ -360,6 +401,7 @@
1B58EFB82BE729D20066F447 /* Endpoint.swift */,
1B0557F52BE9074100367124 /* AuthEndpoints.swift */,
1B9274CC2C1158E0008F4FA3 /* AddressEndpoints.swift */,
1B2DDEFF2C1E96B8003EC97C /* PackageEndpoints.swift */,
);
path = Endpoints;
sourceTree = "<group>";
Expand Down Expand Up @@ -387,6 +429,8 @@
1BE58CA92C05731B00C7DF63 /* LoginViewModelMock.swift */,
1BC071792C140C6A006EC08E /* ProfileViewModelMock.swift */,
1BC0717B2C140CA9006EC08E /* AddressesRepositoryMock.swift */,
1B2DDF012C1E9AC8003EC97C /* PackagesViewModelMock.swift */,
1B2DDF032C1E9B12003EC97C /* PackagesRepositoryMock.swift */,
);
path = Previews;
sourceTree = "<group>";
Expand Down Expand Up @@ -578,6 +622,7 @@
files = (
1B99600F2C12992F00976BBC /* AddressRespository.swift in Sources */,
1B58EFB92BE729D20066F447 /* Endpoint.swift in Sources */,
1B2DDEF42C1E7DD4003EC97C /* PackagePlaceholderView.swift in Sources */,
1B07BC8D2BFD677900D8B149 /* RippleSpinnerView.swift in Sources */,
1B9274D02C115AF1008F4FA3 /* AddressesModel.swift in Sources */,
1BE58CA82C0572B400C7DF63 /* StorageMock.swift in Sources */,
Expand All @@ -586,8 +631,12 @@
1B9274CB2C1156C6008F4FA3 /* AppData.swift in Sources */,
1BE58CAA2C05731B00C7DF63 /* LoginViewModelMock.swift in Sources */,
1BE63F712BE980D60016A26E /* Storage.swift in Sources */,
1B2DDEFC2C1E956C003EC97C /* PackagesRepositoryProtocol.swift in Sources */,
1B85000E2C10033D006E96A0 /* ToastView.swift in Sources */,
1B2DDEF82C1E93B6003EC97C /* PackagesModel.swift in Sources */,
1B8500102C1004D0006E96A0 /* ToastModifier.swift in Sources */,
1B2DDEF62C1E9202003EC97C /* PackagesViewModel.swift in Sources */,
1B2DDF002C1E96B8003EC97C /* PackageEndpoints.swift in Sources */,
1B58EFA52BE6BFBB0066F447 /* LoginViewModel.swift in Sources */,
1B9960112C129BFB00976BBC /* ProfileViewModel.swift in Sources */,
1B58EFAE2BE6C2BE0066F447 /* CourierTextFieldStyle.swift in Sources */,
Expand All @@ -598,7 +647,10 @@
1B9274D22C115E53008F4FA3 /* AddressRepositoryProtocol.swift in Sources */,
1B58EF792BE6BBE90066F447 /* MainView.swift in Sources */,
1BE63F6D2BE9193E0016A26E /* APIRequestClient.swift in Sources */,
1B2DDF042C1E9B12003EC97C /* PackagesRepositoryMock.swift in Sources */,
1B2DDEFA2C1E951A003EC97C /* PackageEntity.swift in Sources */,
1BE63F6F2BE972A60016A26E /* AuthRepositoryProtocol.swift in Sources */,
1B2DDEF22C1E7C95003EC97C /* PackagesView.swift in Sources */,
1B58EFA92BE6C0070066F447 /* BorderedViewModifier.swift in Sources */,
1BC0717C2C140CA9006EC08E /* AddressesRepositoryMock.swift in Sources */,
1B821F192C1AA50600ED1795 /* CustomSessionDelegate.swift in Sources */,
Expand All @@ -608,10 +660,14 @@
1B9274CD2C1158E0008F4FA3 /* AddressEndpoints.swift in Sources */,
1B85E8E72BFC4E24003040CC /* LoginEntity.swift in Sources */,
1B58EF772BE6BBE90066F447 /* MobileCourierApp.swift in Sources */,
1B2DDF022C1E9AC8003EC97C /* PackagesViewModelMock.swift in Sources */,
1B2DDEFE2C1E95D3003EC97C /* PackagesRepository.swift in Sources */,
1B5EBFFE2C081DDA003BC2D9 /* AuthData.swift in Sources */,
1BC0717A2C140C6A006EC08E /* ProfileViewModelMock.swift in Sources */,
1B6E3D892C211EEF002619C9 /* SinglePackageRowView.swift in Sources */,
1BE58CA62C05727500C7DF63 /* AuthRepositoryMock.swift in Sources */,
1BE58CB32C0585C400C7DF63 /* HomeView.swift in Sources */,
1B2DDF062C1E9F85003EC97C /* GroupedPackageRowView.swift in Sources */,
1BD17E632C0EB438009B6C67 /* Coordinator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
38 changes: 38 additions & 0 deletions mobile-courier-app/Assets.xcassets/surface.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF1",
"green" : "0xE1",
"red" : "0xE2"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x52",
"green" : "0x46",
"red" : "0x45"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// PackagesRepository.swift
// mobile-courier-app
//
// Created by Vladimir Espinola on 2024-06-15.
//

import Foundation

struct PackagesRepository: PackagesRepositoryProtocol {
private var apiRequestClient: APIRequestClientProtocol

init(apiRequestClient: APIRequestClientProtocol) {
self.apiRequestClient = apiRequestClient
}

func getPackagesRetrieved() async throws -> [GroupedPackageEntity] {
let model: PackagesModel = try await apiRequestClient.performRequest(
endpoint: PackageEndpoints.retrieved,
decoder: JSONDecoder()
)

return model.asEntity()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension Endpoint {
]

if let authToken = authToken {
internalHeaders["Authorization"] = "Bearer \(authToken)"
internalHeaders["Authorization"] = authToken
}

return internalHeaders
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// PackageEndpoints.swift
// mobile-courier-app
//
// Created by Vladimir Espinola on 2024-06-15.
//

import Foundation

enum PackageEndpoints {
case retrieved
}

extension PackageEndpoints: Endpoint {
var mockFile: String? {
""
}

var requestType: RequestType {
.get
}

var path: String {
"/frontliner-middleware/api/paquetesRetirados"
}

var body: [AnyHashable: Any]? {
nil
}

var queryParams: [String: String]? {
nil
}
}
79 changes: 79 additions & 0 deletions mobile-courier-app/Data/Networking/Models/PackagesModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// PackagesModel.swift
// mobile-courier-app
//
// Created by Vladimir Espinola on 2024-06-15.
//

import Foundation

struct PackagesModel: Codable {
let paquetes: [PackageModel]
}

struct PackageModel: Codable {
let estado: String
let embarqueEstado: String
let paqueteFechaRetiro: String
let embarqueMedio: String
let tarifaPrecioCli: Decimal
let paqueteDescripcion: String
let paqueteTracking: String
let cotizacion: Decimal
let embarqueFecha: String
let paquetePeso: Decimal
let embarqueCodigo: Int
let id: Int
let paquetePrecio: Decimal

enum CodingKeys: String, CodingKey {
case estado
case embarqueEstado = "embarqueestado"
case paqueteFechaRetiro = "paquetefecharetiro"
case embarqueMedio = "embarquemedio"
case tarifaPrecioCli = "tarifapreciocli"
case paqueteDescripcion = "paquetedescripcion"
case paqueteTracking = "paquetetracking"
case cotizacion
case embarqueFecha = "embarquefecha"
case paquetePeso = "paquetepeso"
case embarqueCodigo = "embarquecodigo"
case id
case paquetePrecio = "paqueteprecio"
}
}

extension PackageModel {
func asEntity() -> PackageEntity {
.init(
estado: estado,
embarqueEstado: embarqueEstado,
paqueteFechaRetiro: paqueteFechaRetiro,
embarqueMedio: embarqueMedio,
tarifaPrecioCli: tarifaPrecioCli,
paqueteDescripcion: paqueteDescripcion,
paqueteTracking: paqueteTracking,
cotizacion: cotizacion,
embarqueFecha: embarqueFecha,
paquetePeso: paquetePeso,
embarqueCodigo: embarqueCodigo,
id: id,
paquetePrecio: paquetePrecio
)
}
}

extension PackagesModel {
func asEntity() -> [GroupedPackageEntity] {
Dictionary(grouping: paquetes, by: { $0.embarqueCodigo })
.sorted(by: {
Int($0.key) > Int($1.key)
})
.map {
GroupedPackageEntity(
embarqueCodigo: $0.key,
paquetes: $0.value.map { $0.asEntity() }
)
}
}
}
Loading

0 comments on commit 3d771a2

Please sign in to comment.