Skip to content

Commit

Permalink
rename output
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubenfer committed Jun 18, 2021
1 parent fe34747 commit 8cdd890
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ import REESwift
### Obtener precios consumidor

```swift
func consumerPrices(startDate: Date, endDate: Date, geo: GEO, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void)
func consumerPrices(date: Date, geo: GEO, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void)
func consumerPrices(startDate: Date, endDate: Date, geo: GEO) -> AnyPublisher<[PrecioLuzValue], Error>
func consumerPrices(date: Date, geo: GEO) -> AnyPublisher<[PrecioLuzValue], Error>
func consumerPrices(startDate: Date, endDate: Date, geo: GEO) async throws -> [PrecioLuzValue]
func consumerPrices(date: Date, geo: GEO) async throws -> [PrecioLuzValue]
func consumerPrices(startDate: Date, endDate: Date, geo: GEO, completion: @escaping (Result<[Value], Error>) -> Void)
func consumerPrices(date: Date, geo: GEO, completion: @escaping (Result<[Value], Error>) -> Void)
func consumerPrices(startDate: Date, endDate: Date, geo: GEO) -> AnyPublisher<[Value], Error>
func consumerPrices(date: Date, geo: GEO) -> AnyPublisher<[Value], Error>
func consumerPrices(startDate: Date, endDate: Date, geo: GEO) async throws -> [Value]
func consumerPrices(date: Date, geo: GEO) async throws -> [Value]
```

### Obtener precios mercado spot

```swift
func spotPrices(startDate: Date, endDate: Date, geo: GEO, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void)
func spotPrices(date: Date, geo: GEO, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void)
func spotPrices(startDate: Date, endDate: Date, geo: GEO) -> AnyPublisher<[PrecioLuzValue], Error>
func spotPrices(date: Date, geo: GEO) -> AnyPublisher<[PrecioLuzValue], Error>
func spotPrices(startDate: Date, endDate: Date) async throws -> [PrecioLuzValue]
func spotPrices(date: Date) async throws -> [PrecioLuzValue]
func spotPrices(startDate: Date, endDate: Date, geo: GEO, completion: @escaping (Result<[Value], Error>) -> Void)
func spotPrices(date: Date, geo: GEO, completion: @escaping (Result<[Value], Error>) -> Void)
func spotPrices(startDate: Date, endDate: Date, geo: GEO) -> AnyPublisher<[Value], Error>
func spotPrices(date: Date, geo: GEO) -> AnyPublisher<[Value], Error>
func spotPrices(startDate: Date, endDate: Date) async throws -> [Value]
func spotPrices(date: Date) async throws -> [Value]
```

## Licencia de uso y contribución con el proyecto
Expand Down
8 changes: 0 additions & 8 deletions Sources/REESwift/Model/PrecioLuzValue.swift

This file was deleted.

8 changes: 8 additions & 0 deletions Sources/REESwift/Model/Value.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

public protocol Value {
var datetime: Date { get }
var value: Float { get }
}

