-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from vespinola/8-create-packageview
8 create packageview
- Loading branch information
Showing
22 changed files
with
668 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
mobile-courier-app/Assets.xcassets/surface.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
mobile-courier-app/Data/ConcreteRepositories/PackagesRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
mobile-courier-app/Data/Networking/Endpoints/PackageEndpoints.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
79
mobile-courier-app/Data/Networking/Models/PackagesModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() } | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.