extension APIResponse.Attributes.Value: Value { }
30 changes: 15 additions & 15 deletions Sources/REESwift/REESwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ public struct REESwift {

public extension REESwift {

func consumerPrices(startDate: Date, endDate: Date, geo: GEO, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void) {
func consumerPrices(startDate: Date, endDate: Date, geo: GEO, completion: @escaping (Result<[Value], Error>) -> Void) {
prices(id: "1001", startDate: startDate, endDate: endDate, geo: geo, completion: completion)
}

func consumerPrices(date: Date, geo: GEO, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void) {
func consumerPrices(date: Date, geo: GEO, completion: @escaping (Result<[Value], Error>) -> Void) {
prices(id: "1001", startDate: date.start, endDate: date.end, geo: geo, completion: completion)
}

func consumerPrices(startDate: Date, endDate: Date, geo: GEO) -> AnyPublisher<[PrecioLuzValue], Error> {
func consumerPrices(startDate: Date, endDate: Date, geo: GEO) -> AnyPublisher<[Value], Error> {
return prices(id: "1001", startDate: startDate, endDate: endDate, geo: geo)
}

func consumerPrices(date: Date, geo: GEO) -> AnyPublisher<[PrecioLuzValue], Error> {
func consumerPrices(date: Date, geo: GEO) -> AnyPublisher<[Value], Error> {
return prices(id: "1001", startDate: date.start, endDate: date.end, geo: geo)
}

func spotPrices(startDate: Date, endDate: Date, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void) {
func spotPrices(startDate: Date, endDate: Date, completion: @escaping (Result<[Value], Error>) -> Void) {
prices(id: "600", startDate: startDate, endDate: endDate, geo: nil, completion: completion)
}

func spotPrices(date: Date, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void) {
func spotPrices(date: Date, completion: @escaping (Result<[Value], Error>) -> Void) {
prices(id: "600", startDate: date.start, endDate: date.end, geo: nil, completion: completion)
}

func spotPrices(startDate: Date, endDate: Date) -> AnyPublisher<[PrecioLuzValue], Error> {
func spotPrices(startDate: Date, endDate: Date) -> AnyPublisher<[Value], Error> {
return prices(id: "600", startDate: startDate, endDate: endDate, geo: nil)
}

func spotPrices(date: Date) -> AnyPublisher<[PrecioLuzValue], Error> {
func spotPrices(date: Date) -> AnyPublisher<[Value], Error> {
return prices(id: "600", startDate: date.start, endDate: date.end, geo: nil)
}

private func prices(id: String, startDate: Date, endDate: Date, geo: GEO?, completion: @escaping (Result<[PrecioLuzValue], Error>) -> Void) {
private func prices(id: String, startDate: Date, endDate: Date, geo: GEO?, completion: @escaping (Result<[Value], Error>) -> Void) {
let endpoint = Endpoint.prices(startDate: startDate, endDate: endDate, geo: geo)
Network.shared.request(endpoint) { (result: Result<APIResponse, Error>) in
switch result {
Expand All @@ -55,7 +55,7 @@ public extension REESwift {
}
}

private func prices(id: String, startDate: Date, endDate: Date, geo: GEO?) -> AnyPublisher<[PrecioLuzValue], Error> {
private func prices(id: String, startDate: Date, endDate: Date, geo: GEO?) -> AnyPublisher<[Value], Error> {
let endpoint = Endpoint.prices(startDate: startDate, endDate: endDate, geo: geo)
return Network.shared.request(endpoint)
.tryMap { (apiResponse: APIResponse) -> [APIResponse.Attributes.Value] in
Expand All @@ -74,23 +74,23 @@ public extension REESwift {
@available(macOS 12, *)
public extension REESwift {

func consumerPrices(startDate: Date, endDate: Date, geo: GEO) async throws -> [PrecioLuzValue] {
func consumerPrices(startDate: Date, endDate: Date, geo: GEO) async throws -> [Value] {
return try await prices(id: "1001", startDate: startDate, endDate: endDate, geo: geo)
}

func consumerPrices(date: Date, geo: GEO) async throws -> [PrecioLuzValue] {
func consumerPrices(date: Date, geo: GEO) async throws -> [Value] {
return try await prices(id: "1001", startDate: date.start, endDate: date.end, geo: geo)
}

func spotPrices(startDate: Date, endDate: Date) async throws -> [PrecioLuzValue] {
func spotPrices(startDate: Date, endDate: Date) async throws -> [Value] {
return try await prices(id: "600", startDate: startDate, endDate: endDate, geo: nil)
}

func spotPrices(date: Date) async throws -> [PrecioLuzValue] {
func spotPrices(date: Date) async throws -> [Value] {
return try await prices(id: "600", startDate: date.start, endDate: date.end, geo: nil)
}

private func prices(id: String, startDate: Date, endDate: Date, geo: GEO?) async throws -> [PrecioLuzValue] {
private func prices(id: String, startDate: Date, endDate: Date, geo: GEO?) async throws -> [Value] {
let endpoint = Endpoint.prices(startDate: startDate, endDate: endDate, geo: geo)
let apiResponse: APIResponse = try await Network.shared.request(endpoint)
let prices = apiResponse.included.first { $0.id == id }
Expand Down

0 comments on commit 8cdd890

Please sign in to comment.